Create a flask app to show metrics from collectd
[barometer.git] / docker / flask_app / README
1 To build this run:
2   sudo docker build -t my-flask-app .
3
4 To run the app and see collectd metrics:
5
6   sudo docker run -d --net=host  my-flask-app
7   OR
8   sudo docker run -d -p 5000:5000  my-flask-app
9
10 and configure collectd to use the write_http plugin:
11
12  LoadPlugin write_http
13
14  <Plugin "write_http">
15    <Node "example">
16      URL "http://127.0.0.1:5000"
17      Format Command
18      # Format JSON
19    </Node>
20  </Plugin>
21
22 Format Command is used to make the output more readable for humans.
23 You can also use JSON.
24
25 Later the server will do something more useful.
26 To view the metrics that are being sent by collectd, run::
27
28    sudo docker inspect <container_id>
29    #OR
30    sudo docker logs <container_id>
31
32 Metrics from collectd-5.x will use PUTVAL
33 Metrics from collectd-6.x will use PUTMETRIC
34
35 Sample output::
36
37   127.0.0.1 - - [21/Apr/2021 19:31:49] "POST / HTTP/1.1" 200 -
38   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-cpu00/gauge-TSC interval=10.000 1619029909.268:2112.02271161789
39   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-cpu00/frequency-busy interval=10.000 1619029909.268:1613.51555288381
40   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-cpu00/percent-c1 interval=10.000 1619029909.268:86.2353665532377
41   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-cpu00/frequency-average interval=10.000 1619029909.268:222.094501460956
42   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-pkg00/temperature interval=10.000 1619029909.268:53
43   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-pkg00/temperature-tcc_activation interval=10.000 1619029909.268:100
44   PUTVAL fbae30cc-2f20-11b2-a85c-819293100691/turbostat-cpu04/frequency-average interval=10.000 1619029909.268:206.978572579757
45