Skip to content

Prometheus exporter without external dependencies, exporting histograms directly#921

Closed
SystemsPurge wants to merge 8 commits into
VILLASframework:masterfrom
SystemsPurge:no-extern-deps
Closed

Prometheus exporter without external dependencies, exporting histograms directly#921
SystemsPurge wants to merge 8 commits into
VILLASframework:masterfrom
SystemsPurge:no-extern-deps

Conversation

@SystemsPurge
Copy link
Copy Markdown
Contributor

It's not clear to me where i can find the values associated with the buckets of the histograms

Copy link
Copy Markdown
Contributor

@stv0g stv0g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused?

Comment on lines +11 to 13
#include<string>
#include <jansson.h>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread common/include/villas/hist.hpp Outdated
// 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Comment thread common/lib/hist.cpp Outdated

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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//need this because prometheus understands quantiles
// Needed because Prometheus understands quantiles.

Comment thread common/lib/hist.cpp Outdated
}
}

std::string Hist::promFormat(std::string metric_name, std::string node_name) const{
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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{

Comment thread lib/api/requests/metrics.cpp Outdated
throw InvalidMethod(this);

if (body != nullptr)
throw BadRequest("Nodes endpoint does not accept any body data");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw BadRequest("Nodes endpoint does not accept any body data");
throw BadRequest("The metrics endpoint does not accept any body data");

Comment thread lib/api/requests/metrics.cpp Outdated
// Register API request
static char n[] = "metrics";
static char r[] = "/metrics";
static char d[] = "Get stats of all nodes in desired format";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static char d[] = "Get stats of all nodes in desired format";
static char d[] = "Get stats of all nodes in Prometheus metrics format";

Comment thread lib/api/requests/metrics.cpp Outdated
if (body != nullptr)
throw BadRequest("Nodes endpoint does not accept any body data");

std::string text_res = "";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use an std::stringstream.

@@ -0,0 +1,68 @@
/* The "nodes" API ressource.
*
* Author: Steffen Vogel <post@steffenvogel.de>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put your name here :)

Comment thread lib/api/requests/metrics.cpp Outdated

class MetricsRequest : public Request {
private:
std::unordered_map<Stats::Metric,std::string> metrics_subset = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering: is the a reasoning behind only exporting a subset of statistics?

@stv0g
Copy link
Copy Markdown
Contributor

stv0g commented Jun 12, 2025

@SystemsPurge I noticed this PR is against the add-prometheus-exporter branch. Is this intended? There seems to be a merge conflict.

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>
@SystemsPurge SystemsPurge requested a review from windrad6 as a code owner June 16, 2025 09:38
@SystemsPurge
Copy link
Copy Markdown
Contributor Author

@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

@stv0g stv0g changed the base branch from add-prometheus-exporter to master June 17, 2025 08:57
@stv0g
Copy link
Copy Markdown
Contributor

stv0g commented Jun 17, 2025

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.

@SystemsPurge
Copy link
Copy Markdown
Contributor Author

@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 ?

@stv0g
Copy link
Copy Markdown
Contributor

stv0g commented Jun 24, 2025

Closing in favour of #932

@stv0g stv0g closed this Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants