2017-03-19 19:59:21 +03:00
|
|
|
.. _prometheus:
|
2017-03-19 12:42:01 +03:00
|
|
|
|
2017-03-19 19:59:21 +03:00
|
|
|
Prometheus
|
|
|
|
==========
|
2017-03-19 12:42:01 +03:00
|
|
|
|
2017-03-19 19:59:21 +03:00
|
|
|
You can export statistics to a ``Prometheus`` server through an exporter.
|
2023-12-29 16:15:49 +03:00
|
|
|
When the *--export prometheus* is used, Glances creates a Prometheus exporter
|
|
|
|
listening on <host:port> (defined in the Glances configuration file).
|
2017-03-19 12:42:01 +03:00
|
|
|
|
|
|
|
.. code-block:: ini
|
|
|
|
|
2017-03-19 19:59:21 +03:00
|
|
|
[prometheus]
|
2017-03-19 12:42:01 +03:00
|
|
|
host=localhost
|
2017-03-19 19:59:21 +03:00
|
|
|
port=9091
|
|
|
|
prefix=glances
|
2019-04-12 12:55:51 +03:00
|
|
|
labels=src:glances
|
|
|
|
|
2022-07-14 20:25:20 +03:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
When running Glances in a container, set ``host=0.0.0.0`` in the Glances configuration file.
|
|
|
|
|
|
|
|
.. note::
|
|
|
|
|
|
|
|
You can use dynamic fields for the label (ex: labels=system:`uname -s`)
|
2017-03-19 12:42:01 +03:00
|
|
|
|
|
|
|
and run Glances with:
|
|
|
|
|
|
|
|
.. code-block:: console
|
|
|
|
|
2018-04-02 15:07:23 +03:00
|
|
|
$ glances --export prometheus
|
2017-03-19 12:42:01 +03:00
|
|
|
|
2017-03-19 19:59:21 +03:00
|
|
|
You can check that Glances exports the stats using this URL: http://localhost:9091
|
|
|
|
|
|
|
|
.. image:: ../_static/prometheus_exporter.png
|
|
|
|
|
|
|
|
In order to store the metrics in a Prometheus server, you should add this
|
|
|
|
exporter to your Prometheus server configuration with the following lines
|
|
|
|
(in the prometheus.yml configuration file):
|
2017-03-19 12:42:01 +03:00
|
|
|
|
|
|
|
.. code-block:: ini
|
|
|
|
|
2017-03-19 19:59:21 +03:00
|
|
|
scrape_configs:
|
|
|
|
- job_name: 'glances_exporter'
|
|
|
|
scrape_interval: 5s
|
|
|
|
static_configs:
|
|
|
|
- targets: ['localhost:9091']
|
2017-03-19 12:42:01 +03:00
|
|
|
|
2017-03-19 19:59:21 +03:00
|
|
|
.. image:: ../_static/prometheus_server.png
|