Skip to content

Commit

Permalink
Add local prometheus
Browse files Browse the repository at this point in the history
Signed-off-by: Pavol Loffay <p.loffay@gmail.com>
  • Loading branch information
pavolloffay committed Oct 31, 2023
1 parent 1c95c7f commit cf24119
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
17 changes: 11 additions & 6 deletions 03-app-instrumentation.md
Expand Up @@ -64,12 +64,7 @@ language-specific APIs and SDKs.
In this tutorial we will only instrument the [frontend](./app/frontend) service manually, we will use
automatic instrumentation for the other services in the next step.

Before continuing make sure you can run OpenTelemetry collector locally:
```bash
docker run --rm -it -p 4317:4317 --name=otel-collector -v ./app:/tmp ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:0.88.0 --config /tmp/collector-docker.yaml
```

For development you can run the app locally by installing all dependencies
For development, you can run the app locally by installing all dependencies
and running it with `nodemon` from the [./app/frontend](./app/frontend/) directory:

```bash
Expand Down Expand Up @@ -126,6 +121,16 @@ If all works, the frontend application should emit metrics and print them to the
Now replace the `ConsoleSpanExporter` with an `OTLPTraceExporter` as outlined in the [Exporters](https://opentelemetry.io/docs/instrumentation/js/exporters/) documentation (make use of `opentelemetry/exporter-metrics-otlp-grpc` & `opentelemetry/exporter-trace-otlp-grpc`)
The metrics can be reported to the Prometheus server running locally:
```bash
docker run --rm -it -p 9090:9090 -p 4317:4317 --name=p8s -v ./app/prometheus-docker.yaml:/tmp/prometheus-docker.yaml prom/prometheus --config.file=/tmp/prometheus-docker.yaml --enable-feature=otlp-write-receiver
```
Alternatively, you can run the OpenTelemetry collector locally with debug exporter:
```bash
docker run --rm -it -p 4317:4317 --name=otel-collector -v ./app/collector-docker.yaml:/tmp/collector-docker.yaml ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector:0.88.0 --config /tmp/collector-docker.yaml
```
Finally, look into the `index.js` file once again, there are a few additional `TODOs` for you!
### Exemplars
Expand Down
15 changes: 15 additions & 0 deletions app/prometheus-docker.yaml
@@ -0,0 +1,15 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
alerting:
alertmanagers:
- static_configs:
- targets:
# - alertmanager:9093
rule_files:
# - "first_rules.yml"
# - "second_rules.yml"
scrape_configs:
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]

0 comments on commit cf24119

Please sign in to comment.