|
1 | 1 | ## Prometheus |
2 | 2 |
|
3 | | -To send your metric data to [Prometheus](https://prometheus.io/), you can either |
4 | | -[enable Prometheus' OTLP Receiver](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver) |
5 | | -and use the [OTLP exporter](#otlp) or you can use the Prometheus exporter, a |
6 | | -`MetricReader` that starts an HTTP server that collects metrics and serialize to |
7 | | -Prometheus text format on request. |
| 3 | +To send your metric data to [Prometheus](https://prometheus.io/), you can |
| 4 | +either: |
8 | 5 |
|
9 | | -### Backend Setup {#prometheus-setup} |
| 6 | +- [Enable Prometheus' OTLP Receiver](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver) |
| 7 | + and use the [OTLP exporter](#otlp) (best practice), or |
| 8 | +- Use the Prometheus exporter, a `MetricReader` that starts an HTTP server that |
| 9 | + collects metrics and serializes to Prometheus text format on request. |
10 | 10 |
|
11 | | -> [!NOTE] |
12 | | -> |
13 | | -> If you have Prometheus or a Prometheus-compatible backend already set up, you |
14 | | -> can skip this section and setup the [Prometheus](#prometheus-dependencies) or |
15 | | -> [OTLP](#otlp-dependencies) exporter dependencies for your application. |
| 11 | +### Backend setup {#prometheus-setup} |
16 | 12 |
|
17 | | -You can run [Prometheus](https://prometheus.io) in a docker container, |
18 | | -accessible on port `9090` by following these instructions: |
| 13 | +To run a Prometheus server backend and begin scraping metrics, see the |
| 14 | +[Prometheus getting started guide](https://prometheus.io/docs/prometheus/latest/getting_started/). |
19 | 15 |
|
20 | | -Create a file called `prometheus.yml` with the following content: |
21 | | - |
22 | | -```yaml |
23 | | -scrape_configs: |
24 | | - - job_name: dice-service |
25 | | - scrape_interval: 5s |
26 | | - static_configs: |
27 | | - - targets: [host.docker.internal:9464] |
28 | | -``` |
29 | | -
|
30 | | -Run Prometheus in a docker container with the UI accessible on port `9090`: |
31 | | - |
32 | | -```shell |
33 | | -docker run --rm -v ${PWD}/prometheus.yml:/prometheus/prometheus.yml -p 9090:9090 prom/prometheus --web.enable-otlp-receiver |
34 | | -``` |
35 | | - |
36 | | -> [!NOTE] |
37 | | -> |
38 | | -> When using Prometheus' OTLP Receiver, make sure that you set the OTLP endpoint |
39 | | -> for metrics in your application to `http://localhost:9090/api/v1/otlp`. |
40 | | -> |
41 | | -> Not all docker environments support `host.docker.internal`. In some cases you |
42 | | -> may need to replace `host.docker.internal` with `localhost` or the IP address |
43 | | -> of your machine. |
| 16 | +To enable the OTLP Receiver, see the |
| 17 | +[Prometheus guide for enabling the OTLP Receiver](https://prometheus.io/docs/guides/opentelemetry/#enable-the-otlp-receiver). |
0 commit comments