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.
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" {
    http {
        listen_address = "LISTEN_ADDRESS"
        listen_port    = LISTEN_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
graceful_shutdown_timeoutdurationTimeout for servers graceful shutdown. If configured, should be greater than zero.“30s”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
httphttpConfigures the HTTP server that receives requests.no
grpcgrpcConfigures the gRPC server that receives requests.no

http

The http block configures the HTTP server.

You can use the following arguments to configure the http block. Any omitted fields take their default values.

NameTypeDescriptionDefaultRequired
conn_limitintMaximum number of simultaneous HTTP connections. Defaults to no limit.0no
listen_addressstringNetwork address on which the server listens for new connections. Defaults to accepting all incoming connections.""no
listen_portintPort number on which the server listens for new connections.8080no
server_idle_timeoutdurationIdle timeout for HTTP server."120s"no
server_read_timeoutdurationRead timeout for HTTP server."30s"no
server_write_timeoutdurationWrite timeout for HTTP server."30s"no

grpc

The grpc block configures the gRPC server.

You can use the following arguments to configure the grpc block. Any omitted fields take their default values.

NameTypeDescriptionDefaultRequired
conn_limitintMaximum number of simultaneous HTTP connections. Defaults to no limit.0no
listen_addressstringNetwork address on which the server listens for new connections. It defaults to accepting all incoming connections.""no
listen_portintPort number on which the server listens for new connections. Defaults to a random free port.0no
max_connection_age_gracedurationAn additive period after max_connection_age after which the connection is forcibly closed."infinity"no
max_connection_agedurationThe duration for the maximum time a connection may exist before it is closed."infinity"no
max_connection_idledurationThe duration after which an idle connection is closed."infinity"no
server_max_concurrent_streamsintLimit on the number of concurrent streams for gRPC calls (0 = unlimited).100no
server_max_recv_msg_sizeintLimit on the size of a gRPC message this server can receive (bytes).4MBno
server_max_send_msg_sizeintLimit on the size of a gRPC message this server can send (bytes).4MBno

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" {
    http {
        listen_address = "0.0.0.0"
        listen_port    = 4040
    }
    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"
    }
}

When using the default http block settings, the server listen for new connection on port 8080.

river
loki.source.heroku "local" {
    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"
    }
}

Compatible components

loki.source.heroku can accept arguments from the following components:

Note

Connecting some components may not be sensible or components may require further configuration to make the connection work correctly. Refer to the linked documentation for more details.