---
title: "module.http | Grafana Agent documentation"
description: "Learn about module.http"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# 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](/docs/agent/latest/stability/#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](../../../concepts/modules/#module-loaders) component.

`module.http` embeds a [remote.http](../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](../module.string/) component.

## Usage

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
module.http "LABEL" {
  url = URL

  arguments {
    MODULE_ARGUMENT_1 = VALUE_1
    ...
  }
}
```

## Arguments

The following arguments are supported:

Expand table

| Name             | Type          | Description                                              | Default | Required |
|------------------|---------------|----------------------------------------------------------|---------|----------|
| `url`            | `string`      | URL to poll.                                             |         | yes      |
| `method`         | `string`      | Define HTTP method for the request                       | `"GET"` | no       |
| `headers`        | `map(string)` | Custom headers for the request.                          | `{}`    | no       |
| `poll_frequency` | `duration`    | Frequency to poll the URL.                               | `"1m"`  | no       |
| `poll_timeout`   | `duration`    | Timeout when polling the URL.                            | `"10s"` | no       |
| `is_secret`      | `bool`        | Whether the response body should be treated as a secret. | false   | no       |

## Blocks

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

Expand table

| Hierarchy | Block                         | Description                      | Required |
|-----------|-------------------------------|----------------------------------|----------|
| arguments | [arguments](#arguments-block) | Arguments 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](../../config-blocks/argument/) 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:

Expand table

| Name      | Type       | Description                       |
|-----------|------------|-----------------------------------|
| `exports` | `map(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](../../config-blocks/export/) 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:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
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:

Alloy ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```alloy
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.
