Prometheus exporter without external dependencies, exporting histograms directly#921
Prometheus exporter without external dependencies, exporting histograms directly#921SystemsPurge wants to merge 8 commits into
Conversation
stv0g
left a comment
There was a problem hiding this comment.
Looks good to me so far. I only have some minor comments.
Please also rebase your changes to the last master commit.
Also run clang-format on your changes, as code-formatting is now checked by the CI (you can also use pre-commit locally).
| // Print ASCII style plot of histogram. | ||
| void plot(Logger logger) const; | ||
|
|
||
| void test(); |
| #include<string> | ||
| #include <jansson.h> |
There was a problem hiding this comment.
| #include<string> | |
| #include <jansson.h> | |
| #include<string> | |
| #include <jansson.h> |
We usually try to group headers into these sections separated by an empty line
- libstdc++
- libc
- third-party
- VILLASnode
There was a problem hiding this comment.
You are also missing a space after in include<string>.
@stv0g this grouping is not part of the contributor guidelines, so you shouldn't enforce it :)
There was a problem hiding this comment.
Okay, Its also something which we will fix repo-wide with the new clang-tidy fixes Philipp is working on..
I did not mention the missing space, as it will be fixed by clang-format.
| // Write the histogram in JSON format to file \p f. | ||
| int dumpJson(FILE *f) const; | ||
|
|
||
| std::string promFormat(std::string metric_name, std::string node_name) const; |
There was a problem hiding this comment.
| std::string promFormat(std::string metric_name, std::string node_name) const; | |
| std::string toPrometheusText(std::string metric_name, std::string node_name) const; |
To be in-line with toJson and also be prepared for possible binary Promtheus format.
|
|
||
| std::string Hist::promFormat(std::string metric_name, std::string node_name) const{ | ||
| std::string base = "#TYPE HISTOGRAM "+metric_name; | ||
| //need this because prometheus understands quantiles |
There was a problem hiding this comment.
| //need this because prometheus understands quantiles | |
| // Needed because Prometheus understands quantiles. |
| } | ||
| } | ||
|
|
||
| std::string Hist::promFormat(std::string metric_name, std::string node_name) const{ |
There was a problem hiding this comment.
| std::string Hist::promFormat(std::string metric_name, std::string node_name) const{ | |
| std::string Hist::toPrometheusText(std::string metric_name, std::string node_name) const{ |
| throw InvalidMethod(this); | ||
|
|
||
| if (body != nullptr) | ||
| throw BadRequest("Nodes endpoint does not accept any body data"); |
There was a problem hiding this comment.
| throw BadRequest("Nodes endpoint does not accept any body data"); | |
| throw BadRequest("The metrics endpoint does not accept any body data"); |
| // Register API request | ||
| static char n[] = "metrics"; | ||
| static char r[] = "/metrics"; | ||
| static char d[] = "Get stats of all nodes in desired format"; |
There was a problem hiding this comment.
| static char d[] = "Get stats of all nodes in desired format"; | |
| static char d[] = "Get stats of all nodes in Prometheus metrics format"; |
| if (body != nullptr) | ||
| throw BadRequest("Nodes endpoint does not accept any body data"); | ||
|
|
||
| std::string text_res = ""; |
There was a problem hiding this comment.
Please use an std::stringstream.
| @@ -0,0 +1,68 @@ | |||
| /* The "nodes" API ressource. | |||
| * | |||
| * Author: Steffen Vogel <post@steffenvogel.de> | |||
There was a problem hiding this comment.
Please put your name here :)
|
|
||
| class MetricsRequest : public Request { | ||
| private: | ||
| std::unordered_map<Stats::Metric,std::string> metrics_subset = { |
There was a problem hiding this comment.
I am wondering: is the a reasoning behind only exporting a subset of statistics?
|
@SystemsPurge I noticed this PR is against the |
Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
…an bucket values Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
…nction name and remove useless code. Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
…an bucket values Signed-off-by: SystemsPurge <naktiyoussef@proton.me>
|
@stv0g i just was not sure i wanted to push to this branch directly, but you are welcome to change the target branch of PR |
|
Hi @SystemsPurge, I've adjusted the base branch of this PR. If you dont mind, I would do some simple cleanups and make the Git history pretty before merging it. I will for sure maintain you as the authors of the changes. |
|
@stv0g Do whatever you deem fit. I don't even really care about the crediting but thank you insisting. Do you have write access to the branch or do i have to give it explicitely ? |
|
Closing in favour of #932 |
It's not clear to me where i can find the values associated with the buckets of the histograms