diff --git a/experimental/examples/prometheus/README.md b/experimental/examples/prometheus/README.md index 53ec356b61..398427baec 100644 --- a/experimental/examples/prometheus/README.md +++ b/experimental/examples/prometheus/README.md @@ -11,17 +11,28 @@ This is a simple example that demonstrates basic metrics collection and exports npm install ``` -Setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/) - ## Run the Application -- Run the server - ```sh # from this directory npm run start ``` +If you are using the default configurations, the metrics should be available at + +## Run Prometheus + +### With docker + +```sh +# from this directory +docker compose up +``` + +### With binary + +Setup [Prometheus](https://prometheus.io/docs/prometheus/latest/getting_started/) + - Replace the `prometheus.yml` provided by the Prometheus installation with the following: ```yaml @@ -34,7 +45,6 @@ scrape_configs: # scheme defaults to 'http'. static_configs: - targets: ['localhost:9464'] - ``` - Start Prometheus @@ -44,7 +54,7 @@ scrape_configs: prometheus --config.file=prometheus.yml ``` -### Prometheus UI +## Prometheus UI If you are using the default configurations, the prometheus client will be available at diff --git a/experimental/examples/prometheus/docker-compose.yaml b/experimental/examples/prometheus/docker-compose.yaml new file mode 100644 index 0000000000..5647d893f9 --- /dev/null +++ b/experimental/examples/prometheus/docker-compose.yaml @@ -0,0 +1,12 @@ +version: '3.7' + +services: + prometheus: + image: prom/prometheus:v2.47.2 + extra_hosts: + - host.docker.internal:host-gateway + volumes: + - "./prometheus.docker.yml:/etc/prometheus/prometheus.yml" + ports: + - 9090:9090 + restart: always diff --git a/experimental/examples/prometheus/prometheus.docker.yml b/experimental/examples/prometheus/prometheus.docker.yml new file mode 100644 index 0000000000..2fb8007583 --- /dev/null +++ b/experimental/examples/prometheus/prometheus.docker.yml @@ -0,0 +1,9 @@ +global: + scrape_interval: 15s # Default is every 1 minute. + +scrape_configs: + - job_name: 'opentelemetry' + # metrics_path defaults to '/metrics' + # scheme defaults to 'http'. + static_configs: + - targets: ['host.docker.internal:9464']