Skip to content

Commit 88780b8

Browse files
wire in the otel converter and create a migration guide (#6790)
* wire in the otel converter and create a migration guide Signed-off-by: erikbaranowski <[email protected]> * Apply suggestions from code review Co-authored-by: Clayton Cornell <[email protected]> --------- Signed-off-by: erikbaranowski <[email protected]> Co-authored-by: Clayton Cornell <[email protected]>
1 parent 5e037eb commit 88780b8

File tree

6 files changed

+310
-9
lines changed

6 files changed

+310
-9
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Main (unreleased)
3434

3535
- Add ability to convert static mode positions file to `loki.source.file` compatible via `legacy_positions_file` argument. (@mattdurham)
3636

37+
- Added support for `otelcol` configuration conversion in `grafana-agent convert` and `grafana-agent run` commands. (@rfratto, @erikbaranowski, @tpaschalis, @hainenber)
38+
3739
### Features
3840

3941
- Added a new CLI flag `--stability.level` which defines the minimum stability

docs/sources/flow/reference/cli/convert.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ The following flags are supported:
4848

4949
* `--report`, `-r`: The filepath and filename where the report is written.
5050

51-
* `--source-format`, `-f`: Required. The format of the source file. Supported formats: [prometheus], [promtail], [static].
51+
* `--source-format`, `-f`: Required. The format of the source file. Supported formats: [otelcol], [prometheus], [promtail], [static].
5252

5353
* `--bypass-errors`, `-b`: Enable bypassing errors when converting.
5454

5555
* `--extra-args`, `e`: Extra arguments from the original format used by the converter.
5656

57+
[otelcol]: #opentelemetry-collector
5758
[prometheus]: #prometheus
5859
[promtail]: #promtail
5960
[static]: #static
@@ -72,6 +73,17 @@ Errors are defined as non-critical issues identified during the conversion
7273
where an output can still be generated. These can be bypassed using the
7374
`--bypass-errors` flag.
7475

76+
### OpenTelemetry Collector
77+
78+
You can use the `--source-format=otelcol` to convert the source configuration from an [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/configuration/) to a {{< param "PRODUCT_NAME" >}} configuration.
79+
80+
Many OpenTelemetry Collector components are supported.
81+
Review the `otelcol.*` component information in the [Component Reference][] for more information about `otelcol` components that you can convert.
82+
If a source configuration has unsupported features, you will receive [errors] when you convert it to a flow configuration.
83+
The converter raises warnings for configuration options that may require your attention.
84+
85+
Refer to [Migrate from OpenTelemetry Collector to {{< param "PRODUCT_NAME" >}}][migrate-otelcol] for a detailed migration guide.
86+
7587
### Prometheus
7688

7789
Using the `--source-format=prometheus` will convert the source configuration from
@@ -86,7 +98,7 @@ This includes Prometheus features such as
8698
and many supported *_sd_configs. Unsupported features in a source configuration result
8799
in [errors].
88100

89-
Refer to [Migrate from Prometheus to {{< param "PRODUCT_NAME" >}}]({{< relref "../../tasks/migrate/from-prometheus/" >}}) for a detailed migration guide.
101+
Refer to [Migrate from Prometheus to {{< param "PRODUCT_NAME" >}}][migrate-prometheus] for a detailed migration guide.
90102

91103
### Promtail
92104

@@ -100,21 +112,28 @@ are supported and can be converted to {{< param "PRODUCT_NAME" >}} configuration
100112
If you have unsupported features in a source configuration, you will receive [errors] when you convert to a flow configuration. The converter will
101113
also raise warnings for configuration options that may require your attention.
102114

103-
Refer to [Migrate from Promtail to {{< param "PRODUCT_NAME" >}}]({{< relref "../../tasks/migrate/from-promtail/" >}}) for a detailed migration guide.
115+
Refer to [Migrate from Promtail to {{< param "PRODUCT_NAME" >}}][migrate-promtail] for a detailed migration guide.
104116

105117
### Static
106118

107119
Using the `--source-format=static` will convert the source configuration from a
108-
[Grafana Agent Static]({{< relref "../../../static" >}}) configuration to a {{< param "PRODUCT_NAME" >}} configuration.
120+
[Grafana Agent Static][] configuration to a {{< param "PRODUCT_NAME" >}} configuration.
109121

110122
Include `--extra-args` for passing additional command line flags from the original format.
111123
For example, `--extra-args="-enable-features=integrations-next"` will convert a Grafana Agent Static
112-
[integrations-next]({{< relref "../../../static/configuration/integrations/integrations-next/" >}})
113-
configuration to a {{< param "PRODUCT_NAME" >}} configuration. You can also
124+
[integrations-next][] configuration to a {{< param "PRODUCT_NAME" >}} configuration. You can also
114125
expand environment variables with `--extra-args="-config.expand-env"`. You can combine multiple command line
115126
flags with a space between each flag, for example `--extra-args="-enable-features=integrations-next -config.expand-env"`.
116127

117128
If you have unsupported features in a Static mode source configuration, you will receive [errors][] when you convert to a Flow mode configuration. The converter will
118129
also raise warnings for configuration options that may require your attention.
119130

120-
Refer to [Migrate from Grafana Agent Static to {{< param "PRODUCT_NAME" >}}]({{< relref "../../tasks/migrate/from-static/" >}}) for a detailed migration guide.
131+
Refer to [Migrate from Grafana Agent Static to {{< param "PRODUCT_NAME" >}}][migrate-static] for a detailed migration guide.
132+
133+
[Component Reference]: ../../components/
134+
[migrate-otelcol]: ../../../tasks/migrate/from-otelcol/
135+
[migrate-prometheus]: ../../../tasks/migrate/from-prometheus/
136+
[migrate-promtail]: ../../../tasks/migrate/from-promtail/
137+
[migrate-static]: ../../../tasks/migrate/from-static/
138+
[Grafana Agent Static]: ../../../../static/
139+
[integrations-next]: ../../../../static/configuration/integrations/integrations-next/

docs/sources/flow/reference/cli/run.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The following flags are supported:
6161
* `--cluster.advertise-interfaces`: List of interfaces used to infer an address to advertise. Set to `all` to use all available network interfaces on the system. (default `"eth0,en0"`).
6262
* `--cluster.max-join-peers`: Number of peers to join from the discovered set (default `5`).
6363
* `--cluster.name`: Name to prevent nodes without this identifier from joining the cluster (default `""`).
64-
* `--config.format`: The format of the source file. Supported formats: `flow`, `prometheus`, `promtail`, `static` (default `"flow"`).
64+
* `--config.format`: The format of the source file. Supported formats: `flow`, `otelcol`, `prometheus`, `promtail`, `static` (default `"flow"`).
6565
* `--config.bypass-conversion-errors`: Enable bypassing errors when converting (default `false`).
6666
* `--config.extra-args`: Extra arguments from the original format used by the converter.
6767

docs/sources/flow/tasks/migrate/from-operator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ canonical: https://grafana.com/docs/agent/latest/flow/tasks/migrate/from-operato
1010
description: Migrate from Grafana Agent Operator to Grafana Agent Flow
1111
menuTitle: Migrate from Operator
1212
title: Migrate from Grafana Agent Operator to Grafana Agent Flow
13-
weight: 320
13+
weight: 300
1414
---
1515

1616
# Migrate from Grafana Agent Operator to {{% param "PRODUCT_NAME" %}}
Lines changed: 274 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,274 @@
1+
---
2+
canonical: https://grafana.com/docs/agent/latest/flow/tasks/migrate/from-otelcol/
3+
description: Learn how to migrate from OpenTelemetry Collector to Grafana Agent Flow
4+
menuTitle: Migrate from OpenTelemetry Collector
5+
title: Migrate from OpenTelemetry Collector to Grafana Agent Flow
6+
weight: 310
7+
---
8+
9+
# Migrate from OpenTelemetry Collector to {{% param "PRODUCT_NAME" %}}
10+
11+
The built-in {{< param "PRODUCT_ROOT_NAME" >}} convert command can migrate your [OpenTelemetry Collector][] configuration to a {{< param "PRODUCT_NAME" >}} configuration.
12+
13+
This topic describes how to:
14+
15+
* Convert an OpenTelemetry Collector configuration to a {{< param "PRODUCT_NAME" >}} configuration.
16+
* Run an OpenTelemetry Collector configuration natively using {{< param "PRODUCT_NAME" >}}.
17+
18+
## Components used in this topic
19+
20+
* [otelcol.receiver.otlp][]
21+
* [otelcol.processor.memory_limiter][]
22+
* [otelcol.exporter.otlp][]
23+
24+
## Before you begin
25+
26+
* You must have an existing OpenTelemetry Collector configuration.
27+
* You must have a set of OpenTelemetry Collector applications ready to push telemetry data to {{< param "PRODUCT_NAME" >}}.
28+
* You must be familiar with the concept of [Components][] in {{< param "PRODUCT_NAME" >}}.
29+
30+
## Convert an OpenTelemetry Collector configuration
31+
32+
To fully migrate your configuration from [OpenTelemetry Collector] to {{< param "PRODUCT_NAME" >}}, you must convert your OpenTelemetry Collector configuration into a {{< param "PRODUCT_NAME" >}} configuration.
33+
This conversion will enable you to take full advantage of the many additional features available in {{< param "PRODUCT_NAME" >}}.
34+
35+
> In this task, you will use the [convert][] CLI command to output a {{< param "PRODUCT_NAME" >}}
36+
> configuration from a OpenTelemetry Collector configuration.
37+
38+
1. Open a terminal window and run the following command.
39+
40+
{{< code >}}
41+
42+
```static-binary
43+
AGENT_MODE=flow grafana-agent convert --source-format=otelcol --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
44+
```
45+
46+
```flow-binary
47+
grafana-agent-flow convert --source-format=otelcol --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
48+
```
49+
50+
{{< /code >}}
51+
52+
Replace the following:
53+
54+
- _`<INPUT_CONFIG_PATH>`_: The full path to the OpenTelemetry Collector configuration.
55+
- _`<OUTPUT_CONFIG_PATH>`_: The full path to output the {{< param "PRODUCT_NAME" >}} configuration.
56+
57+
1. [Run][] {{< param "PRODUCT_NAME" >}} using the new {{< param "PRODUCT_NAME" >}} configuration from _`<OUTPUT_CONFIG_PATH>`_:
58+
59+
### Debugging
60+
61+
1. If the `convert` command can't convert an OpenTelemetry Collector configuration, diagnostic information is sent to `stderr`.\
62+
You can bypass any non-critical issues and output the {{< param "PRODUCT_NAME" >}} configuration using a best-effort conversion by including the `--bypass-errors` flag.
63+
64+
{{< admonition type="caution" >}}
65+
If you bypass the errors, the behavior of the converted configuration may not match the original OpenTelemetry Collector configuration.
66+
Make sure you fully test the converted configuration before using it in a production environment.
67+
{{< /admonition >}}
68+
69+
{{< code >}}
70+
71+
```static-binary
72+
AGENT_MODE=flow grafana-agent convert --source-format=otelcol --bypass-errors --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
73+
```
74+
75+
```flow-binary
76+
grafana-agent-flow convert --source-format=otelcol --bypass-errors --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
77+
```
78+
79+
{{< /code >}}
80+
81+
Replace the following:
82+
83+
- _`<INPUT_CONFIG_PATH>`_: The full path to the OpenTelemetry Collector configuration.
84+
- _`<OUTPUT_CONFIG_PATH>`_: The full path to output the {{< param "PRODUCT_NAME" >}} configuration.
85+
86+
1. You can also output a diagnostic report by including the `--report` flag.
87+
88+
{{< code >}}
89+
90+
```static-binary
91+
AGENT_MODE=flow grafana-agent convert --source-format=otelcol --report=<OUTPUT_REPORT_PATH> --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
92+
```
93+
94+
```flow-binary
95+
grafana-agent-flow convert --source-format=otelcol --report=<OUTPUT_REPORT_PATH> --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
96+
```
97+
98+
{{< /code >}}
99+
100+
Replace the following:
101+
102+
- _`<INPUT_CONFIG_PATH>`_: The full path to the OpenTelemetry Collector configuration.
103+
- _`<OUTPUT_CONFIG_PATH>`_: The full path to output the {{< param "PRODUCT_NAME" >}} configuration.
104+
- _`<OUTPUT_REPORT_PATH>`_: The output path for the report.
105+
106+
Using the [example][] OpenTelemetry Collector configuration below, the diagnostic report provides the following information:
107+
108+
```plaintext
109+
(Info) Converted receiver/otlp into otelcol.receiver.otlp.default
110+
(Info) Converted processor/memory_limiter into otelcol.processor.memory_limiter.default
111+
(Info) Converted exporter/otlp into otelcol.exporter.otlp.default
112+
113+
A configuration file was generated successfully.
114+
```
115+
116+
## Run an OpenTelemetry Collector configuration
117+
118+
If you’re not ready to completely switch to a {{< param "PRODUCT_NAME" >}} configuration, you can run {{< param "PRODUCT_ROOT_NAME" >}} using your existing OpenTelemetry Collector configuration.
119+
The `--config.format=otelcol` flag tells {{< param "PRODUCT_ROOT_NAME" >}} to convert your OpenTelemetry Collector configuration to a {{< param "PRODUCT_NAME" >}} configuration and load it directly without saving the new configuration.
120+
This allows you to try {{< param "PRODUCT_NAME" >}} without modifying your existing OpenTelemetry Collector configuration infrastructure.
121+
122+
> In this task, you will use the [run][] CLI command to run {{< param "PRODUCT_NAME" >}}
123+
> using an OpenTelemetry Collector configuration.
124+
125+
[Run][] {{< param "PRODUCT_NAME" >}} and include the command line flag `--config.format=otelcol`.
126+
Your configuration file must be a valid OpenTelemetry Collector configuration file rather than a {{< param "PRODUCT_NAME" >}} configuration file.
127+
128+
### Debugging
129+
130+
1. You can follow the convert CLI command [debugging][] instructions to generate a diagnostic report.
131+
132+
1. Refer to the {{< param "PRODUCT_NAME" >}} [Debugging][DebuggingUI] for more information about a running {{< param "PRODUCT_NAME" >}}.
133+
134+
1. If your OpenTelemetry Collector configuration can't be converted and loaded directly into {{< param "PRODUCT_NAME" >}}, diagnostic information is sent to `stderr`.
135+
You can bypass any non-critical issues and start the Agent by including the `--config.bypass-conversion-errors` flag in addition to `--config.format=otelcol`.
136+
137+
{{< admonition type="caution" >}}
138+
If you bypass the errors, the behavior of the converted configuration may not match the original Prometheus configuration.
139+
Do not use this flag in a production environment.
140+
{{< /admonition >}}
141+
142+
## Example
143+
144+
This example demonstrates converting an OpenTelemetry Collector configuration file to a {{< param "PRODUCT_NAME" >}} configuration file.
145+
146+
The following OpenTelemetry Collector configuration file provides the input for the conversion.
147+
148+
```yaml
149+
receivers:
150+
otlp:
151+
protocols:
152+
grpc:
153+
http:
154+
155+
exporters:
156+
otlp:
157+
endpoint: database:4317
158+
159+
processors:
160+
memory_limiter:
161+
limit_percentage: 90
162+
check_interval: 1s
163+
164+
165+
service:
166+
pipelines:
167+
metrics:
168+
receivers: [otlp]
169+
processors: [memory_limiter]
170+
exporters: [otlp]
171+
logs:
172+
receivers: [otlp]
173+
processors: [memory_limiter]
174+
exporters: [otlp]
175+
traces:
176+
receivers: [otlp]
177+
processors: [memory_limiter]
178+
exporters: [otlp]
179+
```
180+
181+
The convert command takes the YAML file as input and outputs a [River][] file.
182+
183+
{{< code >}}
184+
185+
```static-binary
186+
AGENT_MODE=flow grafana-agent convert --source-format=otelcol --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
187+
```
188+
189+
```flow-binary
190+
grafana-agent-flow convert --source-format=otelcol --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
191+
```
192+
193+
{{< /code >}}
194+
195+
Replace the following:
196+
197+
- _`<INPUT_CONFIG_PATH>`_: The full path to the OpenTelemetry Collector configuration.
198+
- _`<OUTPUT_CONFIG_PATH>`_: The full path to output the {{< param "PRODUCT_NAME" >}} configuration.
199+
200+
The new {{< param "PRODUCT_NAME" >}} configuration file looks like this:
201+
202+
```river
203+
otelcol.receiver.otlp "default" {
204+
grpc { }
205+
206+
http { }
207+
208+
output {
209+
metrics = [otelcol.processor.memory_limiter.default.input]
210+
logs = [otelcol.processor.memory_limiter.default.input]
211+
traces = [otelcol.processor.memory_limiter.default.input]
212+
}
213+
}
214+
215+
otelcol.processor.memory_limiter "default" {
216+
check_interval = "1s"
217+
limit_percentage = 90
218+
219+
output {
220+
metrics = [otelcol.exporter.otlp.default.input]
221+
logs = [otelcol.exporter.otlp.default.input]
222+
traces = [otelcol.exporter.otlp.default.input]
223+
}
224+
}
225+
226+
otelcol.exporter.otlp "default" {
227+
client {
228+
endpoint = "database:4317"
229+
}
230+
}
231+
```
232+
233+
## Limitations
234+
235+
Configuration conversion is done on a best-effort basis. {{< param "PRODUCT_ROOT_NAME" >}} will issue warnings or errors where the conversion can't be performed.
236+
237+
After the configuration is converted, review the {{< param "PRODUCT_NAME" >}} configuration file created and verify that it's correct before starting to use it in a production environment.
238+
239+
The following list is specific to the convert command and not {{< param "PRODUCT_NAME" >}}:
240+
241+
* Components are supported which directly embed upstream OpenTelemetry Collector features. You can get a general idea of which exist in
242+
{{< param "PRODUCT_NAME" >}} for conversion by reviewing the `otelcol.*` components in the [Component Reference][].
243+
Any additional unsupported features are returned as errors during conversion.
244+
* Check if you are using any extra command line arguments with OpenTelemetry Collector that aren't present in your configuration file.
245+
* Metamonitoring metrics exposed by {{< param "PRODUCT_NAME" >}} usually match OpenTelemetry Collector metamonitoring metrics but will use a different name.
246+
Make sure that you use the new metric names, for example, in your alerts and dashboards queries.
247+
* The logs produced by {{< param "PRODUCT_NAME" >}} differ from those produced by OpenTelemetry Collector.
248+
* {{< param "PRODUCT_ROOT_NAME" >}} exposes the {{< param "PRODUCT_NAME" >}} [UI][].
249+
250+
[OpenTelemetry Collector]: https://opentelemetry.io/docs/collector/configuration/
251+
[debugging]: #debugging
252+
[example]: #example
253+
254+
{{% docs/reference %}}
255+
[otelcol.receiver.otlp]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/reference/components/otelcol.receiver.otlp.md"
256+
[otelcol.processor.memory_limiter]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/reference/components/otelcol.processor.memory_limiter.md"
257+
[otelcol.exporter.otlp]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/reference/components/otelcol.exporter.otlp.md"
258+
[Components]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/concepts/components.md"
259+
[Components]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/concepts/components.md"
260+
[Component Reference]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/reference/components/_index.md"
261+
[Component Reference]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/reference/components/_index.md"
262+
[convert]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/reference/cli/convert.md"
263+
[convert]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/reference/cli/convert.md"
264+
[run]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/reference/cli/run.md"
265+
[run]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/reference/cli/run.md"
266+
[Run]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/get-started/run/"
267+
[Run]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/get-started/run/"
268+
[DebuggingUI]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/tasks/debug.md"
269+
[DebuggingUI]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/tasks/debug.md"
270+
[River]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/concepts/config-language/_index.md"
271+
[River]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/concepts/config-language/_index.md"
272+
[UI]: "/docs/agent/ -> /docs/agent/<AGENT_VERSION>/flow/tasks/debug#grafana-agent-flow-ui"
273+
[UI]: "/docs/grafana-cloud/ -> /docs/grafana-cloud/send-data/agent/flow/tasks/debug#grafana-agent-flow-ui"
274+
{{% /docs/reference %}}

0 commit comments

Comments
 (0)