---
title: "Migrate from Promtail to Grafana Agent Flow | Grafana Agent documentation"
description: "Learn how to migrate from Promtail to Grafana Agent Flow"
---

# Migrate from Promtail to Grafana Agent Flow

The built-in Grafana Agent convert command can migrate your [Promtail](https://www.grafana.com/docs/loki/v0.43/clients/promtail/) configuration to a Grafana Agent Flow configuration.

This topic describes how to:

- Convert a Promtail configuration to a Grafana Agent Flow configuration.
- Run a Promtail configuration natively using Grafana Agent Flow.

## Components used in this topic

- [local.file\_match](/docs/agent/v0.43/flow/reference/components/local.file_match/)
- [loki.source.file](/docs/agent/v0.43/flow/reference/components/loki.source.file/)
- [loki.write](/docs/agent/v0.43/flow/reference/components/loki.write/)

## Before you begin

- You must have an existing Promtail configuration.
- You must be familiar with the concept of [Components](/docs/agent/v0.43/flow/concepts/components/) in Grafana Agent Flow.

## Convert a Promtail configuration

To fully migrate from [Promtail](https://www.grafana.com/docs/loki/v0.43/clients/promtail/) to Grafana Agent Flow, you must convert your Promtail configuration into a Grafana Agent Flow configuration. This conversion will enable you to take full advantage of the many additional features available in Grafana Agent Flow.

> In this task, you will use the [convert](/docs/agent/v0.43/flow/reference/cli/convert/) CLI command to output a Grafana Agent Flow configuration from a Promtail configuration.

1. Open a terminal window and run the following command.
   
   static-binary flow-binary
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   static-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```static-binary
   AGENT_MODE=flow grafana-agent convert --source-format=promtail --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
   ```
   
   flow-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```flow-binary
   grafana-agent-flow convert --source-format=promtail --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
   ```
   
   Replace the following:
   
   - *`<INPUT_CONFIG_PATH>`* : The full path to the Promtail configuration.
   - *`<OUTPUT_CONFIG_PATH>`* : The full path to output the Grafana Agent Flow configuration.
2. [Run](/docs/agent/v0.43/flow/get-started/run/) Grafana Agent Flow using the new configuration from *`<OUTPUT_CONFIG_PATH>`* :

### Debugging

1. If the convert command can’t convert a Promtail configuration, diagnostic information is sent to `stderr`. You can bypass any non-critical issues and output the Grafana Agent Flow configuration using a best-effort conversion by including the `--bypass-errors` flag.
   
   > 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.
   
   static-binary flow-binary
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   static-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```static-binary
   AGENT_MODE=flow grafana-agent convert --source-format=promtail --bypass-errors --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
   ```
   
   flow-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```flow-binary
   grafana-agent-flow convert --source-format=promtail --bypass-errors --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
   ```
   
   Replace the following:
   
   - *`<INPUT_CONFIG_PATH>`* : The full path to the Promtail configuration.
   - *`<OUTPUT_CONFIG_PATH>`* : The full path to output the Grafana Agent Flow configuration.
2. You can also output a diagnostic report by including the `--report` flag.
   
   static-binary flow-binary
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   static-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```static-binary
   AGENT_MODE=flow grafana-agent convert --source-format=promtail --report=<OUTPUT_REPORT_PATH> --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
   ```
   
   flow-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```flow-binary
   grafana-agent-flow convert --source-format=promtail --report=<OUTPUT_REPORT_PATH> --output=<OUTPUT_CONFIG_PATH> <INPUT_CONFIG_PATH>
   ```
   
   Replace the following:
   
   - *`<INPUT_CONFIG_PATH>`* : The full path to the Promtail configuration.
   - *`<OUTPUT_CONFIG_PATH>`* : The full path to output the Grafana Agent Flow configuration.
   - *`<OUTPUT_REPORT_PATH>`* : The output path for the report.
   
   If you use the [example](#example) Promtail configuration below, the diagnostic report provides the following information:
   
   plaintext ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```plaintext
   (Warning) If you have a tracing set up for Promtail, it cannot be migrated to Grafana Agent Flow automatically. Refer to the documentation on how to configure tracing in Grafana Agent Flow.
   (Warning) The metrics from Grafana Agent Flow are different from the metrics emitted by Promtail. If you rely on Promtail's metrics, you must change your configuration, for example, your alerts and dashboards.
   ```

## Run a Promtail configuration

If you’re not ready to completely switch to a Grafana Agent Flow configuration, you can run Grafana Agent using your existing Promtail configuration. The `--config.format=promtail` flag tells Grafana Agent to convert your Promtail configuration to Grafana Agent Flow and load it directly without saving the new configuration. This allows you to try Grafana Agent Flow without modifying your existing Promtail configuration infrastructure.

> In this task, you will use the [run](/docs/agent/v0.43/flow/get-started/run/) CLI command to run Grafana Agent Flow using a Promtail configuration.

[Run](/docs/agent/v0.43/flow/get-started/run/) Grafana Agent Flow and include the command line flag `--config.format=promtail`. Your configuration file must be a valid Promtail configuration file rather than a Grafana Agent Flow configuration file.

### Debugging

1. You can follow the convert CLI command [debugging](#debugging) instructions to generate a diagnostic report.
2. Refer to the Grafana Agent Flow [Debugging](/docs/agent/v0.43/flow/tasks/debug/) for more information about running Grafana Agent Flow.
3. If your Promtail configuration can’t be converted and loaded directly into Grafana Agent, diagnostic information is sent to `stderr`. You can bypass any non-critical issues and start Grafana Agent by including the `--config.bypass-conversion-errors` flag in addition to `--config.format=promtail`.
   
   > Caution
   > 
   > If you bypass the errors, the behavior of the converted configuration may not match the original Promtail configuration. Do not use this flag in a production environment.

## Example

This example demonstrates converting a Promtail configuration file to a Grafana Agent Flow configuration file.

The following Promtail configuration file provides the input for the conversion.

YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```yaml
clients:
  - url: http://localhost/loki/api/v1/push
scrape_configs:
  - job_name: example
    static_configs:
      - targets:
          - localhost
        labels:
          __path__: /var/log/*.log
```

The convert command takes the YAML file as input and outputs a [River](/docs/agent/v0.43/flow/concepts/config-language/) file.

static-binary flow-binary

![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

static-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

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

flow-binary ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

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

Replace the following:

- *`<INPUT_CONFIG_PATH>`* : The full path to the Promtail configuration.
- *`<OUTPUT_CONFIG_PATH>`* : The full path to output the Grafana Agent Flow configuration.

The new Grafana Agent Flow configuration file looks like this:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
local.file_match "example" {
	path_targets = [{
		__address__ = "localhost",
		__path__    = "/var/log/*.log",
	}]
}

loki.source.file "example" {
	targets    = local.file_match.example.targets
	forward_to = [loki.write.default.receiver]
}

loki.write "default" {
	endpoint {
		url = "http://localhost/loki/api/v1/push"
	}
	external_labels = {}
}
```

## Limitations

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

After the configuration is converted, review the Grafana Agent Flow configuration file created and verify that it’s correct before starting to use it in a production environment.

The following list is specific to the convert command and not Grafana Agent Flow:

- Check if you are using any extra command line arguments with Promtail that aren’t present in your configuration file. For example, `-max-line-size`.
- Check if you are setting any environment variables, whether [expanded in the configuration file](https://www.grafana.com/docs/loki/v0.43/clients/promtail/configuration/#use-environment-variables-in-the-configuration) itself or consumed directly by Promtail, such as `JAEGER_AGENT_HOST`.
- In Grafana Agent Flow, the positions file is saved at a different location. Refer to the [loki.source.file](/docs/agent/v0.43/flow/reference/components/loki.source.file/) documentation for more details. Check if you have any existing setup, for example, a Kubernetes Persistent Volume, that you must update to use the new positions file path.
- Metamonitoring metrics exposed by Grafana Agent Flow usually match Promtail metamonitoring metrics but will use a different name. Make sure that you use the new metric names, for example, in your alerts and dashboards queries.
- The logs produced by Grafana Agent Flow will differ from those produced by Promtail.
- Grafana Agent Flow exposes the Grafana Agent Flow [UI](/docs/agent/v0.43/flow/tasks/debug/#grafana-agent-flow-ui), which differs from Promtail’s Web UI.
