]> git.proxmox.com Git - ceph.git/blame - ceph/doc/mgr/prometheus.rst
update sources to 12.2.2
[ceph.git] / ceph / doc / mgr / prometheus.rst
CommitLineData
3efd9988 1=================
c07f9fc5
FG
2Prometheus plugin
3=================
4
5Provides a Prometheus exporter to pass on Ceph performance counters
6from the collection point in ceph-mgr. Ceph-mgr receives MMgrReport
7messages from all MgrClient processes (mons and OSDs, for instance)
8with performance counter schema data and actual counter data, and keeps
9a circular buffer of the last N samples. This plugin creates an HTTP
10endpoint (like all Prometheus exporters) and retrieves the latest sample
11of every counter when polled (or "scraped" in Prometheus terminology).
12The HTTP path and query parameters are ignored; all extant counters
13for all reporting entities are returned in text exposition format.
14(See the Prometheus `documentation <https://prometheus.io/docs/instrumenting/exposition_formats/#text-format-details>`_.)
15
3efd9988
FG
16Enabling prometheus output
17==========================
c07f9fc5
FG
18
19The *prometheus* module is enabled with::
20
21 ceph mgr module enable prometheus
22
23Configuration
24-------------
25
26By default the module will accept HTTP requests on port ``9283`` on all
27IPv4 and IPv6 addresses on the host. The port and listen address are both
28configurable with ``ceph config-key set``, with keys
29``mgr/prometheus/server_addr`` and ``mgr/prometheus/server_port``.
30This port is registered with Prometheus's `registry <https://github.com/prometheus/prometheus/wiki/Default-port-allocations>`_.
31
3efd9988
FG
32Statistic names and labels
33==========================
34
35The names of the stats are exactly as Ceph names them, with
36illegal characters ``.``, ``-`` and ``::`` translated to ``_``,
37and ``ceph_`` prefixed to all names.
38
39
40All *daemon* statistics have a ``ceph_daemon`` label such as "osd.123"
41that identifies the type and ID of the daemon they come from. Some
42statistics can come from different types of daemon, so when querying
43e.g. an OSD's RocksDB stats, you would probably want to filter
44on ceph_daemon starting with "osd" to avoid mixing in the monitor
45rocksdb stats.
46
47
48The *cluster* statistics (i.e. those global to the Ceph cluster)
49have labels appropriate to what they report on. For example,
50metrics relating to pools have a ``pool_id`` label.
51
52Pool and OSD metadata series
53----------------------------
54
55Special series are output to enable displaying and querying on
56certain metadata fields.
57
58Pools have a ``ceph_pool_metadata`` field like this:
59
60::
61
62 ceph_pool_metadata{pool_id="2",name="cephfs_metadata_a"} 0.0
63
64OSDs have a ``ceph_osd_metadata`` field like this:
65
66::
67
68 ceph_osd_metadata{cluster_addr="172.21.9.34:6802/19096",device_class="ssd",id="0",public_addr="172.21.9.34:6801/19096",weight="1.0"} 0.0
69
70
71Correlating drive statistics with node_exporter
72-----------------------------------------------
73
74The prometheus output from Ceph is designed to be used in conjunction
75with the generic host monitoring from the Prometheus node_exporter.
76
77To enable correlation of Ceph OSD statistics with node_exporter's
78drive statistics, special series are output like this:
79
80::
81
82 ceph_disk_occupation{ceph_daemon="osd.0",device="sdd",instance="myhost",job="ceph"}
83
84To use this to get disk statistics by OSD ID, use the ``and on`` syntax
85in your prometheus query like this:
86
87::
88
89 rate(node_disk_bytes_written[30s]) and on (device,instance) ceph_disk_occupation{ceph_daemon="osd.0"}
90
91See the prometheus documentation for more information about constructing
92queries.
93
94Note that for this mechanism to work, Ceph and node_exporter must agree
95about the values of the ``instance`` label. See the following section
96for guidance about to to set up Prometheus in a way that sets
97``instance`` properly.
98
99Configuring Prometheus server
100=============================
101
102See the prometheus documentation for full details of how to add
103scrape endpoints: the notes
104in this section are tips on how to configure Prometheus to capture
105the Ceph statistics in the most usefully-labelled form.
106
107This configuration is necessary because Ceph is reporting metrics
108from many hosts and services via a single endpoint, and some
109metrics that relate to no physical host (such as pool statistics).
110
111honor_labels
112------------
113
114To enable Ceph to output properly-labelled data relating to any host,
115use the ``honor_labels`` setting when adding the ceph-mgr endpoints
116to your prometheus configuration.
117
118Without this setting, any ``instance`` labels that Ceph outputs, such
119as those in ``ceph_disk_occupation`` series, will be overridden
120by Prometheus.
121
122Ceph instance label
123-------------------
124
125By default, Prometheus applies an ``instance`` label that includes
126the hostname and port of the endpoint that the series game from. Because
127Ceph clusters have multiple manager daemons, this results in an ``instance``
128label that changes spuriously when the active manager daemon changes.
129
130Set a custom ``instance`` label in your Prometheus target configuration:
131you might wish to set it to the hostname of your first monitor, or something
132completely arbitrary like "ceph_cluster".
133
134node_exporter instance labels
135-----------------------------
136
137Set your ``instance`` labels to match what appears in Ceph's OSD metadata
138in the ``hostname`` field. This is generally the short hostname of the node.
139
140This is only necessary if you want to correlate Ceph stats with host stats,
141but you may find it useful to do it in all cases in case you want to do
142the correlation in the future.
143
144Example configuration
145---------------------
146
147This example shows a single node configuration running ceph-mgr and
148node_exporter on a server called ``senta04``.
149
150This is just an example: there are other ways to configure prometheus
151scrape targets and label rewrite rules.
152
153prometheus.yml
154~~~~~~~~~~~~~~
155
156::
157
158 global:
159 scrape_interval: 15s
160 evaluation_interval: 15s
161
162 scrape_configs:
163 - job_name: 'node'
164 file_sd_configs:
165 - files:
166 - node_targets.yml
167 - job_name: 'ceph'
168 honor_labels: true
169 file_sd_configs:
170 - files:
171 - ceph_targets.yml
172
173
174ceph_targets.yml
175~~~~~~~~~~~~~~~~
176
177
178::
179
180 [
181 {
182 "targets": [ "senta04.mydomain.com:9283" ],
183 "labels": {
184 "instance": "ceph_cluster"
185 }
186 }
187 ]
188
189
190node_targets.yml
191~~~~~~~~~~~~~~~~
192
193::
194
195 [
196 {
197 "targets": [ "senta04.mydomain.com:9100" ],
198 "labels": {
199 "instance": "senta04"
200 }
201 }
202 ]
203
204
c07f9fc5 205Notes
3efd9988 206=====
c07f9fc5
FG
207
208Counters and gauges are exported; currently histograms and long-running
209averages are not. It's possible that Ceph's 2-D histograms could be
210reduced to two separate 1-D histograms, and that long-running averages
211could be exported as Prometheus' Summary type.
212
c07f9fc5
FG
213Timestamps, as with many Prometheus exporters, are established by
214the server's scrape time (Prometheus expects that it is polling the
215actual counter process synchronously). It is possible to supply a
216timestamp along with the stat report, but the Prometheus team strongly
217advises against this. This means that timestamps will be delayed by
218an unpredictable amount; it's not clear if this will be problematic,
219but it's worth knowing about.