This example demonstrates how to use the OpenTelemetry SDK to instrument a simple application using Prometheus as the metric exporter and expose the metrics via HTTP.
These metrics are collected by a Prometheus instance which is configured to scrape metrics via HTTP.
- Java 17 or higher is required to run Gradle and build this example
- Java 8 or higher may be used to run the example once it has been built
- Docker 19.03
- Docker Compose
../gradlew shadowJarStart the application and Prometheus via Docker Compose:
docker compose upTo view metrics in Prometheus (e.g. 90th percentile), navigate to:
To fetch application metrics in prometheus format, run:
curl localhost:19090/metricsTo fetch application metrics in OpenMetrics format, which includes exemplars, run:
curl -H 'Accept: application/openmetrics-text; version=1.0.0; charset=utf-8' localhost:19090/metrics