opentelemetry-java/examples/prometheus
John Watson 2ac3ff6e83
Convert the examples to not use the GlobalOpenTelemetry instance. (#2364)
* update the grpc example to remove global usage

* update the http example to remove global usage

* update the jaeger example to get rid of the global usage

* update the metrics example to get rid of the global OpenTelemetry usage

* update the otlp exporter example to get rid of the global OpenTelemetry usage

* update the sdk-usage example to get rid of the global OpenTelemetry usage

* update the zipkin example to get rid of the global OpenTelemetry usage

* run the formatter

* update method names and details based on feedback
2020-12-18 16:21:51 -08:00
..
src/main/java/io/opentelemetry/example/prometheus Convert the examples to not use the GlobalOpenTelemetry instance. (#2364) 2020-12-18 16:21:51 -08:00
README.md Rename all packages to follow the module name definition (#1952) 2020-10-31 10:59:11 -07:00
build.gradle Update the examples for v0.10.0 (#2030) 2020-11-05 16:32:58 -08:00
prometheus.yml 1503 prometheus example (#1541) 2020-08-17 14:17:05 -07:00

README.md

Prometheus Example

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 are collected by a Prometheus instance which is configured to pull these metrics via HTTP.

How to run

Prerequisites

  • Java 1.7
  • Docker 19.03

1 - Compile

../gradlew fatJar

2 - Run Prometheus

Start Prometheus instance with a configuration that sets up a HTTP collection job for 127.0.0.1:19090

See prometheus.yml

docker run --network="host" --rm -it \
    --name prometheus \
    -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml \
    prom/prometheus 

3 - Start the Application

java -cp build/libs/opentelemetry-examples-prometheus-all-0.1.0-SNAPSHOT.jar io.opentelemetry.example.prometheus.PrometheusExample 19090

4 - Open the Prometheus UI

Navigate to:

http://localhost:9090/graph?g0.range_input=15m&g0.expr=incoming_messages&g0.tab=0