Using collectd and kapacitor - not triggering alerts

I am trying to get kapacitor to trigger an alert based on collectd data in influxdb. Am basing my tick file on the answer in using kapacitor with influxdb and collectd.

stream
// Select just the cpu measurement from our example database.
|from()
    .measurement('cpu_value')
    .where(lambda: "type" == 'percent' AND "type_instance" == 'idle')
|alert()
    .crit(lambda: "value" <  98)
    // Whenever we get an alert write it to a file.
    .log('/tmp/alerts.log')

I have defined the alert as per kapacitor docs:

kapacitor define cpu_alert -type stream -tick cpu_alert.tick -dbrp collectd.default

Appropriate data is being sent to influxdb from collectd and available via query:

select value from /cpu_value/ where type='percent' and type_instance = 'idle' order by time desc limit 10;

enter image description here

However running :

kapacitor record stream -task cpu_alert -duration 20s &

does not record any data:

$ kapacitor list recordings
ID                                      Type    Status    Size      Date                   
48e5c04a-68c2-44a3-ba80-f2c12d952994    stream  running   0 B       19    Jul 16 11:57 IST  

I suspect that I may not be correctly referencing the database when I register the task, but cannot see where I have an error.

0
задан 13 April 2017 в 15:13
1 ответ

Основной причиной была неправильная конфигурация. Обратите внимание на разделы «Influxdb.subscriptions» и «Influxdb.excluded-subscriptions» в файле kapacitor.conf.

По умолчанию kapacitor подписывается на все БД Influx. Я хотел, чтобы он подписался только на одну БД, но по ошибке включил это в раздел «infxdb.excluded-subscriptions», а не в «infxdb.subscriptions».

Вы можете увидеть, какие подписки активны, выполнив «ПОКАЗАТЬ ПОДПИСКИ» запрос к infxdb.

1
ответ дан 4 December 2019 в 16:33