Repository navigation
Expand file tree
/
Copy pathPrometheusRequestHandlerFactory.h
More file actions
124 lines (114 loc) · 4.22 KB
/
Copy pathPrometheusRequestHandlerFactory.h
File metadata and controls
124 lines (114 loc) · 4.22 KB
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
#pragma once
#include <base/types.h>
#include <memory>
namespace Poco::Util { class AbstractConfiguration; }
namespace DB
{
class IServer;
class HTTPRequestHandlerFactory;
using HTTPRequestHandlerFactoryPtr = std::shared_ptr<HTTPRequestHandlerFactory>;
class AsynchronousMetrics;
/// Makes a handler factory to handle prometheus protocols.
/// Expects a configuration like this:
///
/// <prometheus>
/// <port>1234</port>
/// <endpoint>/metric</endpoint>
/// <metrics>true</metrics>
/// <asynchronous_metrics>true</asynchronous_metrics>
/// <events>true</events>
/// <errors>true</errors>
/// </prometheus>
///
/// More prometheus protocols can be supported with using a different configuration <prometheus.handlers>
/// (which is similar to the <http_handlers> section):
///
/// <prometheus>
/// <port>1234</port>
/// <handlers>
/// <my_rule1>
/// <url>/metrics</url>
/// <handler>
/// <type>metrics</type>
/// <metrics>true</metrics>
/// <asynchronous_metrics>true</asynchronous_metrics>
/// <events>true</events>
/// <errors>true</errors>
/// </handler>
/// </my_rule1>
/// </handlers>
/// </prometheus>
///
/// An alternative port to serve prometheus protocols can be specified in the <protocols> section:
///
/// <protocols>
/// <my_protocol_1>
/// <port>4321</port>
/// <type>prometheus</type>
/// </my_protocol_1>
/// </protocols>
HTTPRequestHandlerFactoryPtr createPrometheusHandlerFactory(
IServer & server,
const Poco::Util::AbstractConfiguration & config,
const AsynchronousMetrics & asynchronous_metrics,
const String & name);
/// Makes a HTTP handler factory to handle requests for prometheus metrics for a HTTP rule in the <http_handlers> section.
/// Expects a configuration like this:
///
/// <http_port>8123</http_port>
/// <http_handlers>
/// <my_rule_1>
/// <url>/metrics</url>
/// <handler>
/// <type>prometheus_metrics</type>
/// <metrics>true</metrics>
/// <asynchronous_metrics>true</asynchronous_metrics>
/// <events>true</events>
/// <errors>true</errors>
/// </handler>
/// </my_rule_1>
/// <my_rule2>
/// <url_prefix>/prometheus/api/v1</url_prefix>
/// <handler>
/// <type>prometheus_api_v1</type>
/// <table>db.time_series_table_name</table>
/// </handler>
/// </my_rule2>
/// </http_handlers>
HTTPRequestHandlerFactoryPtr createPrometheusHandlerFactoryForHTTPRule(
IServer & server,
const Poco::Util::AbstractConfiguration & config,
const String & config_prefix, /// path to "http_handlers.my_handler_1"
const AsynchronousMetrics & asynchronous_metrics,
std::unordered_map<String, String> & common_headers);
/// Makes a HTTP Handler factory to handle requests for prometheus metrics as a part of the default HTTP rule in the <http_handlers> section.
/// Expects a configuration like this:
///
/// <http_port>8123</http_port>
/// <http_handlers>
/// <defaults/>
/// </http_handlers>
/// <prometheus>
/// <endpoint>/metric</endpoint>
/// <metrics>true</metrics>
/// <asynchronous_metrics>true</asynchronous_metrics>
/// <events>true</events>
/// <errors>true</errors>
/// </prometheus>
///
/// The "defaults" HTTP handler should serve the prometheus exposing metrics protocol on the http port
/// only if it isn't already served on its own port <prometheus.port>,
/// and also if there is no <prometheus.handlers> section in the configuration
/// (because if that section exists then it must be in charge of how prometheus protocols are handled).
HTTPRequestHandlerFactoryPtr createPrometheusHandlerFactoryForHTTPRuleDefaults(
IServer & server,
const Poco::Util::AbstractConfiguration & config,
const AsynchronousMetrics & asynchronous_metrics);
/// Makes a handler factory to handle prometheus protocols.
/// Supports the "metrics" protocol only.
HTTPRequestHandlerFactoryPtr createKeeperPrometheusHandlerFactory(
IServer & server,
const Poco::Util::AbstractConfiguration & config,
const AsynchronousMetrics & asynchronous_metrics,
const String & name);
}