Grafana Alloy

Grafana Alloy

Ship logs from Grafana Alloy over OTLP HTTP with Basic auth

Use Grafana Alloy to collect log files and send them to your Logit.io Logs stack over OTLP HTTP. Alloy is Grafana's distribution of the OpenTelemetry Collector. It exports to your stack's Hosted OpenTelemetry endpoint with Basic auth. Applications can also send traces and metrics through the same exporter.

⚠️

Promtail reached end of life on 2 March 2026. Grafana Agent (Static mode, Flow mode and Operator) reached end of life on 1 November 2025. Neither receives security or bug fixes. If you still run either, move to Alloy. See Migrate from Loki and Grafana Cloud for the steps.

Logs

Install integration

Please click on the Install Integration button to configure your stack for this source.

Before you start

  1. Enable Hosted OpenTelemetry on your Logs stack if the card on the stack's Endpoints page does not already show connection details.
  2. Copy the username and the Hosted OpenTelemetry API key from the Hosted OpenTelemetry section of the Endpoints page. The username is {stackId}-otel. Use the Hosted OpenTelemetry API key as the password, not your OpenSearch key.
  3. Install Alloy (opens in a new tab) on the server that holds the logs.

The destination is https://{stackId}-otel.logit.io. Replace {stackId} with your Logs stack ID. Use HTTPS on the default port 443, with no custom port. Hosted OpenTelemetry accepts OTLP over HTTP only, so use the otelcol.exporter.otlphttp component. Do not use otelcol.exporter.otlp, which sends over gRPC.

Configure Alloy

Save this as your Alloy configuration file. On Linux packages this is /etc/alloy/config.alloy. Change __path__ to the log files you want to collect.

config.alloy
local.file_match "app_logs" {
  path_targets = [{
    __path__ = "/var/log/*.log",
    job      = "varlogs",
  }]
}
 
loki.source.file "app_logs" {
  targets       = local.file_match.app_logs.targets
  forward_to    = [otelcol.receiver.loki.logit.receiver]
  tail_from_end = true
}
 
otelcol.receiver.loki "logit" {
  output {
    logs = [otelcol.processor.batch.logit.input]
  }
}
 
otelcol.receiver.otlp "local_apps" {
  http {
    endpoint = "127.0.0.1:4318"
  }
 
  grpc {
    endpoint = "127.0.0.1:4317"
  }
 
  output {
    logs    = [otelcol.processor.batch.logit.input]
    metrics = [otelcol.processor.batch.logit.input]
    traces  = [otelcol.processor.batch.logit.input]
  }
}
 
otelcol.processor.batch "logit" {
  output {
    logs    = [otelcol.exporter.otlphttp.logit.input]
    metrics = [otelcol.exporter.otlphttp.logit.input]
    traces  = [otelcol.exporter.otlphttp.logit.input]
  }
}
 
otelcol.auth.basic "logit" {
  username = "{stackId}-otel"
  password = sys.env("LOGIT_OTEL_API_KEY")
}
 
otelcol.exporter.otlphttp "logit" {
  client {
    endpoint = "https://{stackId}-otel.logit.io"
    auth     = otelcol.auth.basic.logit.handler
  }
}

How the pipeline works:

  • loki.source.file reads the files and otelcol.receiver.loki converts each entry to an OpenTelemetry log record. tail_from_end = true starts at the end of each file the first time Alloy sees it, so write a new log line after Alloy starts. Remove it to read existing content too.
  • otelcol.receiver.otlp is optional. It lets local applications send OTLP logs, traces and metrics to Alloy on loopback ports. Delete the whole block, and the metrics and traces lines in the batch processor's output, if you only collect files.
  • otelcol.auth.basic reads the API key from the LOGIT_OTEL_API_KEY environment variable, so the key stays out of the file.
  • Traces and metrics are accepted, but they are stored only if your stack has the APM or Metrics add-on. Logs need no add-on.

Set the API key and start Alloy

Set LOGIT_OTEL_API_KEY in the environment of the Alloy service. For the Linux packages, add it to the service environment file, /etc/default/alloy on Debian and Ubuntu or /etc/sysconfig/alloy on RHEL.

LOGIT_OTEL_API_KEY="<your-hosted-otel-api-key>"

Check the file, then restart the service. The service needs read access to each log file.

alloy validate /etc/alloy/config.alloy
sudo systemctl restart alloy

alloy validate checks the syntax and component wiring. It makes no network connections.

Launch OpenSearch Dashboards to view your data

Launch OpenSearch Dashboards

How to diagnose no data in your stack

If you don't see data appearing in your stack after following this integration, take a look at the troubleshooting guide for steps to diagnose and resolve the problem or contact our support team and we'll be happy to assist.

Troubleshooting

SymptomWhat to check
HTTP 401 in the Alloy logsIs the username exactly {stackId}-otel? Is the password the Hosted OpenTelemetry API key from the Endpoints page? Did you rotate the key and not update LOGIT_OTEL_API_KEY?
Connection or TLS errorsIs the endpoint https://{stackId}-otel.logit.io with no port? Are you using otelcol.exporter.otlphttp and not the gRPC exporter?
Logs arrive but traces or metrics do notDoes the stack have the APM or Metrics add-on? Hosted OpenTelemetry accepts these signals but stores them only with the add-on.
Old log lines are missingtail_from_end = true skips content that was already in the file when Alloy first read it.

Related guides