Good evening all !
I have a tick script, used as stream Node.
The script keep looking new data for a specific table, and insert some sum of data in other table. So I am able to perform faster queries.
My issue is that the values of these tables are not the same at the end of the day (and I believe should be).
This is the comparative (example of one week):
SELECT count(“time_taken”) FROM “web_logs_iis” WHERE (“hostname” =~ /^hostname$/) and time >= ‘2018-11-11 00:00:00’ and time <= ‘2018-11-17 23:59:59’
name: web_logs_iis
time count
2018-11-11T00:00:00Z 3.157.175
SELECT sum(“total”) FROM “apm_apex” WHERE (“hostname” =~ /^hostname$/) and time >= ‘2018-11-11 00:00:00’ and time <= ‘2018-11-17 23:59:59’
name: apm_apex
time sum
2018-11-11T00:00:00Z 21.010.226
And this is the tick script.
Am I using some incorrect variable? Any help will be appreciated.
var t_satisfied = 20000
var t_tolerating = 60000
var fromMeasurement = ‘web_logs_iis’
var toMeasurement = ‘apm_apex’
var database = ‘80’
var retention = ‘quarterly’
var period = 1m
var every = 1m
var requests = stream
|from()
.measurement(fromMeasurement)
.groupBy(‘hostname’)
|window()
.fillPeriod()
.period(period)
.every(every)
var total = requests
|count(‘time_taken’)
.as(‘total’)
|groupBy(‘hostname’)
|httpOut(‘total’)
var failed = requests
|where(lambda: int(“protocol_status”) >= 400)
|count(‘time_taken’)
.as(‘failed’)
|groupBy(‘hostname’)
|httpOut(‘failed’)
var satisfied = requests
|where(lambda: int(“time_taken”) <= t_satisfied AND int(“protocol_status”) < 400)
|count(‘time_taken’)
.as(‘satisfied’)
|groupBy(‘hostname’)
|httpOut(‘satisfied’)
var tolerating = requests
|where(lambda: int(“time_taken”) > t_satisfied AND int(“time_taken”) <= t_tolerating AND int(“protocol_status”) < 400)
|count(‘time_taken’)
.as(‘tolerating’)
|groupBy(‘hostname’)
|httpOut(‘tolerating’)
var frustrated = requests
|where(lambda: int(“time_taken”) > t_tolerating AND int(“protocol_status”) < 400)
|count(‘time_taken’)
.as(‘frustrated’)
|groupBy(‘hostname’)
|httpOut(‘frustrated’)
var good_rate = satisfied
// |log()
// .level(‘DEBUG’)
|join(tolerating)
.as(‘satisfied’, ‘tolerating’)
// .fill(‘none’)
|eval(lambda: float(“satisfied.satisfied”) + (float(“tolerating.tolerating”) / 2.0))
.as(‘good_rate’)
|httpOut(‘good_rate’)
var apex = total
|join(good_rate)
.as(‘total’, ‘good_rate’)
|eval(lambda: float(“good_rate.good_rate”) / float(“total.total”))
.as(‘apex’)
|httpOut(‘apex’)
total
|influxDBOut()
.create()
.database(database)
.retentionPolicy(retention)
.measurement(toMeasurement)
.tag(‘kapacitor’, toMeasurement)
.flushInterval(1s)
failed
|influxDBOut()
.create()
.database(database)
.retentionPolicy(retention)
.measurement(toMeasurement)
.tag(‘kapacitor’, toMeasurement)
satisfied
|influxDBOut()
.create()
.database(database)
.retentionPolicy(retention)
.measurement(toMeasurement)
.tag(‘kapacitor’, toMeasurement)
tolerating
|influxDBOut()
.create()
.database(database)
.retentionPolicy(retention)
.measurement(toMeasurement)
.tag(‘kapacitor’, toMeasurement)
frustrated
|influxDBOut()
.create()
.database(database)
.retentionPolicy(retention)
.measurement(toMeasurement)
.tag(‘kapacitor’, toMeasurement)
apex
|influxDBOut()
.create()
.database(database)
.retentionPolicy(retention)
.measurement(toMeasurement)
.tag(‘kapacitor’, toMeasurement)