Monitoring¶
ILMO should, like every other software, be easy to monitor. Therefore a basic metrics are exposed to https://example.com/metrics_json/. The data is encoded in JSON format and is therefore suitable to bea read by humans and it is easy to use it as data source for further processing.
Exposed Metrics¶
users: number of users (all roles combined)
loan: number of loans
loan_length_mean: Mean loan length in days
admin_num: Number of admins
lent_books_num: number of books that are lent
avail_books_num: number of books that are available
lent_material_num: number of materials are lent
avail_material_num: number of materials are available
Example workflow¶
To use the exposed metrics you will usually need a time series database and a visualization tool.
As time series database we will utilize InfluxDB, the visualization tool will be Grafana.
InfluxDB and Telegraf¶
First we install InfluxDB (e.g. with docker, be aware of the security risks!).
# Pull the image
$ sudo docker pull influxdb
# Start influxdb
$ sudo docker run -d -p 8086:8086 -v influxdb:/var/lib/influxdb --name influxdb influxdb
# Start influxdb console
$ docker exec -it influxdb influx
Connected to http://localhost:8086 version 1.8.3
InfluxDB shell version: 1.8.3
> create database monitoring
> create user "telegraf" with password 'mypassword'
> grant all on monitoring to telegraf
Note
When creating the user telegraf check the double and single quotes for username an password.
Now install telegraf and configure etc/telegraf/telegraf.conf. Modify the domain and your password for the InfluxDB database.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | # Global tags can be specified here in key="value" format.
[global_tags]
# Configuration for telegraf agent
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
# Configuration for sending metrics to InfluxDB
[[outputs.influxdb]]
urls = ["http://:::8086"]
database = "telegraf"
skip_database_creation = true
username = 'telegraf'
password = 'yourpassword'
[[inputs.http]]
urls = ["https://example.com/metrics_json/"]
name_override = "ilmo"
#Data from HTTP in JSON format
data_format = "json"
|
Graphana¶
Now we can simply use the InfluxDB as data source in Grafana and configure until you have beautiful plots!