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.

This is documentation for the next version of Agent. For the latest stable release, go to the latest version.

Beta

module.http (deprecated)

Caution

Starting with release v0.40, module.http is deprecated and is replaced by import.http. module.http will be removed in a future release.

BETA: This is a beta component. Beta components are subject to breaking changes, and may be replaced with equivalent functionality that cover the same use case.

module.http is a module loader component.

module.http embeds a remote.http component to retrieve the module from a remote HTTP server. This allows you to use a single module loader, rather than a remote.http component paired with a module.string component.

Usage

river
module.http "LABEL" {
  url = URL

  arguments {
    MODULE_ARGUMENT_1 = VALUE_1
    ...
  }
}

Arguments

The following arguments are supported:

NameTypeDescriptionDefaultRequired
urlstringURL to poll.yes
methodstringDefine HTTP method for the request"GET"no
headersmap(string)Custom headers for the request.{}no
poll_frequencydurationFrequency to poll the URL."1m"no
poll_timeoutdurationTimeout when polling the URL."10s"no
is_secretboolWhether the response body should be treated as a secret.falseno

Blocks

The following blocks are supported inside the definition of module.http:

HierarchyBlockDescriptionRequired
argumentsargumentsArguments to pass to the module.no

arguments block

The arguments block specifies the list of values to pass to the loaded module.

The attributes provided in the arguments block are validated based on the argument blocks defined in the module source:

  • If a module source marks one of its arguments as required, it must be provided as an attribute in the arguments block of the module loader.

  • Attributes in the argument block of the module loader are rejected if they are not defined in the module source.

Exported fields

The following fields are exported and can be referenced by other components:

NameTypeDescription
exportsmap(any)The exports of the Module loader.

exports exposes the export config block inside a module. It can be accessed from the parent config via module.http.LABEL.exports.EXPORT_LABEL.

Values in exports correspond to export blocks defined in the module source.

Component health

module.http is reported as healthy if the most recent load of the module was successful.

Before the first load of the module, the health is reported as Unknown.

If the module is not loaded successfully, the current health displays as unhealthy, and the health includes the error from loading the module.

Debug information

module.http does not expose any component-specific debug information.

Debug metrics

module.http does not expose any component-specific debug metrics.

Example

In this example, the module.http component loads a module from a locally running HTTP server, polling for changes once every minute.

The module sets up a Redis exporter and exports the list of targets to the parent config to scrape and remote write.

Parent:

river
module.http "remote_module" {
  url              = "http://localhost:8080/redis_module.yaml"
  poll_frequency   = "1m"
}

prometheus.exporter.unix "default" { }

prometheus.scrape "local_agent" {
  targets         = concat(prometheus.exporter.unix.default.targets, module.http.remote_module.exports.targets)
  forward_to      = [module.http.metrics.exports.prometheus_remote_write.receiver]
  scrape_interval = "10s"
}

prometheus.remote_write "default" {
  endpoint {
    url = PROMETHEUS_REMOTE_WRITE_URL

    basic_auth {
        username = USERNAME
        password = PASSWORD
    }
  }
}

Replace the following:

  • PROMETHEUS_REMOTE_WRITE_URL: The URL of the Prometheus remote_write-compatible server to send metrics to.
  • USERNAME: The username to use for authentication to the remote_write API.
  • PASSWORD: The password to use for authentication to the remote_write API.

Module:

river
prometheus.exporter.redis "local_redis" {
  redis_addr          = REDIS_ADDR
  redis_password_file = REDIS_PASSWORD_FILE
}

export "redis_targets" {
  value = prometheus.exporter.redis.local_redis.targets
}

Replace the following:

  • REDIS_ADDR: The address of your Redis instance.
  • REDIS_PASSWORD_FILE: The path to a file containing the password for your Redis instance.