Skip to content

Commit 281b141

Browse files
NleaNele Lea UhlemannNele Lea Uhlemannlaulauland
authored
Add Deploying otel collector + small improvements (#53)
* Include Deployment guide for Otel Collector - Railway (complete) - Northflank (draft) Update ReadMe: include instructions how to run docs locally Add: include the card for northflank to the deploying explorer page * include deployment for otel collector on northflank * Hide Prometheus deployment for local and fly.io * Remove the word "deploying" from side bar * adding links to autometrics-shared deployment resources --------- Co-authored-by: Nele Lea Uhlemann <nlea@Neles-MBP.home> Co-authored-by: Nele Lea Uhlemann <nlea@Neles-MBP.fritz.box> Co-authored-by: Laurynas Keturakis <laurynas.keturakis@gmail.com>
1 parent 162bf08 commit 281b141

14 files changed

Lines changed: 206 additions & 14 deletions

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33
Uses Nextra to generate a static site from markdown files.
44

55
The `_app.jsx` file contains some application setup logic.
6+
7+
## Run the docs locally
8+
- Ensure you have [yarn](https://yarnpkg.com/) installed
9+
- In the repo run `yarn` to install the dependencies
10+
- Run `yarn dev` to spin up the side locally
39.4 KB
Loading
76.2 KB
Loading

src/pages/_meta.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@
3030
"type": "separator",
3131
"title": "Deployment"
3232
},
33-
"deploying-prometheus": "Deploying Prometheus",
34-
"deploying-explorer": "Deploying Explorer",
35-
"deploying-alertmanager": "Deploying Alertmanager",
33+
"deploying-prometheus": "Prometheus",
34+
"deploying-explorer": "Explorer",
35+
"deploying-alertmanager": "Alertmanager",
36+
"deploying-otel-collector": "OTel Collector",
3637
"other": {
3738
"type": "separator",
3839
"title": ""

src/pages/deploying-alertmanager/docker.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Deploying Alertmanager on Docker
2+
title: Alertmanager on Docker
33
short: Docker
44
---
55

src/pages/deploying-explorer.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Cards, Card } from "nextra-theme-docs"
22

3-
# Deploying Explorer
3+
# Explorer
44

55
Explorer is a special Autometrics-specific interface for Prometheus data. It is a simple client-based application that connects to a running Prometheus instance. Once connected it automatically recognizes Autometrics-labeled metrics and visualizes them in a simple and easy to use interface.
66

@@ -12,11 +12,13 @@ See [Local Development](/docs/local-development) for more information.
1212

1313
## Deploying Explorer
1414

15-
The `am` CLI can be run as a simple service app and is available as a Docker image. See guides below for platform-specific instructions.
15+
The `am` CLI can be run as a simple service app and is available as a Docker image. See and guides below for platform-specific instructions.
1616

1717
<Cards num={1}>
1818
<Card
1919
children icon title = "Deploying Explorer with Docker" href="/deploying-explorer/docker"/>
2020
<Card
21+
children icon title = "Deploying Explorer on Northflank" href="/deploying-explorer/northflank"/>
22+
<Card
2123
children icon title = "Deploying Explorer on Railway" href="/deploying-explorer/railway"/>
2224
</Cards>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { Cards, Card } from "nextra-theme-docs"
2+
3+
# OTel Collector
4+
5+
The [OpenTelemetry (OTel) Collector](https://opentelemetry.io/docs/collector/) functions as a vendor-neutral proxy in the OpenTelemetry ecosystem. It efficiently receives, processes, and exports telemetry data, offering versatility in handling various sources, formats, and protocols.
6+
The OTel Collector supports both scraping and pushing of telemetry data, providing flexibility for diverse data collection needs
7+
8+
9+
## Deploying OTel Collector
10+
11+
The OTel Collector is available as a Docker image. See [resources](https://github.com/autometrics-dev/autometrics-shared/tree/main/deployment-guides-resources/otel-collector) and guides below for platform-specific instructions.
12+
13+
<Cards num={1}>
14+
<Card
15+
children icon title = "Deploying OTel Collector on Northflank" href="/deploying-explorer/northflank"/>
16+
<Card
17+
children icon title = "Deploying OTel Collector on Railway" href="/deploying-explorer/railway"/>
18+
</Cards>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"northflank": "Northflank",
3+
"railway": "Railway"
4+
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
title: Deploying OTel Collector on Northflank
3+
short: Northflank
4+
---
5+
import { Steps } from "nextra/components";
6+
7+
# Deploying OTel Collector on Northflank
8+
OTel Collector is available as an official [Docker image](https://hub.docker.com/r/otel/opentelemetry-collector) on Docker Hub. We can use it as a base image and layer in our configuration before deploying it on Railway.
9+
You find the resources for the Deployment [here](https://github.com/autometrics-dev/autometrics-shared/tree/main/deployment-guides-resources/otel-collector).
10+
11+
<Steps>
12+
13+
### Create a GitHub repository and a Otel Collector configuration file
14+
We will use Northflank's ability to deploy from a repository using a [Dockerfile](https://northflank.com/docs/v1/application/build/build-with-a-dockerfile) to set up our Prometheus instance.
15+
16+
Create a file named `otel-collector-config.yaml` to specify a receiver endpoint for sending metrics from the instrumented application.
17+
18+
19+
```yaml {filename="otel-collector-config.yml"} showLineNumbers
20+
receivers:
21+
otlp:
22+
protocols:
23+
http:
24+
endpoint: 0.0.0.0:4318
25+
26+
pipelines:
27+
metrics:
28+
receivers: [otlp]
29+
```
30+
31+
#### Optional: Export metrics
32+
As the OTel Collector acts as a proxy, we can define an exporter to send metrics.
33+
In this example, metrics are pushed to [Prometheus's remote write receiver](https://prometheus.io/docs/prometheus/latest/querying/api/#remote-write-receiver).
34+
Note that while Prometheus advises against this method for efficient sample ingestion, it is chosen here because Autometrics relies on Prometheus for superior querying and visualization capabilities.
35+
36+
```yaml {filename="otel-collector-config.yml"} showLineNumbers
37+
exporters:
38+
prometheusremotewrite:
39+
endpoint: http://prometheus:9090/api/v1/write
40+
resource_to_telemetry_conversion:
41+
enabled: true # Convert resource attributes to
42+
43+
pipelines:
44+
metrics:
45+
exporters: [prometheusremotewrite]
46+
```
47+
You can find an example otel-config.yaml [here](https://github.com/autometrics-dev/autometrics-shared/blob/main/deployment-guides-resources/otel-collector/otel-collector-config.yaml).
48+
49+
### Add a Dockerfile in the root of the repository
50+
The below [Dockerfile](https://github.com/autometrics-dev/autometrics-shared/blob/main/deployment-guides-resources/otel-collector/Dockerfiles) uses the base Otel Collector image and loads our configuration
51+
52+
```Dockerfile
53+
FROM otel/opentelemetry-collector:latest
54+
ADD otel-collector-config.yaml /etc/otelcol/config.yaml
55+
```
56+
57+
### Create a Northflank service from a GitHub repo
58+
Create a Northflank service from our newly created GitHub repo, it should pick up the configuration from the Dockerfile.
59+
60+
### Add Network configurations
61+
In order to make Prometheus accessible to other services in your Northflank network or externally configure the PORT & DNS settings under the service network section in the Northflank UI.
62+
63+
![Northflank Network Settings for Otel Collector](/images/northflank-otel-collector-networking.png)
64+
65+
66+
### Configure application code
67+
Utilize the 'push' capabilities in your chosen Autometrics language library, detailed in each language's quickstart section.
68+
When initializing the OTLP exporter, specify the endpoint for your deployed OTel Collector.
69+
Note that the OTel Collector expects metrics at **/v1/metrics**.
70+
71+
72+
If you have deployed the OTel collector with the port set to 4318 your internal Northflank endpoint should look something like this:
73+
74+
`http://name-of-collector-service:4318/v1/metrics`
75+
76+
</Steps>
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Deploying OTel Collector on Railway
3+
short: Railway
4+
---
5+
import { Steps } from "nextra/components";
6+
7+
# Deploying OTel Collector on Railway
8+
OTel Collector is available as an official [Docker image](https://hub.docker.com/r/otel/opentelemetry-collector) on Docker Hub. We can use it as a base image and layer in our configuration before deploying it on Railway
9+
You find the resources for the Deployment [here](https://github.com/autometrics-dev/autometrics-shared/tree/main/deployment-guides-resources/otel-collector).
10+
11+
<Steps>
12+
13+
### Create a GitHub repository and a Otel Collector configuration file
14+
To set up the OTel Collector instance, utilize Railway's repository deployment and leverage [Dockerfile features](https://docs.railway.app/deploy/dockerfiles).
15+
Create a file named `otel-collector-config.yaml` to specify a receiver endpoint for sending metrics from the instrumented application
16+
17+
```yaml {filename="otel-collector-config.yml"} showLineNumbers
18+
receivers:
19+
otlp:
20+
protocols:
21+
http:
22+
endpoint: 0.0.0.0:4318
23+
24+
pipelines:
25+
metrics:
26+
receivers: [otlp]
27+
```
28+
#### Optional: Export metrics
29+
As the OTel Collector acts as a proxy, we can define an exporter to send metrics.
30+
In this example, metrics are pushed to [Prometheus's remote write receiver](https://prometheus.io/docs/prometheus/latest/querying/api/#remote-write-receiver).
31+
Note that while Prometheus advises against this method for efficient sample ingestion, it is chosen here because Autometrics relies on Prometheus for superior querying and visualization capabilities.
32+
33+
```yaml {filename="otel-collector-config.yml"} showLineNumbers
34+
exporters:
35+
prometheusremotewrite:
36+
endpoint: http://prometheus:9090/api/v1/write
37+
resource_to_telemetry_conversion:
38+
enabled: true # Convert resource attributes to
39+
40+
pipelines:
41+
metrics:
42+
exporters: [prometheusremotewrite]
43+
```
44+
You can find the full otel-config.yaml [here](https://github.com/autometrics-dev/autometrics-shared/blob/main/deployment-guides-resources/otel-collector/otel-collector-config.yaml).
45+
46+
### Add a Dockerfile in the root of the repository
47+
The below [Dockerfile](https://github.com/autometrics-dev/autometrics-shared/blob/main/deployment-guides-resources/otel-collector/Dockerfiles) uses the base Otel Collector image and loads our configuration
48+
49+
```Dockerfile
50+
FROM otel/opentelemetry-collector:latest
51+
52+
ADD otel-collector-config.yaml /etc/otelcol/config.yaml
53+
```
54+
55+
### Create a Railway service from a GitHub repo
56+
Create a Railway service from our newly created GitHub repo, it should pick up the configuration from the Dockerfile.
57+
58+
### Add a PORT environment variable
59+
In order to make the OTel Collector accessible to other services in your Railway project or externally (optional) - you need to tell Railway which port to listen on using the "magic" PORT environment variable.
60+
61+
To add it go to Service > Variables and add just the port number.
62+
![Railway add PORT variable for Otel Collector](/images/railway-otel-collector-port-variable.png)
63+
64+
65+
### Configure application code
66+
Utilize the 'push' capabilities in your chosen Autometrics language library, detailed in each language's quickstart section.
67+
When initializing the OTLP exporter, specify the endpoint for your deployed OTel Collector.
68+
Note that the OTel Collector expects metrics at **/v1/metrics**.
69+
70+
71+
If you have deployed the OTel collector with the port set to 4318 your internal Railway endpoint should look something like this:
72+
73+
`http://name-of-collector-service:4318/v1/metrics`
74+
75+
</Steps>

0 commit comments

Comments
 (0)