Menu

Important: This documentation is about an older version. It's relevant only to the release noted, many of the features and functions have been updated or replaced. Please view the current version.

Open source

Configure Grafana Alloy on Kubernetes

This page describes how to apply a new configuration to Alloy when running on Kubernetes with the Helm chart. It assumes that:

Refer to Collect and forward data for information about configuring Alloy to collect and forward data.

Configure the Helm chart

To modify Alloy’s Helm chart configuration, perform the following steps:

  1. Create a local values.yaml file with a new Helm chart configuration.

    1. You can use your own copy of the values file or download a copy of the default values.yaml.

    2. Make changes to your values.yaml to customize settings for the Helm chart.

      Refer to the inline documentation in the default values.yaml for more information about each option.

  2. Run the following command in a terminal to upgrade your Alloy installation:

    shell
    helm upgrade --namespace <NAMESPACE> <RELEASE_NAME> grafana/alloy -f <VALUES_PATH>

    Replace the following:

    • <NAMESPACE>: The namespace you used for your Alloy installation.
    • <RELEASE_NAME>: The name you used for your Alloy installation.
    • <VALUES_PATH>: The path to your copy of values.yaml to use.

Kustomize considerations

If you are using Kustomize to inflate and install the Helm chart, be careful when using a configMapGenerator to generate the ConfigMap containing the configuration. By default, the generator appends a hash to the name and patches the resource mentioning it, triggering a rolling update.

This behavior is undesirable for Alloy because the startup time can be significant, for example, when your deployment has a large metrics Write-Ahead Log. You can use the Helm chart sidecar container to watch the ConfigMap and trigger a dynamic reload.

The following is an example snippet of a kustomization that disables this behavior:

yaml
configMapGenerator:
  - name: alloy
    files:
      - config.alloy
    options:
      disableNameSuffixHash: true

Configure Alloy

This section describes how to modify the Alloy configuration, which is stored in a ConfigMap in the Kubernetes cluster. There are two methods to perform this task.

Method 1: Modify the configuration in the values.yaml file

Use this method if you prefer to embed your Alloy configuration in the Helm chart’s values.yaml file.

  1. Modify the configuration file contents directly in the values.yaml file:

    yaml
    alloy:
      configMap:
        content: |-
          // Write your Alloy config here:
          logging {
            level = "info"
            format = "logfmt"
          }
  2. Run the following command in a terminal to upgrade your Alloy installation:

    shell
    helm upgrade --namespace <NAMESPACE> <RELEASE_NAME> grafana/alloy -f <VALUES_PATH>

    Replace the following:

    • <NAMESPACE>: The namespace you used for your Alloy installation.
    • <RELEASE_NAME>: The name you used for your Alloy installation.
    • <VALUES_PATH>: The path to your copy of values.yaml to use.

Method 2: Create a separate ConfigMap from a file

Use this method if you prefer to write your Alloy configuration in a separate file.

  1. Write your configuration to a file, for example, config.alloy.

    alloy
    // Write your Alloy config here:
    logging {
      level = "info"
      format = "logfmt"
    }
  2. Create a ConfigMap called alloy-config from the above file:

    shell
    kubectl create configmap --namespace <NAMESPACE> alloy-config "--from-file=config.alloy=./config.alloy"

    Replace the following:

    • <NAMESPACE>: The namespace you used for your Alloy installation.
  3. Modify Helm Chart’s configuration in your values.yaml to use the existing ConfigMap:

    yaml
    alloy:
      configMap:
        create: false
        name: alloy-config
        key: config.alloy
  4. Run the following command in a terminal to upgrade your Alloy installation:

    shell
    helm upgrade --namespace <NAMESPACE> <RELEASE_NAME> grafana/alloy -f <VALUES_PATH>

    Replace the following:

    • <NAMESPACE>: The namespace you used for your Alloy installation.
    • <RELEASE_NAME>: The name you used for your Alloy installation.
    • <VALUES_PATH>: The path to your copy of values.yaml to use.