Difference between revisions of "Kapacitor"

From air
Jump to navigation Jump to search
Line 21: Line 21:
   
 
=Utilisation=
 
=Utilisation=
  +
  +
Installer et démarrer [[Telegraf]] sur une ou plusieurs machines à monitorer
  +
  +
Créer le fichier cpu_alert.tick
  +
 
<pre>
 
<pre>
  +
stream
  +
.from().measurement('cpu_usage_idle')
  +
.groupBy('host')
  +
.window()
  +
.period(1m)
  +
.every(1m)
  +
.mapReduce(influxql.mean('value'))
  +
.eval(lambda: 100.0 - "mean")
  +
.as('used')
  +
.alert()
  +
.message('{{ .Level}}: {{ .Name }}/{{ index .Tags "host" }} has high cpu usage: {{ index .Fields "used" }}')
  +
.warn(lambda: "used" > 70.0)
  +
.crit(lambda: "used" > 85.0)
  +
</pre>
   
  +
Définir et démarrer la tache cpu_alert.tick
  +
<pre>
  +
kapacitor define \
  +
-name cpu_alert \
  +
-type stream \
  +
-dbrp telegraf.default \
  +
-tick ./cpu_alert.tick
  +
# Start the task
  +
kapacitor enable cpu_alert
  +
</pre>
  +
  +
Arrêter la tache cpu_alert.tick
  +
<pre>
  +
kapacitor disable cpu_alert
 
</pre>
 
</pre>

Revision as of 18:04, 18 February 2016

Kapacitor is a data processing engine. It can process both stream (subscribe realtime) and batch (bulk query) data from InfluxDB. Kapacitor lets you define custom logic to process alerts with dynamic thresholds, match metrics for patterns, compute statistical anomalies, etc.

Installation

wget https://s3.amazonaws.com/influxdb/kapacitor_0.10.0-1_amd64.deb
sudo dpkg -i kapacitor_0.10.0-1_amd64.deb

Configuration

kapacitord config > config.yaml

Editer le fichier config.yaml

Lancement

kapacitord -config config.yaml

Utilisation

Installer et démarrer Telegraf sur une ou plusieurs machines à monitorer

Créer le fichier cpu_alert.tick

stream
    .from().measurement('cpu_usage_idle')
    .groupBy('host')
    .window()
        .period(1m)
        .every(1m)
    .mapReduce(influxql.mean('value'))
    .eval(lambda: 100.0 - "mean")
        .as('used')
    .alert()
        .message('{{ .Level}}: {{ .Name }}/{{ index .Tags "host" }} has high cpu usage: {{ index .Fields "used" }}')
        .warn(lambda: "used" > 70.0)
        .crit(lambda: "used" > 85.0)

Définir et démarrer la tache cpu_alert.tick

kapacitor define \
    -name cpu_alert \
    -type stream \
    -dbrp telegraf.default \
    -tick ./cpu_alert.tick
# Start the task
kapacitor enable cpu_alert

Arrêter la tache cpu_alert.tick

kapacitor disable cpu_alert