Difference between revisions of "Kapacitor"

From air
Jump to navigation Jump to search
Line 33: Line 33:
   
 
=Utilisation=
 
=Utilisation=
  +
<pre>
  +
kapacitor help
  +
</pre>
   
  +
<pre>
  +
record record the result of a query or a snapshot of the current stream data.
  +
define create/update a task.
  +
replay replay a recording to a task.
  +
enable enable and start running a task with live data.
  +
disable stop running a task.
  +
reload reload a running task with an updated task definition.
  +
push publish a task definition to another Kapacitor instance. Not implemented yet.
  +
delete delete a task or a recording.
  +
list list information about tasks or recordings.
  +
show display detailed information about a task.
  +
help get help for a command.
  +
level sets the logging level on the kapacitord server.
  +
version displays the Kapacitor version info.
  +
</pre>
 
Installer et démarrer [[Telegraf]] sur une ou plusieurs machines à monitorer
 
Installer et démarrer [[Telegraf]] sur une ou plusieurs machines à monitorer
   
Line 61: Line 79:
 
-dbrp telegraf.default \
 
-dbrp telegraf.default \
 
-tick ./cpu_alert.tick
 
-tick ./cpu_alert.tick
  +
  +
kapacitor list tasks
  +
 
# Start the task
 
# Start the task
 
kapacitor enable cpu_alert
 
kapacitor enable cpu_alert
  +
kapacitor list tasks
  +
kapacitor show cpu_alert
 
</pre>
 
</pre>
   
  +
Arrêter la tache cpu_alert.tick
 
  +
  +
=Recording=
  +
TODO
  +
<pre>
  +
kapacitor help recording
  +
kapacitor list recordings
  +
kapacitor record stream -name cpu_alert -duration 1m
  +
kapacitor list recordings
  +
</pre>
  +
  +
  +
=Replay=
  +
TODO
  +
<pre>
  +
kapacitor help replay
  +
kapacitor list recordings
  +
kapacitor replay -id 6f68d222-0873-44ad-9d46-7b4b03d8acee -name cpu_alert -rec-time
  +
</pre>
  +
  +
  +
=Arrêt du tâche=
 
Arrêter la tâche cpu_alert.tick
 
<pre>
 
<pre>
 
kapacitor disable cpu_alert
 
kapacitor disable cpu_alert

Revision as of 19:35, 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

Standalone

kapacitord config > kapacitor.conf

Editer le fichier kapacitor.conf pour modifier l'adresse du serveur influxdb stockant la base de données telegraf.

Service

Editer le fichier /etc/kapacitor/kapacitor.conf pour modifier l'adresse du serveur influxdb stockant la base de données telegraf.

Lancement

Standalone

kapacitord -config ./kapacitor.conf

Service

sudo service kapacitor start
sudo service kapacitor version
sudo service kapacitor status

Utilisation

kapacitor help
	record   record the result of a query or a snapshot of the current stream data.
	define   create/update a task.
	replay   replay a recording to a task.
	enable   enable and start running a task with live data.
	disable  stop running a task.
	reload   reload a running task with an updated task definition.
	push     publish a task definition to another Kapacitor instance. Not implemented yet.
	delete   delete a task or a recording.
	list     list information about tasks or recordings.
	show     display detailed information about a task.
	help     get help for a command.
	level    sets the logging level on the kapacitord server.
	version  displays the Kapacitor version info.

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

Depuis un autre terminal, 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

kapacitor list tasks

# Start the task
kapacitor enable cpu_alert
kapacitor list tasks
kapacitor show cpu_alert


Recording

TODO

kapacitor help recording
kapacitor list recordings
kapacitor record stream -name cpu_alert -duration 1m
kapacitor list recordings


Replay

TODO

kapacitor help replay
kapacitor list recordings
kapacitor replay -id 6f68d222-0873-44ad-9d46-7b4b03d8acee -name cpu_alert -rec-time


Arrêt du tâche

Arrêter la tâche cpu_alert.tick

kapacitor disable cpu_alert

Remarque: en cas d'arrêt et de redémarrage de kapacitord, les taches actives avant l'arrêt sont activées.