Skip to content

Commit

Permalink
docs: add docker-compose to run prometheus for the experimental examp…
Browse files Browse the repository at this point in the history
…le (#4268)

Co-authored-by: Marc Pichler <[email protected]>
  • Loading branch information
Lp-Francois and pichlermarc authored Nov 9, 2023
1 parent f2b447d commit 40fde0f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
22 changes: 16 additions & 6 deletions experimental/examples/prometheus/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <http://localhost:9464/metrics>

## 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
Expand All @@ -34,7 +45,6 @@ scrape_configs:
# scheme defaults to 'http'.
static_configs:
- targets: ['localhost:9464']

```
- Start Prometheus
Expand All @@ -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 <http://localhost:9090>

Expand Down
12 changes: 12 additions & 0 deletions experimental/examples/prometheus/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -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
9 changes: 9 additions & 0 deletions experimental/examples/prometheus/prometheus.docker.yml
Original file line number Diff line number Diff line change
@@ -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']

0 comments on commit 40fde0f

Please sign in to comment.