summaryrefslogtreecommitdiffstats
path: root/docs/gw/influxdb.rst
blob: 4c0cc4db1e5fccfe0c7cc1dbe736b5fda5d23054 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
.. _influxdb:

InfluxDB
========

You can export statistics to an ``InfluxDB`` server (time series server).

In Glances version 3.2.0 and higher, the way Glances exports stats to
InfluxDB changes. The following fields will be added as tags:

- key stats (for example *interface_name* for network, container *name* for docker...)
- hostname (shortname)
- tags

Glances InfluxDB data model:

+---------------+-----------------------+-----------------------+
| Measurement   | Fields                | Tags                  |
+===============+=======================+=======================+
| cpu           | user                  | hostname              |
|               | system                |                       |
|               | iowait...             |                       |
+---------------+-----------------------+-----------------------+
| network       | read_bytes            | hostname              |
|               | write_bytes           | disk_name             |
|               | time_since_update...  |                       |
|               |                       |                       |
+---------------+-----------------------+-----------------------+
| diskio        | rx                    | hostname              |
|               | tx                    | interface_name        |
|               | time_since_update...  |                       |
|               |                       |                       |
+---------------+-----------------------+-----------------------+
| docker        | cpu_percent           | hostname              |
|               | memory_usage...       | name                  |
+---------------+-----------------------+-----------------------+
| gpu           | proc                  | hostname              |
|               | mem                   | gpu_id                |
|               | temperature...        |                       |
+---------------+-----------------------+-----------------------+

InfluxDB (up to version 1.7.x)
------------------------------

The connection should be defined in the Glances configuration file as
following:

.. code-block:: ini

    [influxdb]
    host=localhost
    port=8086
    protocol=http
    user=root
    password=root
    db=glances
    # Prefix will be added for all measurement name
    # Ex: prefix=foo
    #     => foo.cpu
    #     => foo.mem
    # You can also use dynamic values
    #prefix=foo
    # Following tags will be added for all measurements
    # You can also use dynamic values.
    # Note: hostname is always added as a tag
    #tags=foo:bar,spam:eggs,domain:`domainname`

and run Glances with:

.. code-block:: console

    $ glances --export influxdb

Glances generates a lot of columns, e.g., if you have many running
Docker containers, so you should use the ``tsm1`` engine in the InfluxDB
configuration file (no limit on columns number).

Note: if you want to use SSL, please set 'protocol=https'.


InfluxDB v2 (from InfluxDB v1.8.x/Flux and InfluxDB v2.x)
---------------------------------------------------------

Note: The InfluxDB v2 client (https://pypi.org/project/influxdb-client/)
is only available for Python 3.6 or higher.

The connection should be defined in the Glances configuration file as
following:

.. code-block:: ini

    [influxdb2]
    host=localhost
    port=8086
    protocol=http
    org=nicolargo
    bucket=glances
    token=EjFUTWe8U-MIseEAkaVIgVnej_TrnbdvEcRkaB1imstW7gapSqy6_6-8XD-yd51V0zUUpDy-kAdVD1purDLuxA==
    # Prefix will be added for all measurement name
    # Ex: prefix=foo
    #     => foo.cpu
    #     => foo.mem
    # You can also use dynamic values
    #prefix=foo
    # Following tags will be added for all measurements
    # You can also use dynamic values.
    # Note: hostname is always added as a tag
    #tags=foo:bar,spam:eggs,domain:`domainname`

and run Glances with:

.. code-block:: console

    $ glances --export influxdb2

Note: if you want to use SSL, please set 'protocol=https'.

Grafana
-------

For Grafana users, Glances provides a dedicated for `InfluxQL`_ or `Flux`_ InfluxDB datasource.

.. image:: ../_static/glances-influxdb.png

To use it, just import the file in your ``Grafana`` web interface.

.. image:: ../_static/grafana.png

.. _InfluxQL: https://github.com/nicolargo/glances/blob/master/conf/glances-grafana-influxql.json
.. _Flux: https://github.com/nicolargo/glances/blob/master/conf/glances-grafana-flux.json