blob: acd8a82133cbd03b9b66ffe081529bbfcc6efecc (
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
|
.. SPDX-License-Identifier: GPL-3.0-or-later
.. _mod-http-prometheus:
Prometheus metrics endpoint
---------------------------
The :ref:`HTTP module <mod-http>` exposes ``/metrics`` endpoint that serves metrics
from :ref:`mod-stats` in Prometheus_ text format.
You can use it as soon as HTTP module is configured:
.. code-block:: bash
$ curl -k https://localhost:8453/metrics | tail
# TYPE latency histogram
latency_bucket{le=10} 2.000000
latency_bucket{le=50} 2.000000
latency_bucket{le=100} 2.000000
latency_bucket{le=250} 2.000000
latency_bucket{le=500} 2.000000
latency_bucket{le=1000} 2.000000
latency_bucket{le=1500} 2.000000
latency_bucket{le=+Inf} 2.000000
latency_count 2.000000
latency_sum 11.000000
You can namespace the metrics in configuration, using `http.prometheus.namespace` attribute:
.. code-block:: lua
modules.load('http')
-- Set Prometheus namespace
http.prometheus.namespace = 'resolver_'
You can also add custom metrics or rewrite existing metrics before they are returned to Prometheus client.
.. code-block:: lua
modules.load('http')
-- Add an arbitrary metric to Prometheus
http.prometheus.finalize = function (metrics)
table.insert(metrics, 'build_info{version="1.2.3"} 1')
end
.. _Prometheus: https://prometheus.io
|