From 4a0fedf4b7969ece5e050e49555513927c686641 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20St=C3=A4ber?= Date: Fri, 23 Feb 2024 14:50:27 +0100 Subject: [PATCH] Select ALL $job and $instance in example dashboards MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Fabian Stäber --- docker/Dockerfile | 8 +-- ...grafana-dashboard-red-metrics-classic.json | 67 ++++++++++++------- .../grafana-dashboard-red-metrics-native.json | 65 +++++++++++------- examples/java/run.sh | 4 +- .../com/grafana/example/RollController.java | 4 +- 5 files changed, 89 insertions(+), 59 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index c5a7bdd..309afd2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,10 +1,10 @@ FROM redhat/ubi8 -ENV GRAFANA_VERSION="10.2.3" -ENV PROMETHEUS_VERSION="2.49.1" +ENV GRAFANA_VERSION="10.3.3" +ENV PROMETHEUS_VERSION="2.50.0" ENV TEMPO_VERSION="2.3.1" -ENV LOKI_VERSION="2.9.3" -ENV OPENTELEMETRY_COLLECTOR_VERSION="0.92.0" +ENV LOKI_VERSION="2.9.4" +ENV OPENTELEMETRY_COLLECTOR_VERSION="0.95.0" RUN mkdir /otel-lgtm WORKDIR /otel-lgtm diff --git a/docker/grafana-dashboard-red-metrics-classic.json b/docker/grafana-dashboard-red-metrics-classic.json index 73b8d8d..fd23b55 100644 --- a/docker/grafana-dashboard-red-metrics-classic.json +++ b/docker/grafana-dashboard-red-metrics-classic.json @@ -19,6 +19,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, + "id": 4, "links": [], "liveNow": false, "panels": [ @@ -44,7 +45,7 @@ "content": "# RED Metrics: (r)equest rate, (e)rror rate, (d)uration\n\nThis dashboard uses explicit bucket histograms and the stable [OpenTelemetry metrics semantic conventions](https://opentelemetry.io/docs/specs/semconv/general/metrics/).\nTo enable this for the [OpenTelemetry Java instrumentation agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation/), set the following environment variables:\n\n```\nexport OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=explicit_bucket_histogram\nexport OTEL_SEMCONV_STABILITY_OPT_IN=http\n```", "mode": "markdown" }, - "pluginVersion": "10.2.0", + "pluginVersion": "10.3.3", "type": "text" }, { @@ -104,7 +105,8 @@ } ] }, - "unit": "reqps" + "unit": "reqps", + "unitScale": true }, "overrides": [] }, @@ -134,7 +136,7 @@ "uid": "prometheus" }, "editorMode": "code", - "expr": "sum(rate({__name__=~\"http_server_request_duration_seconds_count|http_server_request_duration_count|http_server_duration_milliseconds_count|http_server_duration_seconds_count|http_server_duration_count\", job=\"$job\", instance=\"$instance\"}[5m]))", + "expr": "sum(rate({__name__=~\"http_server_request_duration_seconds_count|http_server_request_duration_count|http_server_duration_milliseconds_count|http_server_duration_seconds_count|http_server_duration_count\", job=~\"$job\", instance=~\"$instance\"}[5m]))", "legendFormat": "__auto", "range": true, "refId": "A" @@ -200,7 +202,8 @@ } ] }, - "unit": "percentunit" + "unit": "percentunit", + "unitScale": true }, "overrides": [] }, @@ -230,7 +233,7 @@ "uid": "prometheus" }, "editorMode": "code", - "expr": "sum(rate({__name__=~\"http_server_request_duration_seconds_count|http_server_request_duration_count|http_server_duration_milliseconds_count|http_server_duration_seconds_count|http_server_duration_count\", job=\"$job\", instance=\"$instance\", http_response_status_code=~\"5..\"}[5m])) / sum(rate({__name__=~\"http_server_request_duration_seconds_count|http_server_request_duration_count|http_server_duration_milliseconds_count|http_server_duration_seconds_count|http_server_duration_count\", job=\"$job\", instance=\"$instance\"}[5m]))", + "expr": "sum(rate({__name__=~\"http_server_request_duration_seconds_count|http_server_request_duration_count|http_server_duration_milliseconds_count|http_server_duration_seconds_count|http_server_duration_count\", job=~\"$job\", instance=~\"$instance\", http_response_status_code=~\"5..\"}[5m])) / sum(rate({__name__=~\"http_server_request_duration_seconds_count|http_server_request_duration_count|http_server_duration_milliseconds_count|http_server_duration_seconds_count|http_server_duration_count\", job=~\"$job\", instance=~\"$instance\"}[5m]))", "legendFormat": "__auto", "range": true, "refId": "A" @@ -264,7 +267,8 @@ } ] }, - "unit": "reqps" + "unit": "reqps", + "unitScale": true }, "overrides": [] }, @@ -277,6 +281,7 @@ "id": 3, "options": { "displayMode": "gradient", + "maxVizHeight": 300, "minVizHeight": 10, "minVizWidth": 0, "namePlacement": "auto", @@ -289,9 +294,10 @@ "values": false }, "showUnfilled": true, + "sizing": "auto", "valueMode": "color" }, - "pluginVersion": "10.2.0", + "pluginVersion": "10.3.3", "targets": [ { "datasource": { @@ -300,7 +306,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=\"$job\", instance=\"$instance\"}[5m]))", + "expr": "sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=~\"$job\", instance=~\"$instance\"}[5m]))", "format": "heatmap", "instant": false, "legendFormat": "{{le}}", @@ -381,7 +387,7 @@ }, "editorMode": "code", "exemplar": false, - "expr": "sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=\"$job\", instance=\"$instance\"}[5m]))", + "expr": "sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=~\"$job\", instance=~\"$instance\"}[5m]))", "format": "heatmap", "instant": false, "range": true, @@ -439,8 +445,7 @@ "mode": "absolute", "steps": [ { - "color": "green", - "value": null + "color": "green" }, { "color": "red", @@ -480,7 +485,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "histogram_quantile(0.95, sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=\"$job\", instance=\"$instance\"}[5m])))", + "expr": "histogram_quantile(0.95, sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=~\"$job\", instance=~\"$instance\"}[5m])))", "format": "time_series", "instant": false, "legendFormat": "95th", @@ -494,7 +499,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "histogram_quantile(0.5, sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=\"$job\", instance=\"$instance\"}[5m])))", + "expr": "histogram_quantile(0.5, sum by (le) (rate({__name__=~\"http_server_request_duration_seconds_bucket|http_server_request_duration_bucket|http_server_duration_milliseconds_bucket|http_server_duration_seconds_bucket|http_server_duration_bucket\", job=~\"$job\", instance=~\"$instance\"}[5m])))", "hide": false, "legendFormat": "50th", "range": true, @@ -506,15 +511,20 @@ } ], "refresh": "", - "schemaVersion": 38, + "schemaVersion": 39, "tags": [], "templating": { "list": [ { + "allValue": ".+", "current": { - "selected": false, - "text": "greeting-service", - "value": "greeting-service" + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] }, "datasource": { "type": "prometheus", @@ -522,9 +532,9 @@ }, "definition": "label_values(job)", "hide": 0, - "includeAll": false, + "includeAll": true, "label": "", - "multi": false, + "multi": true, "name": "job", "options": [], "query": { @@ -538,24 +548,29 @@ "type": "query" }, { + "allValue": ".+", "current": { - "selected": false, - "text": "2aa84f09-7278-4972-9dc4-5248bcab0306", - "value": "2aa84f09-7278-4972-9dc4-5248bcab0306" + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] }, "datasource": { "type": "prometheus", "uid": "prometheus" }, - "definition": "label_values({job=\"$job\"},instance)", + "definition": "label_values({job=~\"$job\"},instance)", "hide": 0, - "includeAll": false, + "includeAll": true, "label": "instance", - "multi": false, + "multi": true, "name": "instance", "options": [], "query": { - "query": "label_values({job=\"$job\"},instance)", + "query": "label_values({job=~\"$job\"},instance)", "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 1, diff --git a/docker/grafana-dashboard-red-metrics-native.json b/docker/grafana-dashboard-red-metrics-native.json index 5f64a77..5578e4c 100644 --- a/docker/grafana-dashboard-red-metrics-native.json +++ b/docker/grafana-dashboard-red-metrics-native.json @@ -44,7 +44,7 @@ "content": "# RED Metrics: (r)equest rate, (e)rror rate, (d)uration\n\nThis dashboard uses exponential histograms and the stable [OpenTelemetry metrics semantic conventions](https://opentelemetry.io/docs/specs/semconv/general/metrics/).\nTo enable this for the [OpenTelemetry Java instrumentation agent](https://github.com/open-telemetry/opentelemetry-java-instrumentation/), set the following environment variables:\n\n```\nexport OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=base2_exponential_bucket_histogram\nexport OTEL_SEMCONV_STABILITY_OPT_IN=http\n```", "mode": "markdown" }, - "pluginVersion": "10.2.0", + "pluginVersion": "10.3.3", "type": "text" }, { @@ -104,7 +104,8 @@ } ] }, - "unit": "reqps" + "unit": "reqps", + "unitScale": true }, "overrides": [] }, @@ -134,7 +135,7 @@ "uid": "prometheus" }, "editorMode": "code", - "expr": "sum(histogram_count(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\", job=\"$job\", instance=\"$instance\"}[5m])))", + "expr": "sum(histogram_count(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\", job=~\"$job\", instance=~\"$instance\"}[5m])))", "legendFormat": "__auto", "range": true, "refId": "A" @@ -200,7 +201,8 @@ } ] }, - "unit": "percentunit" + "unit": "percentunit", + "unitScale": true }, "overrides": [] }, @@ -230,7 +232,7 @@ "uid": "prometheus" }, "editorMode": "code", - "expr": "sum(histogram_count(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\", job=\"$job\", instance=\"$instance\", http_response_status_code=~\"5..\"}[5m]))) / sum(histogram_count(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\", job=\"$job\", instance=\"$instance\"}[5m])))\n\n", + "expr": "sum(histogram_count(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\", job=~\"$job\", instance=~\"$instance\", http_response_status_code=~\"5..\"}[5m]))) / sum(histogram_count(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\", job=~\"$job\", instance=~\"$instance\"}[5m])))\n\n", "legendFormat": "__auto", "range": true, "refId": "A" @@ -255,7 +257,8 @@ "scaleDistribution": { "type": "linear" } - } + }, + "unitScale": true }, "overrides": [] }, @@ -291,7 +294,8 @@ "layout": "auto" }, "tooltip": { - "show": true, + "mode": "single", + "showColorScale": false, "yHistogram": false }, "yAxis": { @@ -300,7 +304,7 @@ "unit": "s" } }, - "pluginVersion": "10.2.0", + "pluginVersion": "10.3.3", "targets": [ { "datasource": { @@ -309,7 +313,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "sum(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\",job=\"$job\", instance=\"$instance\"}[5m]))", + "expr": "sum(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\",job=~\"$job\", instance=~\"$instance\"}[5m]))", "format": "time_series", "instant": false, "range": true, @@ -376,7 +380,8 @@ } ] }, - "unit": "s" + "unit": "s", + "unitScale": true }, "overrides": [] }, @@ -408,7 +413,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "histogram_quantile(0.95, sum(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\",job=\"$job\", instance=\"$instance\"}[5m])))", + "expr": "histogram_quantile(0.95, sum(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\",job=~\"$job\", instance=~\"$instance\"}[5m])))", "format": "time_series", "instant": false, "legendFormat": "95th", @@ -422,7 +427,7 @@ }, "editorMode": "code", "exemplar": true, - "expr": "histogram_quantile(0.5, sum(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\",job=\"$job\", instance=\"$instance\"}[5m])))", + "expr": "histogram_quantile(0.5, sum(rate({__name__=~\"http_server_request_duration_seconds|http_server_request_duration|http_server_duration_milliseconds|http_server_duration_seconds|http_server_duration\",job=~\"$job\", instance=~\"$instance\"}[5m])))", "hide": false, "legendFormat": "50th", "range": true, @@ -434,15 +439,20 @@ } ], "refresh": "", - "schemaVersion": 38, + "schemaVersion": 39, "tags": [], "templating": { "list": [ { + "allValue": ".+", "current": { - "selected": false, - "text": "hello-world-app", - "value": "hello-world-app" + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] }, "datasource": { "type": "prometheus", @@ -450,9 +460,9 @@ }, "definition": "label_values(job)", "hide": 0, - "includeAll": false, + "includeAll": true, "label": "", - "multi": false, + "multi": true, "name": "job", "options": [], "query": { @@ -466,24 +476,29 @@ "type": "query" }, { + "allValue": ".+", "current": { - "selected": false, - "text": "ae8f5726-99a0-401b-b70b-34ceabe2c0ba", - "value": "ae8f5726-99a0-401b-b70b-34ceabe2c0ba" + "selected": true, + "text": [ + "All" + ], + "value": [ + "$__all" + ] }, "datasource": { "type": "prometheus", "uid": "prometheus" }, - "definition": "label_values({job=\"$job\"},instance)", + "definition": "label_values({job=~\"$job\"},instance)", "hide": 0, - "includeAll": false, + "includeAll": true, "label": "instance", - "multi": false, + "multi": true, "name": "instance", "options": [], "query": { - "query": "label_values({job=\"$job\"},instance)", + "query": "label_values({job=~\"$job\"},instance)", "refId": "PrometheusVariableQueryEditor-VariableQuery" }, "refresh": 1, diff --git a/examples/java/run.sh b/examples/java/run.sh index 77caf57..e235ab1 100755 --- a/examples/java/run.sh +++ b/examples/java/run.sh @@ -5,10 +5,12 @@ set -euo pipefail if [[ ! -f ./target/rolldice.jar ]] ; then ./mvnw clean package fi -version=v2.0.0 +version=v2.1.0 jar=opentelemetry-javaagent-${version}.jar if [[ ! -f ./${jar} ]] ; then curl -sL https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.0.0/opentelemetry-javaagent.jar -o ${jar} fi export OTEL_RESOURCE_ATTRIBUTES="service.name=rolldice,service.instance.id=localhost:8080" +# uncomment the next line to switch to Prometheus native histograms. +# export OTEL_EXPORTER_OTLP_METRICS_DEFAULT_HISTOGRAM_AGGREGATION=base2_exponential_bucket_histogram java -Dotel.metric.export.interval=500 -Dotel.bsp.schedule.delay=500 -javaagent:${jar} -jar ./target/rolldice.jar diff --git a/examples/java/src/main/java/com/grafana/example/RollController.java b/examples/java/src/main/java/com/grafana/example/RollController.java index 4dc3f20..37724a8 100644 --- a/examples/java/src/main/java/com/grafana/example/RollController.java +++ b/examples/java/src/main/java/com/grafana/example/RollController.java @@ -1,5 +1,6 @@ package com.grafana.example; +import java.util.Optional; import java.util.Random; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,9 +8,6 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import java.util.Optional; -import java.util.concurrent.ThreadLocalRandom; - @RestController public class RollController {