Skip to content

Commit

Permalink
Update migration topic to use codeblock for static and flow commands (#…
Browse files Browse the repository at this point in the history
…5544)

* Update to use codeblock for static and flow

* Add code to promtail convert topic

* Add code to prometheus migration topic
  • Loading branch information
clayton-cornell authored Oct 19, 2023
1 parent 1444962 commit 6d61935
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 38 deletions.
64 changes: 48 additions & 16 deletions docs/sources/flow/getting-started/migrating-from-prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,66 @@ This topic describes how to:

To fully migrate your configuration from [Prometheus] to Grafana Agent
in flow mode, you must convert your Prometheus configuration into a Grafana Agent flow
mode configuration. This conversion will enable you to take full advantage of the many
mode configuration. This conversion will enable you to take full advantage of the many
additional features available in Grafana Agent flow mode.

> In this task, we will use the [convert][] CLI command to output a flow
> configuration from a Prometheus configuration.
1. Open a terminal window and run the following command:

```bash
AGENT_MODE=flow; grafana-agent convert --source-format=prometheus --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

Replace the following:
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=prometheus --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=prometheus --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

Replace the following:
* `INPUT_CONFIG_PATH`: The full path to the Prometheus configuration.
* `OUTPUT_CONFIG_PATH`: The full path to output the flow configuration.

1. [Start the agent][] in flow mode using the new flow configuration from `OUTPUT_CONFIG_PATH`:

### Debugging

1. If the convert command cannot convert a Prometheus configuration,
1. If the convert command can't convert a Prometheus configuration,
diagnostic information is sent to `stderr`. You can bypass
any non-critical issues and output the flow configuration using a
any non-critical issues and output the flow configuration using a
best-effort conversion by including the `--bypass-errors` flag.

{{% admonition type="caution" %}}If you bypass the errors, the behavior of the converted configuration may not match the original Prometheus configuration. Make sure you fully test the converted configuration before using it in a production environment.{{% /admonition %}}

```bash
AGENT_MODE=flow; grafana-agent convert --source-format=prometheus --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=prometheus --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=prometheus --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

1. You can also output a diagnostic report by including the `--report` flag.

```bash
AGENT_MODE=flow; grafana-agent convert --source-format=prometheus --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=prometheus --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=prometheus --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

* Replace `OUTPUT_REPORT_PATH` with the output path for the report.

Expand Down Expand Up @@ -151,10 +175,18 @@ The convert command takes the YAML file as input and outputs a [River][] file.
[River]: {{< relref "../config-language/_index.md" >}}
```bash
AGENT_MODE=flow; grafana-agent convert --source-format=prometheus --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
{{< code >}}
```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=prometheus --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=prometheus --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

The new flow configuration file looks like this:

```river
Expand Down
57 changes: 45 additions & 12 deletions docs/sources/flow/getting-started/migrating-from-promtail.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,18 @@ features available in Grafana Agent Flow Mode.
1. Open a terminal window and run the following command:

```bash
AGENT_MODE=flow; grafana-agent convert --source-format=promtail --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=promtail --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=promtail --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}


Replace the following:
* `INPUT_CONFIG_PATH`: The full path to the Promtail configuration.
Expand All @@ -77,15 +86,31 @@ features available in Grafana Agent Flow Mode.

{{% admonition type="caution" %}}If you bypass the errors, the behavior of the converted configuration may not match the original Promtail configuration. Make sure you fully test the converted configuration before using it in a production environment.{{% /admonition %}}

```bash
AGENT_MODE=flow; grafana-agent convert --source-format=promtail --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=promtail --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=promtail --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

1. You can also output a diagnostic report by including the `--report` flag.

```bash
AGENT_MODE=flow; grafana-agent convert --source-format=promtail --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=promtail --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=promtail --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

* Replace `OUTPUT_REPORT_PATH` with the output path for the report.

Expand Down Expand Up @@ -152,10 +177,18 @@ The convert command takes the YAML file as input and outputs a [River][] file.
[River]: {{< relref "../config-language/_index.md" >}}
```bash
AGENT_MODE=flow; grafana-agent convert --source-format=promtail --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
{{< code >}}
```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=promtail --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=promtail --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

The new Flow Mode configuration file looks like this:

```river
Expand All @@ -182,7 +215,7 @@ loki.write "default" {
## Limitations

Configuration conversion is done on a best-effort basis. The Agent will issue
warnings or errors where the conversion cannot be performed.
warnings or errors where the conversion can't be performed.

Once the configuration is converted, we recommend that you review
the Flow Mode configuration file created, and verify that it is correct
Expand Down
52 changes: 42 additions & 10 deletions docs/sources/flow/getting-started/migrating-from-static.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,17 @@ features available in Grafana Agent Flow mode.
1. Open a terminal window and run the following command:

```bash
AGENT_MODE=flow grafana-agent convert --source-format=static --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=static --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=static --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

Replace the following:
* `INPUT_CONFIG_PATH`: The full path to the [Static][] configuration.
Expand All @@ -82,16 +90,32 @@ features available in Grafana Agent Flow mode.

{{% admonition type="caution" %}}If you bypass the errors, the behavior of the converted configuration may not match the original [Static] mode configuration. Make sure you fully test the converted configuration before using it in a production environment.{{% /admonition %}}

```bash
AGENT_MODE=flow grafana-agent convert --source-format=static --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=static --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=static --bypass-errors --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

1. You can use the `--report` flag to output a diagnostic report.

```bash
AGENT_MODE=flow grafana-agent convert --source-format=static --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
{{< code >}}

```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=static --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=static --report=OUTPUT_REPORT_PATH --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

* Replace `OUTPUT_REPORT_PATH` with the output path for the report.

Using the [example](#example) Grafana Agent Static Mode configuration below, the diagnostic
Expand Down Expand Up @@ -159,7 +183,7 @@ metrics:
- targets: ['127.0.0.1:12345']
labels:
cluster: 'localhost'

logs:
global:
file_watch_config:
Expand Down Expand Up @@ -196,10 +220,18 @@ The convert command takes the YAML file as input and outputs a [River][] file.
[River]: {{< relref "../config-language/_index.md" >}}
```bash
{{< code >}}
```static-binary
AGENT_MODE=flow grafana-agent convert --source-format=static --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

```flow-binary
grafana-agent-flow convert --source-format=static --output=OUTPUT_CONFIG_PATH INPUT_CONFIG_PATH
```

{{< /code >}}

The new Flow mode configuration file looks like this:

```river
Expand Down

0 comments on commit 6d61935

Please sign in to comment.