Skip to content

Commit 94afb53

Browse files
authored
Add docs for open telemetry collector (#6429)
Signed-off-by: SungJin1212 <[email protected]>
1 parent 93d2ed0 commit 94afb53

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
title: "OpenTelemetry Collector"
3+
linkTitle: "OpenTelemetry Collector"
4+
weight: 10
5+
slug: opentelemetry-collector
6+
---
7+
8+
This guide explains how to configure open-telemetry collector and OTLP(OpenTelemetry Protocol) configurations in the
9+
Cortex.
10+
11+
## Context
12+
13+
The [open-telemetry collector](https://opentelemetry.io/docs/collector/) can write collected metrics to the Cortex with
14+
the Prometheus and OTLP formats.
15+
16+
## Push with Prometheus format
17+
18+
To push metrics via the `Prometheus` format, we can
19+
use [prometheusremotewrite](https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/exporter/prometheusremotewriteexporter)
20+
exporter in the open-telemetry collector.
21+
In the `exporters` and `service` sections in the open-telemetry collector yaml file, we can add as follows:
22+
23+
```
24+
exporters:
25+
prometheusremotewrite:
26+
endpoint: http://<cortex-endpoint>/api/v1/push
27+
headers:
28+
X-Scope-OrgId: <orgId>
29+
30+
...
31+
32+
service:
33+
pipelines:
34+
metrics:
35+
receivers: [...]
36+
processors: [...]
37+
exporters: [prometheusremotewrite]
38+
```
39+
40+
Please refer to [Authentication and Authorisation](./authentication-and-authorisation.md) section for the
41+
`X-Scope-OrgId` explanation.
42+
43+
## Push with OTLP format
44+
45+
To push metrics via the `OTLP` format, we can
46+
use [otlphttp](https://github.com/open-telemetry/opentelemetry-collector/tree/main/exporter/otlphttpexporter) exporter
47+
in the open-telemetry collector.
48+
In the `exporters` and `service` sections in the open-telemetry collector yaml file, we can add as follows:
49+
50+
```
51+
exporters:
52+
otlphttp:
53+
endpoint: http://<cortex-endpoint>/api/v1/otlp
54+
headers:
55+
X-Scope-OrgId: <orgId>
56+
57+
...
58+
59+
service:
60+
pipelines:
61+
metrics:
62+
receivers: [...]
63+
processors: [...]
64+
exporters: [otlphttp]
65+
```
66+
67+
## Configure OTLP
68+
69+
### target_info metric
70+
71+
By default,
72+
the [target_info](https://github.com/prometheus/OpenMetrics/blob/main/specification/OpenMetrics.md#supporting-target-metadata-in-both-push-based-and-pull-based-systems)
73+
is enabled to write and can be disabled via `-distributor.otlp.disable-target-info=true`.
74+
75+
### Resource attributes conversion
76+
77+
The conversion of
78+
all [resource attributes](https://opentelemetry.io/docs/specs/semconv/resource/) to labels is
79+
disabled by default and can be enabled via
80+
`-distributor.otlp.convert-all-attributes=true`.
81+
82+
You can specify the attributes converted to labels via `-distributor.promote-resource-attributes` flag. It is supported
83+
only if `-distributor.otlp.convert-all-attributes=false`.
84+
85+
These flags can be configured via yaml:
86+
87+
```
88+
limits:
89+
promote_resource_attributes: <list of string>
90+
...
91+
distributor:
92+
otlp:
93+
convert_all_attributes: <boolean>
94+
disable_target_info: <boolean>
95+
```
96+
97+
These are the yaml examples:
98+
99+
- Example 1: All of the resource attributes are converted, and the `target_info` metric is disabled to push.
100+
101+
```
102+
distributor:
103+
otlp:
104+
convert_all_attributes: true
105+
disable_target_info: true
106+
```
107+
108+
- Example 2: Only `service.name` and `service.instance.id` resource attributes are converted to labels and the
109+
`target_info` metric is enabled to push.
110+
111+
```
112+
limits:
113+
promote_resource_attributes: ["service.name", "service.instance.id"]
114+
distributor:
115+
otlp:
116+
convert_all_attributes: false
117+
disable_target_info: false
118+
```
119+
120+
### Configure promote resource attributes per tenants
121+
122+
The `promote_resource_attributes` is a [runtime config](./overrides-exporter.md) so you can configure it per tenant.
123+
124+
For example, this yaml file specifies `attr1` being converted to label in both `user-1` and `user-2`. But, the `attr2`
125+
is converted only for `user-2`.
126+
127+
```
128+
overrides:
129+
user-1:
130+
promote_resource_attributes: ["attr1"]
131+
user-2:
132+
promote_resource_attributes: ["attr1", "attr2"]
133+
`
134+
```

0 commit comments

Comments
 (0)