Anomaly Detection with InfluxDB Tutorial This tutorial is poorly organized, we provide more thorough instructions here.
- python3
- InfluxDB==1.7.9
- Kapacitor==1.5.3 https://portal.influxdata.com/downloads/
brew services start influxdb
brew services start kapacitor
brew services start telegraf
sudo systemctl start influxdb
sudo systemctl start kapacitor
sudo systemctl start telegraf
Execute the command and check for errors.
TODO
sudo journalctl -f -n 128 -u influxdb
or
sudo systemctl status <influxdb/kapacitor/telegraf>
You can run bash run.sh
directly, detailed descriptions are below.
-
Change Kapacitor configs Append the code in
kapacitor-part.conf
to your kapacitor configuration file. It's typically located at/etc/kapacitor/kapacitor.conf
Note that you should remove the previously defined[udf]
function if there is any in your conf file. -
Restart Kapacitor
sudo service kapacitor restart
Check logs for errors
sudo tail -f -n 128 /var/log/kapacitor/kapacitor.log
-
Define Kapacitor Task
kapacitor define print_temps -tick print_temps.tick
If success, there should be nothing printed to your console.
-
Start the recording in the background
rid=$(kapacitor record stream -task print_temps -duration 24h -no-wait)
-
Run python script to generate data
python printer_data.py
-
We can verify it worked by listing information about the recording. Our recording came out to 1.6MB, so yours should come out somewhere close to that:
$ kapacitor list recordings $rid ID Type Status Size Date 7bd3ced5-5e95-4a67-a0e1-f00860b1af47 stream finished 1.6 MB 04 May 16 11:44 MDT
-
Finally, let’s run the play against our task and see how it works:
kapacitor replay -task print_temps -recording $rid -rec-time
-
Check the various log files to see if the algorithm caught the anomalies:
cat /tmp/kapacitor_udf/{hotend,bed,air}_failure.log