From 72ba20621dfd3d2a41cfed637e554020b7306aa7 Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Thu, 9 Mar 2023 09:13:20 +0200 Subject: [PATCH 1/4] Fix view names in prometheus example --- examples/prometheus/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/prometheus/main.cc b/examples/prometheus/main.cc index 243e58e723..b8ffa4b4bd 100644 --- a/examples/prometheus/main.cc +++ b/examples/prometheus/main.cc @@ -52,7 +52,7 @@ void InitMetrics(const std::string &name, const std::string &addr) std::unique_ptr meter_selector{ new metrics_sdk::MeterSelector(name, version, schema)}; std::unique_ptr sum_view{ - new metrics_sdk::View{name, "description", metrics_sdk::AggregationType::kSum}}; + new metrics_sdk::View{counter_name, "description", metrics_sdk::AggregationType::kSum}}; p->AddView(std::move(instrument_selector), std::move(meter_selector), std::move(sum_view)); // histogram view @@ -62,7 +62,7 @@ void InitMetrics(const std::string &name, const std::string &addr) std::unique_ptr histogram_meter_selector{ new metrics_sdk::MeterSelector(name, version, schema)}; std::unique_ptr histogram_view{ - new metrics_sdk::View{name, "description", metrics_sdk::AggregationType::kHistogram}}; + new metrics_sdk::View{histogram_name, "description", metrics_sdk::AggregationType::kHistogram}}; p->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), std::move(histogram_view)); metrics_api::Provider::SetMeterProvider(provider); From d5cee3ba976b3b751211825e5828e9fb77f6320d Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Thu, 9 Mar 2023 10:04:08 +0200 Subject: [PATCH 2/4] Fix format --- examples/prometheus/main.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/prometheus/main.cc b/examples/prometheus/main.cc index b8ffa4b4bd..d620c761dd 100644 --- a/examples/prometheus/main.cc +++ b/examples/prometheus/main.cc @@ -61,8 +61,8 @@ void InitMetrics(const std::string &name, const std::string &addr) new metrics_sdk::InstrumentSelector(metrics_sdk::InstrumentType::kHistogram, histogram_name)}; std::unique_ptr histogram_meter_selector{ new metrics_sdk::MeterSelector(name, version, schema)}; - std::unique_ptr histogram_view{ - new metrics_sdk::View{histogram_name, "description", metrics_sdk::AggregationType::kHistogram}}; + std::unique_ptr histogram_view{new metrics_sdk::View{ + histogram_name, "description", metrics_sdk::AggregationType::kHistogram}}; p->AddView(std::move(histogram_instrument_selector), std::move(histogram_meter_selector), std::move(histogram_view)); metrics_api::Provider::SetMeterProvider(provider); From 31f8ce5193c2be87fd0b4d2dd7f91bbd54715647 Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Tue, 14 Mar 2023 12:56:21 +0200 Subject: [PATCH 3/4] Update README --- examples/prometheus/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/prometheus/README.md b/examples/prometheus/README.md index d36228a5b7..315e92f0a2 100644 --- a/examples/prometheus/README.md +++ b/examples/prometheus/README.md @@ -59,7 +59,7 @@ Start the application and keep it running. Now we should be able to see the metrics at [http://localhost:9464/metrics](http://localhost:9464/metrics) from a web browser: -![Browser UI](https://user-images.githubusercontent.com/71217171/168492500-12bd1c99-33ab-4515-a294-17bc349b5d13.png) +![Browser UI](https://user-images.githubusercontent.com/9139451/224979531-beaa4d6e-98ec-4798-9934-ed25c6b196db.png) Now, we understand how we can configure `PrometheusExporter` to export metrics. Next, we are going to learn about how to use Prometheus to collect the metrics. @@ -114,12 +114,12 @@ docker run -p 9090:9090 -v $(pwd):/etc/prometheus --network="host" prom/promethe To use the graphical interface for viewing our metrics with Prometheus, navigate to [http://localhost:9090/graph](http://localhost:9090/graph), -and type `prometheus_metric_example_bucket` in the expression bar of the UI; -finally, click the execute button. +and type `prometheus_metric_example_histogram_bucket` in the expression bar of +the UI; finally, click the execute button. We should be able to see the following chart from the browser: -![Prometheus UI](https://user-images.githubusercontent.com/71217171/168492437-f9769db1-6f9e-49c6-8ef0-85f5e1188ba0.png) +![Prometheus UI](https://user-images.githubusercontent.com/9139451/224979224-e7d3865a-f56e-4bb9-8aab-e3f81de40d6e.png) From the legend, we can see that the `instance` name and the `job` name are the values we have set in `prometheus.yml`. @@ -164,7 +164,7 @@ Feel free to find some handy PromQL [here](https://promlabs.com/promql-cheat-sheet/). ![Grafana -UI](https://user-images.githubusercontent.com/71217171/168492482-047a4429-4854-4b3c-a2dd-4d75362090d5.png) +UI](https://user-images.githubusercontent.com/9139451/224979197-4f11abeb-7856-42b2-9b52-af5fd262c75c.png) ```mermaid graph TD From 19a720a035e14be459c442f8f0f7c8e00e1f26c9 Mon Sep 17 00:00:00 2001 From: Mikhail Khachayants Date: Tue, 14 Mar 2023 13:12:57 +0200 Subject: [PATCH 4/4] Update README --- examples/prometheus/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/prometheus/README.md b/examples/prometheus/README.md index 315e92f0a2..3c75f9690a 100644 --- a/examples/prometheus/README.md +++ b/examples/prometheus/README.md @@ -164,7 +164,7 @@ Feel free to find some handy PromQL [here](https://promlabs.com/promql-cheat-sheet/). ![Grafana -UI](https://user-images.githubusercontent.com/9139451/224979197-4f11abeb-7856-42b2-9b52-af5fd262c75c.png) +UI](https://user-images.githubusercontent.com/9139451/224983906-52e061b8-b561-4414-87e9-68823bbc3ad6.png) ```mermaid graph TD