---
title: "The convert command | Grafana Agent documentation"
description: "Learn about the convert command"
---

# The convert command

The `convert` command converts a supported configuration format to Grafana Agent Flow River format.

> Caution
> 
> This command has no backward compatibility guarantees and may change or be removed between releases.

## Usage

Usage:

- `AGENT_MODE=flow grafana-agent convert [<FLAG> ...] <FILE_NAME>`
- `grafana-agent-flow convert [<FLAG> ...] <FILE_NAME>`
  
  Replace the following:
  
  - *`<FLAG>`* : One or more flags that define the input and output of the command.
  - *`<FILE_NAME>`* : The Grafana Agent configuration file.

If the `FILE_NAME` argument isn’t provided or if the `FILE_NAME` argument is equal to `-`, `convert` converts the contents of standard input. Otherwise, `convert` reads and converts the file from disk specified by the argument.

There are several different flags available for the `convert` command. You can use the `--output` flag to write the contents of the converted configuration to a specified path. You can use the `--report` flag to generate a diagnostic report. The `--bypass-errors` flag allows you to bypass any [errors](#errors) generated during the file conversion.

The command fails if the source configuration has syntactically incorrect configuration or can’t be converted to Grafana Agent Flow River format.

The following flags are supported:

- `--output`, `-o`: The filepath and filename where the output is written.
- `--report`, `-r`: The filepath and filename where the report is written.
- `--source-format`, `-f`: Required. The format of the source file. Supported formats: [otelcol](#opentelemetry-collector), [prometheus](#prometheus), [promtail](#promtail), [static](#static).
- `--bypass-errors`, `-b`: Enable bypassing errors when converting.
- `--extra-args`, `e`: Extra arguments from the original format used by the converter.

### Defaults

Grafana Agent Flow defaults are managed as follows:

- If a provided source configuration value matches a Grafana Agent Flow default value, the property is left off the output.
- If a non-provided source configuration value default matches a Grafana Agent Flow default value, the property is left off the output.
- If a non-provided source configuration value default doesn’t match a Grafana Agent Flow default value, the default value is included in the output.

### Errors

Errors are defined as non-critical issues identified during the conversion where an output can still be generated. These can be bypassed using the `--bypass-errors` flag.

### OpenTelemetry Collector

You can use the `--source-format=otelcol` to convert the source configuration from an [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/configuration/) to a Grafana Agent Flow configuration.

Many OpenTelemetry Collector components are supported. Review the `otelcol.*` component information in the [Component Reference](../../components/) for more information about `otelcol` components that you can convert. If a source configuration has unsupported features, you will receive [errors](#errors) when you convert it to a flow configuration. The converter raises warnings for configuration options that may require your attention.

Refer to [Migrate from OpenTelemetry Collector to Grafana Agent Flow](../../../tasks/migrate/from-otelcol/) for a detailed migration guide.

### Prometheus

Using the `--source-format=prometheus` will convert the source configuration from [Prometheus v2.45](https://prometheus.io/docs/prometheus/2.45/configuration/configuration/) to Grafana Agent Flow configuration.

This includes Prometheus features such as [scrape\_config](https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#scrape_config), [relabel\_config](https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#relabel_config), [metric\_relabel\_configs](https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#metric_relabel_configs), [remote\_write](https://prometheus.io/docs/prometheus/2.45/configuration/configuration/#remote_write), and many supported \*\_sd\_configs. Unsupported features in a source configuration result in [errors](#errors).

Refer to [Migrate from Prometheus to Grafana Agent Flow](../../../tasks/migrate/from-prometheus/) for a detailed migration guide.

### Promtail

Using the `--source-format=promtail` will convert the source configuration from [Promtail v2.8.x](/docs/loki/v2.8.x/clients/promtail/) to Grafana Agent Flow configuration.

Nearly all [Promtail features](/docs/loki/v2.8.x/clients/promtail/configuration/) are supported and can be converted to Grafana Agent Flow configuration.

If you have unsupported features in a source configuration, you will receive [errors](#errors) when you convert to a flow configuration. The converter will also raise warnings for configuration options that may require your attention.

Refer to [Migrate from Promtail to Grafana Agent Flow](../../../tasks/migrate/from-promtail/) for a detailed migration guide.

### Static

Using the `--source-format=static` will convert the source configuration from a [Grafana Agent Static](../../../../static/) configuration to a Grafana Agent Flow configuration.

Include `--extra-args` for passing additional command line flags from the original format. For example, `--extra-args="-enable-features=integrations-next"` will convert a Grafana Agent Static [integrations-next](../../../../static/configuration/integrations/integrations-next/) configuration to a Grafana Agent Flow configuration. You can also expand environment variables with `--extra-args="-config.expand-env"`. You can combine multiple command line flags with a space between each flag, for example `--extra-args="-enable-features=integrations-next -config.expand-env"`.

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

Refer to [Migrate from Grafana Agent Static to Grafana Agent Flow](../../../tasks/migrate/from-static/) for a detailed migration guide.
