-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prometheus endpoint #7900
Prometheus endpoint #7900
Conversation
Initial implementation very basic, and I want to discuss some question. Prometheus support Histogram and Summary metric types. I make changes in HttpHandlerFactory to support different handles (Prometheus one of them). Should New Does test required for new functionality? I think that implementing integration test possible, but we need to decide what exactly we want to check. |
Also I add metric names in snake case following prometheus guidelines. I wrote names directly in source code, because some metrics should contain units suffix (or |
Can it be implemented through a configuration of this #7572 ? |
For now we suggest that only |
The implementation looks very sound.
Better to finish this PR and postpone implementation of derived types of metrics.
AsyncMetrics should be added exactly in the same way as for Graphite - for consistency.
Yes, we need a test. A test will check that the server responds for prometheus handle and the response has some expected value of some metric (not necessarily to check for exact value, just check the presence of some metric and that value is greater than something). |
Yes, this feature along with |
AsynchronousMetrics contain valuable information for monitoring. If we don't add them, then Prometheous support will be inferior than Graphite support. |
@vdimir , your implementation hardcodes metric names and description. It would require to remember adding new metrics in monitoring when something is added in ClickHouse. Outside of ClickHouse implementations (https://github.com/f1yegor/clickhouse_exporter/ or inside https://github.com/Altinity/clickhouse-operator) try to create metrics on the fly from system tables. Could you elaborate why you decided to hardcode, please? |
Yes. One line instead introducing extra param seems much simpler:
Also, both exporters provide results of some extra queries as metrics (so the people migrating from those exporters will have less metrics). Maybe we can consider adding them (or similar) too: |
This should be implemented in a separate PR. The goal of this PR is to add Prometheus handler to provide the same set of metrics that we already support for Graphite. |
I add snake case names because some of them needs to be changed in plural form, or some suffix should be added. (my comment above). I considered automatic conversion to snake case too, but I haven't decide what is better. |
Custom code is fine. I'm just offering another way:
It looks like a good contribution anyway. |
Three points:
|
The following configuration currently work in #7572 config.xml: <predefine_query_handler>
<url>/metrics</url>
<method>GET</method>
<queries>
<query>SELECT * FROM system.metrics LIMIT 5 FORMAT Template SETTINGS format_template_resultset = 'prometheus_template_output_format_resultset', format_template_row = 'prometheus_template_output_format_row', format_template_rows_between_delimiter = '\n'</query>
</queries>
</predefine_query_handler> prometheus_template_output_format_resultset:
prometheus_template_output_format_row:
Result:
|
Can we add |
We have not added it, because they are updated in longer intervals (60 seconds by default) in contrast to other values, that are always up to date and can be written as frequent as needed. |
Can we avoid duplicating metric names in snake_case? |
This reverts commit 2ddb801.
Is it acceptable to keep metric names in CamelCase without any changes? To keep the code more maintenable. |
I have not enough experience with Prometheus to decide which solution more acceptable. But now I reverted names to CamelCase and ready to implement other approach for naming if we'll find it. Other uncompleted part of this task is adding integration test. I have some issue with running it on MacOS, because I couldn't build ClickHouse natively and use docker with Ubuntu. But integration tests require docker itself which is not available because I already in container. I am interested to figure out machinery with integration tests and finish this task, so I hope that I find some solution for it. |
Another reason for keeping the metric names - it will allow use various dashboards without any changes |
About the choice of default port in configuration example, 8001. We should default to some most widely used port for that type of handles or simply reuse http_port. |
|
But works perfectly. |
Common Prometheus port is 9090 (link), I had to use it in
Ok, I'll make response more verbose and send other PR. UPD: I didn't notice that you already change response text. |
Hm, but this is prometheus server, not the exporter (while this is an exporter) P.S. this is just a note, no objections against 9090 port |
Thanks for note, I was wrong. Exporters uses ports starting at 9100.
|
Ok. Waiting for a PR!
I already made it. |
Also there are problems with jemalloc statistics, there is
|
Two suggestions:
|
Hello, this looks cool. Just few comments/questions : so we have a basic /metrics endpoints which answer so hardcoded queries and we can add some predefined_queries in http_handler conf. |
Do you mean same as #10043 ?
Could you explain, what types of labels should be added and how it should be set? |
In prometheus label can be anything. For example :
would result in :
So yep add more custom queries possible for the same htttp route / path (/metrics) and add the possibilities to have more custom output. |
@ut0mt8 Maybe HTTP handler config + template format will help you ? reference: https://clickhouse.tech/docs/en/interfaces/http/#predefined_query_handler https://clickhouse.tech/docs/en/interfaces/formats/#format-template |
I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en
Changelog category (leave one):
Changelog entry:
Detailed description (optional):
ClickHouse serves metrics in Prometheus format on specified endpoint.
Close #7369