Menu

Caution

Grafana Alloy is the new name for our distribution of the OTel collector. Grafana Agent has been deprecated and is in Long-Term Support (LTS) through October 31, 2025. Grafana Agent will reach an End-of-Life (EOL) on November 1, 2025. Read more about why we recommend migrating to Grafana Alloy.

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

loki.source.heroku

loki.source.heroku listens for Heroku messages over TCP connections and forwards them to other loki.* components.

The component starts a new heroku listener for the given listener block and fans out incoming entries to the list of receivers in forward_to.

Before using loki.source.heroku, Heroku should be configured with the URL where the Agent will be listening. Follow the steps in Heroku HTTPS Drain docs for using the Heroku CLI with a command like the following:

shell
heroku drains:add [http|https]://HOSTNAME:PORT/heroku/api/v1/drain -a HEROKU_APP_NAME

Multiple loki.source.heroku components can be specified by giving them different labels.

Usage

river
loki.source.heroku "LABEL" {
    listener {
        address = "LISTEN_ADDRESS"
        port    = PORT
    }
    forward_to = RECEIVER_LIST
}

Arguments

loki.source.heroku supports the following arguments:

NameTypeDescriptionDefaultRequired
use_incoming_timestampboolWhether or not to use the timestamp received from Heroku.falseno
labelsmap(string)The labels to associate with each received Heroku record.{}no
forward_tolist(LogsReceiver)List of receivers to send log entries to.yes
relabel_rulesRelabelRulesRelabeling rules to apply on log entries.{}no

The relabel_rules field can make use of the rules export value from a loki.relabel component to apply one or more relabeling rules to log entries before they’re forwarded to the list of receivers in forward_to.

Blocks

The following blocks are supported inside the definition of loki.source.heroku:

HierarchyNameDescriptionRequired
listenerlistenerConfigures a listener for Heroku messages.yes

listener block

The listener block defines the listen address and port where the listener expects Heroku messages to be sent to.

NameTypeDescriptionDefaultRequired
addressstringThe <host> address to listen to for heroku messages.0.0.0.0no
portintThe <port> to listen to for heroku messages.yes

Labels

The labels map is applied to every message that the component reads.

The following internal labels all prefixed with __ are available but will be discarded if not relabeled:

  • __heroku_drain_host
  • __heroku_drain_app
  • __heroku_drain_proc
  • __heroku_drain_log_id

All url query params will be translated to __heroku_drain_param_<name>

If the X-Scope-OrgID header is set it will be translated to __tenant_id__

Exported fields

loki.source.heroku does not export any fields.

Component health

loki.source.heroku is only reported as unhealthy if given an invalid configuration.

Debug information

loki.source.heroku exposes some debug information per Heroku listener:

  • Whether the listener is currently running.
  • The listen address.

Debug metrics

  • loki_source_heroku_drain_entries_total (counter): Number of successful entries received by the Heroku target.
  • loki_source_heroku_drain_parsing_errors_total (counter): Number of parsing errors while receiving Heroku messages.

Example

This example listens for Heroku messages over TCP in the specified port and forwards them to a loki.write component using the Heroku timestamp.

river
loki.source.heroku "local" {
    listener {
        address = "0.0.0.0"
        port    = 8080
    }
    use_incoming_timestamp = true
    labels                 = {component = "loki.source.heroku"}
    forward_to             = [loki.write.local.receiver]
}

loki.write "local" {
    endpoint {
        url = "loki:3100/api/v1/push"
    }
}