General availability (GA) Open source Grafana Cloud

import.http

import.http retrieves a module from an HTTP server.

Use import.http to load Alloy configuration from a remote HTTP server. The remote file must define configuration inside a declare block. Alloy evaluates imported modules as reusable components, so the remote file must not include top-level global configuration blocks such as logging or remotecfg. Global configuration belongs in the local configuration file that imports the module. You must configure command-line flags outside the module. Alloy periodically polls the URL to detect and apply configuration changes.

Refer to Load configuration from remote sources for more information.

Usage

Alloy
import.http "<LABEL>" {
  url = <URL>
}

Arguments

You can use the following arguments with import.http:

NameTypeDescriptionDefaultRequired
urlstringURL to poll.yes
headersmap(string)Custom headers for the request.{}no
methodstringHTTP method for the request."GET"no
poll_frequencydurationFrequency to poll the URL."1m"no
poll_timeoutdurationTimeout when polling the URL."10s"no

Blocks

You can use the following blocks with import.http:

BlockDescriptionRequired
clientHTTP client settings when connecting to the endpoint.no
client > authorizationConfigure generic authorization to the endpoint.no
client > basic_authConfigure basic_auth for authenticating to the endpoint.no
client > oauth2Configure OAuth 2.0 for authenticating to the endpoint.no
client > oauth2 > tls_configConfigure TLS settings for connecting to the endpoint.no
client > tls_configConfigure TLS settings for connecting to the endpoint.no

The > symbol indicates deeper levels of nesting. For example, client > basic_auth refers to a basic_auth block defined inside a client block.

client

The client block configures settings for connecting to the HTTP server.

NameTypeDescriptionDefaultRequired
bearer_token_filestringFile containing a bearer token to authenticate with.no
bearer_tokensecretBearer token to authenticate with.no
enable_http2boolWhether HTTP2 is supported for requests.trueno
follow_redirectsboolWhether redirects returned by the server should be followed.trueno
http_headersmap(list(secret))Custom HTTP headers to be sent along with each request. The map key is the header name.no
proxy_urlstringHTTP proxy to send requests through.no
no_proxystringComma-separated list of IP addresses, CIDR notations, and domain names to exclude from proxying.no
proxy_from_environmentboolUse the proxy URL indicated by environment variables.falseno
proxy_connect_headermap(list(secret))Specifies headers to send to proxies during CONNECT requests.no

bearer_token, bearer_token_file, basic_auth, authorization, and oauth2 are mutually exclusive, and only one can be provided inside of a http_client_config block.

no_proxy can contain IPs, CIDR notations, and domain names. IP and domain names can contain port numbers. proxy_url must be configured if no_proxy is configured.

proxy_from_environment uses the environment variables HTTP_PROXY, HTTPS_PROXY, and NO_PROXY (or the lowercase versions thereof). Requests use the proxy from the environment variable matching their scheme, unless excluded by NO_PROXY. proxy_url and no_proxy must not be configured if proxy_from_environment is configured.

proxy_connect_header should only be configured if proxy_url or proxy_from_environment are configured.

authorization

The authorization block configures custom authorization for polling the configured URL.

NameTypeDescriptionDefaultRequired
credentials_filestringFile containing the secret value.no
credentials