The join node itself has a fill option
https://docs.influxdata.com/kapacitor/v0.13/nodes/join_node/#fill
var requests = batch
|query('''
SELECT sum("value")
FROM "apache_logs"."default".app_apache_status
WHERE "http_status" != '500'
''')
.period(20s)
.every(20s)
.align()
.fill(0.0)
var requestErrors = batch
|query('''
SELECT sum("value")
FROM "apache_logs"."default".app_apache_status
WHERE "http_status" = '500'
''')
.period(20s)
.every(20s)
.align()
.fill(0.0)
requests
|join(requestErrors)
.as('requests', 'requestErrors')
.tolerance(20s)
.fill(0.0)
|log()
.level('DEBUG')
|alert()
.crit(lambda: "sum" > 0)
.log('/tmp/kapacitor-app_apache_status-http_requests')
.hipChat()
On Wednesday, July 6, 2016 at 10:41:57 AM UTC-6, Sean Beckett wrote:
>
> In InfluxDB if there's no return at all, fill does nothing. I've opened an
> issue to discuss this behavior:
> https://github.com/influxdata/influxdb/issues/6967
>
> Given https://github.com/influxdata/influxdb/issues/6412 I think it is
> nothing Kapacitor can work around, either, but I will ask.
>
> ---------- Forwarded message ----------
> From: Sean McGary <[email protected] <javascript:>>
> Date: Wed, Jul 6, 2016 at 9:53 AM
> Subject: [influxdb] Influxdb/kapacitor - join fails when one of the batch
> queries returns 0 rows
> To: InfluxDB <[email protected] <javascript:>>
>
>
> Hey folks, Im having some troubles with an influxdb query with kapacitor.
> First off, heres the tick script I have:
>
>
> var requests = batch
> |query('''
> SELECT sum("value")
> FROM "apache_logs"."default".app_apache_status
> WHERE "http_status" != '500'
> ''')
> .period(20s)
> .every(20s)
> .align()
> .fill(0.0)
>
> var requestErrors = batch
> |query('''
> SELECT sum("value")
> FROM "apache_logs"."default".app_apache_status
> WHERE "http_status" = '500'
> ''')
> .period(20s)
> .every(20s)
> .align()
> .fill(0.0)
>
> requests
> |join(requestErrors)
> .as('requests', 'requestErrors')
> .tolerance(20s)
> |log()
> .level('DEBUG')
> |alert()
> .crit(lambda: "sum" > 0)
> .log('/tmp/kapacitor-app_apache_status-http_requests')
> .hipChat()
>
>
> The fields in my measurement "app_apache_status" that are relevant to this
> are: time, value (an int) and http_status (apparently a string?). The
> queries should be pretty explanatory - one to get all 500 errors, the other
> to get everything else.
>
> The place where Im running into issues is that the query to get all of the
> 500 errors returns 0 rows most of the time which seems to be messing with
> the ability to join to the other batch. Even with adding fill(0) it still
> returns 0 rows.
>
> My question: is there a way to always return at least 1 row where the sum
> is simply 0, even if there are 0 rows that are found in the time range?
>
> --
> Remember to include the InfluxDB version number with all issue reports
> ---
> You received this message because you are subscribed to the Google Groups
> "InfluxDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/influxdb.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/influxdb/6b233752-edd2-4523-9022-5c83dbcae344%40googlegroups.com
>
> <https://groups.google.com/d/msgid/influxdb/6b233752-edd2-4523-9022-5c83dbcae344%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Sean Beckett
> Director of Support and Professional Services
> InfluxDB
>
--
Remember to include the InfluxDB version number with all issue reports
---
You received this message because you are subscribed to the Google Groups
"InfluxDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/influxdb.
To view this discussion on the web visit
https://groups.google.com/d/msgid/influxdb/80f884bd-4eff-4f77-81db-dfe54ddc39a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.