> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bronto.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect Grafana Alloy to Bronto

> Configure Grafana Alloy to forward logs, metrics, and traces to Bronto over OTLP/HTTP, including Loki log pipelines, Prometheus metrics, and Kubernetes.

[Grafana Alloy](https://grafana.com/docs/alloy/latest/) is Grafana's distribution of the OpenTelemetry Collector. It forwards logs, metrics, and traces to Bronto with the `otelcol.exporter.otlphttp` component. This page covers Alloy configuration only.

For installation instructions, see the [Alloy installation guide](https://grafana.com/docs/alloy/latest/set-up/install/).

## Endpoint and authentication

Set the exporter's `endpoint` to the base ingestion URL for your Bronto region. Alloy appends `/v1/logs`, `/v1/metrics`, and `/v1/traces` for each signal.

| Region | Endpoint |
| - | - |
| EU | `https://ingestion.eu.bronto.io` |
| US | `https://ingestion.us.bronto.io` |

Bronto uses the `service.name` and `service.namespace` resource attributes to pick the dataset and collection for logs. Only the API key header is required:

| Header | Required | Scope | Description |
| - | - | - | - |
| `x-bronto-api-key` | Required | All signals | Your [Bronto API key](https://docs.bronto.io/Account-Management/API-Keys.md#create-a-new-api-key). |
| `x-bronto-dataset` | Optional | Logs only | Overrides `service.name` as the log dataset. |
| `x-bronto-collection` | Optional | Logs only | Overrides `service.namespace` as the log collection. |
| `x-bronto-tags` | Optional | Logs only | Key-value dataset tags (e.g. `env=prod,team=platform`). See [Partitions](https://docs.bronto.io/Search-and-Visualize/Partitions.md). |

> [!NOTE]
>
> Datasets and collections apply only to logs. Metrics appear in the [Metric Explorer](https://docs.bronto.io/metrics/explore-metrics.md), and traces appear in [Explore Traces](https://docs.bronto.io/tracing/explore-traces.md).

## Logs, metrics, and traces

The example below sends all three signals through one exporter:

* **Logs** — tails files with `loki.source.file`, converts the entries to OTLP with `otelcol.receiver.loki`, and sets the dataset and collection.
* **Metrics** — collects host metrics with `prometheus.exporter.unix` and converts Prometheus counters from cumulative to delta.
* **Traces** — accepts OTLP from your instrumented applications on ports `4317` (gRPC) and `4318` (HTTP).

```hcl config.alloy theme={"dark"}
// Logs: tail files and convert the Loki entries to OTLP
local.file_match "app" {
  path_targets = [{"__path__" = "/path/to/your/logs/*.log"}]
}

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

otelcol.receiver.loki "default" {
  output {
    logs = [otelcol.processor.transform.bronto_routing.input]
  }
}

// Set the log dataset (service.name) and collection (service.namespace)
otelcol.processor.transform "bronto_routing" {
  error_mode = "ignore"

  log_statements {
    context    = "resource"
    statements = [
      `set(resource.attributes["service.name"], "<YOUR_DATASET_NAME>")`,
      `set(resource.attributes["service.namespace"], "<YOUR_COLLECTION_NAME>")`,
    ]
  }

  output {
    logs = [otelcol.processor.batch.default.input]
  }
}

// Metrics: host metrics, converted from cumulative to delta
prometheus.exporter.unix "host" { }

prometheus.scrape "host" {
  targets        = prometheus.exporter.unix.host.targets
  honor_metadata = true
  forward_to     = [otelcol.receiver.prometheus.default.receiver]
}

otelcol.receiver.prometheus "default" {
  output {
    metrics = [otelcol.processor.cumulativetodelta.default.input]
  }
}

otelcol.processor.cumulativetodelta "default" {
  initial_value = "drop"

  output {
    metrics = [otelcol.processor.batch.default.input]
  }
}

// Traces, plus any OTLP logs and metrics, from instrumented applications
otelcol.receiver.otlp "default" {
  grpc {
    endpoint = "0.0.0.0:4317"
  }

  http {
    endpoint = "0.0.0.0:4318"
  }

  output {
    logs    = [otelcol.processor.batch.default.input]
    metrics = [otelcol.processor.cumulativetodelta.default.input]
    traces  = [otelcol.processor.batch.default.input]
  }
}

// Group telemetry into larger requests
otelcol.processor.batch "default" {
  output {
    logs    = [otelcol.exporter.otlphttp.bronto.input]
    metrics = [otelcol.exporter.otlphttp.bronto.input]
    traces  = [otelcol.exporter.otlphttp.bronto.input]
  }
}

// Bronto
otelcol.exporter.otlphttp "bronto" {
  client {
    endpoint = "https://ingestion.<REGION>.bronto.io"
    headers  = {
      "x-bronto-api-key" = sys.env("BRONTO_API_KEY"),
    }
  }
}
```

Start Alloy with the API key in its environment:

```bash theme={"dark"}
export BRONTO_API_KEY=<YOUR_API_KEY>
alloy run --stability.level=experimental config.alloy
```

> [!NOTE]
>
> The metrics pipeline needs a lowered [stability level](https://grafana.com/docs/alloy/latest/reference/cli/run/). `honor_metadata` on `prometheus.scrape` is experimental, and `otelcol.processor.cumulativetodelta` is public preview. If you don't send metrics, remove the metrics components and drop the flag. The logs and traces components here are generally available.

### Why the transform processor is needed

`otelcol.receiver.loki` turns Loki labels such as `job` and `filename` into **log record attributes**, not resource attributes. Without the `otelcol.processor.transform` step, the logs have no `service.name` or `service.namespace`, so Bronto can't route them to the dataset and collection you expect. Alternatively, set the `x-bronto-dataset` and `x-bronto-collection` headers on the exporter. Use a separate exporter for logs if you do, because headers apply to every signal the exporter sends.

### Why `honor_metadata` is needed

By default, `prometheus.scrape` doesn't pass metric type metadata downstream. `otelcol.receiver.prometheus` then can't tell a counter from a gauge, so every metric reaches Bronto as a gauge. For example, `node_cpu_seconds_total` arrives as an ever-growing gauge instead of a counter, and each histogram is split into separate `_bucket`, `_sum`, and `_count` gauges. `honor_metadata = true` keeps the counter, histogram, and summary types.

If you can't run Alloy with `--stability.level=experimental`, remove `honor_metadata`. Metrics still arrive, but only as gauges, and `otelcol.processor.cumulativetodelta` has nothing to convert.

### Why metrics are converted to delta

Prometheus counters and histograms are cumulative. Bronto accepts cumulative sums and histograms, but delta is strongly recommended to get the best value from the current set of supported functions. See [Send Metrics to Bronto](https://docs.bronto.io/metrics/send-metrics.md) for the supported metric types.

## Send only the signals you need

Each pipeline is independent. To send a subset of signals, remove the components you don't need and the matching entries in each `output` block.

## Already using Loki or Prometheus pipelines

If Alloy already sends to Loki or Prometheus, you don't need to change your sources. Add Bronto as a second destination:

* **Loki logs** — add `otelcol.receiver.loki.default.receiver` to the `forward_to` list of your existing `loki.source.*` or `loki.process` components.
* **Prometheus metrics** — add `otelcol.receiver.prometheus.default.receiver` to the `forward_to` list of your existing `prometheus.scrape` components, and set `honor_metadata = true` on them.

## Tail files with the OpenTelemetry filelog receiver

Instead of the Loki components, you can tail files with `otelcol.receiver.filelog`, which sets resource attributes directly and needs no transform step. It is also a public preview component.

```hcl config.alloy theme={"dark"}
otelcol.receiver.filelog "app" {
  include = ["/path/to/your/logs/*.log"]

  resource = {
    "service.name"      = "<YOUR_DATASET_NAME>",
    "service.namespace" = "<YOUR_COLLECTION_NAME>",
  }

  output {
    logs = [otelcol.processor.batch.default.input]
  }
}
```

## Kubernetes

On Kubernetes, run Alloy as a DaemonSet with the [Grafana Alloy Helm chart](https://grafana.com/docs/alloy/latest/set-up/install/kubernetes/). Each Alloy pod tails the container logs on its own node from `/var/log/pods`. Logs from each container go to their own dataset, and the cluster is the collection.

Create a secret for the API key, then install the chart:

```bash theme={"dark"}
kubectl create namespace alloy
kubectl create secret generic bronto-api-key -n alloy \
  --from-literal=api-key=<YOUR_API_KEY>

helm repo add grafana https://grafana.github.io/helm-charts
helm install alloy grafana/alloy -n alloy -f values.yaml
```

```yaml values.yaml theme={"dark"}
alloy:
  mounts:
    varlog: true
  extraEnv:
    - name: BRONTO_API_KEY
      valueFrom:
        secretKeyRef:
          name: bronto-api-key
          key: api-key
    - name: NODE_NAME
      valueFrom:
        fieldRef:
          fieldPath: spec.nodeName
  configMap:
    content: |
      // Discover the pods running on this node
      discovery.kubernetes "pods" {
        role = "pod"

        selectors {
          role  = "pod"
          field = "spec.nodeName=" + sys.env("NODE_NAME")
        }
      }

      // Map each container to its log file and keep useful labels
      discovery.relabel "pod_logs" {
        targets = discovery.kubernetes.pods.targets

        rule {
          source_labels = ["__meta_kubernetes_namespace"]
          target_label  = "namespace"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_name"]
          target_label  = "pod"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_container_name"]
          target_label  = "container"
        }

        rule {
          source_labels = ["__meta_kubernetes_pod_uid", "__meta_kubernetes_pod_container_name"]
          separator     = "/"
          target_label  = "__path__"
          replacement   = "/var/log/pods/*$1/*.log"
        }
      }

      local.file_match "pod_logs" {
        path_targets = discovery.relabel.pod_logs.output
      }

      loki.source.file "pod_logs" {
        targets       = local.file_match.pod_logs.targets
        tail_from_end = true
        forward_to    = [loki.process.cri.receiver]
      }

      // Strip the container runtime (CRI) prefix from each line
      loki.process "cri" {
        stage.cri { }

        forward_to = [otelcol.receiver.loki.default.receiver]
      }

      otelcol.receiver.loki "default" {
        output {
          logs = [otelcol.processor.transform.bronto_routing.input]
        }
      }

      // One dataset per container, one collection per cluster
      otelcol.processor.transform "bronto_routing" {
        error_mode = "ignore"

        log_statements {
          context    = "log"
          statements = [
            `set(resource.attributes["service.name"], log.attributes["container"])`,
            `set(resource.attributes["service.namespace"], "<CLUSTER_NAME>")`,
            `set(resource.attributes["k8s.namespace.name"], log.attributes["namespace"])`,
            `set(resource.attributes["k8s.pod.name"], log.attributes["pod"])`,
          ]
        }

        output {
          logs = [otelcol.processor.batch.default.input]
        }
      }

      // Group log lines into larger requests
      otelcol.processor.batch "default" {
        output {
          logs = [otelcol.exporter.otlphttp.bronto.input]
        }
      }

      otelcol.exporter.otlphttp "bronto" {
        client {
          endpoint = "https://ingestion.<REGION>.bronto.io"
          headers  = {
            "x-bronto-api-key" = sys.env("BRONTO_API_KEY"),
          }
        }
      }
```

The configuration:

* Discovers only the pods on the same node, using the `NODE_NAME` environment variable.
* Strips the container runtime prefix from each line with `stage.cri`, so Bronto receives the original log line.
* Starts at the end of existing log files (`tail_from_end = true`) rather than sending each container's full log history when Alloy starts.
* Sets `service.name` to the container name and adds `k8s.namespace.name` and `k8s.pod.name`, so you can filter by namespace and pod in Bronto.

> [!NOTE]
>
> `otelcol.receiver.loki` sends each log line downstream on its own. Without `otelcol.processor.batch`, a busy node fills the exporter's sending queue and Alloy logs `sending queue is full` errors and drops logs.

## Parsing unstructured logs

Rather than parsing in Alloy, ship raw log lines to Bronto and use the [Bronto Custom Parser](https://docs.bronto.io/core-features/custom-parser.md) to extract structured fields server-side.

## Verify delivery

Once Alloy is running:

* Logs appear in [Search](https://app.bronto.io/search) under the dataset you set.
* Metrics appear in the [Metric Explorer](https://docs.bronto.io/metrics/explore-metrics.md). With `initial_value = "drop"`, the first scrape of each series is used as a baseline, so metrics start arriving after the second scrape.
* Traces appear in [Explore Traces](https://docs.bronto.io/tracing/explore-traces.md).

To check component health, open the Alloy UI at `http://localhost:12345`. A `401` error from `otelcol.exporter.otlphttp.bronto` in the Alloy logs means the API key is missing or invalid.

## Further reading

* [Grafana Alloy component reference](https://grafana.com/docs/alloy/latest/reference/components/) — full list of `otelcol.*`, `loki.*`, and `prometheus.*` components
* [otelcol.exporter.otlphttp](https://grafana.com/docs/alloy/latest/reference/components/otelcol/otelcol.exporter.otlphttp/) — exporter options, including TLS, retries, and queueing
* [Connect OpenTelemetry Collector to Bronto](https://docs.bronto.io/agent-setup/open-telemetry.md) — the equivalent configuration for the upstream Collector
* [Send Metrics to Bronto](https://docs.bronto.io/metrics/send-metrics.md) and [Send Traces to Bronto](https://docs.bronto.io/tracing/send-traces.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.