influxdata / influxdata/kapacitor
StateCount and StateDuration with batch
- Dominant language
- Go
- Stars
- 2.4k
- Forks
- 479
- Avg merge
- 4d 16h
- Merged PRs (30d)
- 4
Description
Hi,
I have an issue with getting StateCount and StateDuration to work with batch task. In the task below, "stat" always returns 0. Therefore with "|stateDuration(lambda: "stat" <= 10)", I would expect "state_duration" to increase every time query is executed, however that is not happening. Every single time batch is executed, state_duration is reset to 0 (state_count to 1 if I use StateCount). Am I missing something here?
> batch
> |query('''
> SELECT last(QueueSize) AS stat FROM "metrics_telegraf"."autogen"."jolokia2_amq_queue"
> ''')
> .groupBy('server_group_env', 'host', 'Destination')
> .period(1m)
> .every(10s)
> |stateDuration(lambda: "stat" <= 10)
> |alert()
> .crit(lambda: "state_duration" < 100)
> .id('XXX_ACTIVEMQ_QUEUE_{{ index .Tags "host" }}_{{ index .Tags "Destination" }}')
> .message('XXX_APAC: ActiveMQ queue {{ index .Tags "Destination" }} on {{ index .Tags "host" }} is filling up')
> .alerta()
> .services('First Data')
> .resource('XXX')
> .value('{{ index .Fields "state_duration" | printf "%0.2f"}}')
> .environment('{{ index .Tags "server_group_env" }}')
> .group('XXX')
> .snmpTrap('1.3.6.1.4.1.3154.2.2.1')
> .data('1.3.6.1.4.1.3154.2.2.1.1', 's', 'XXX')
> .data('1.3.6.1.4.1.3154.2.2.1.2', 's', '{{ .ID }}')
> .data('1.3.6.1.4.1.3154.2.2.1.3', 'i', '{{ if eq .Level "CRITICAL" }}5{{ else if eq .Level "WARNING"}}3{{ else }}1{{ end }}')
> .data('1.3.6.1.4.1.3154.2.2.1.4', 's', '{{ .Message }}')
> .data('1.3.6.1.4.1.3154.2.2.1.5', 'i', '{{ if eq .Level "OK" }}2{{ else }}1{{ end }}')
> .data('1.3.6.1.4.1.3154.2.2.1.6', 's', 'rjpvir1000')
> .data('1.3.6.1.4.1.3154.2.2.1.7', 's', 'I3XXX')
> .data('1.3.6.1.4.1.3154.2.2.1.8', 'i', '104')
>
Contributor guide
Assessment
This issue has not been assessed yet.