The http receiver accepts metrics through HTTP POST requests. It is commonly used to receive data from remote collectors or applications that can push metrics in InfluxDB line protocol.
{
"my_http_receiver": {
"type": "http",
"address" : "0.0.0.0",
"port" : "8080",
"path" : "/write",
"idle_timeout": "120s",
"keep_alives_enabled": true,
"username": "myUser",
"password": "myPW",
"process_messages": []
}
}type: Must behttp.address: IP address to listen on (default: empty for all interfaces).port: Port to listen on (default:8080).path: URL path for the write endpoint (e.g.,/write).idle_timeout: Maximum idle time for keep-alive connections (default:120s).keep_alives_enabled: Whether to enable HTTP keep-alives (default:true).username: Optional username for basic authentication.password: Optional password for basic authentication.process_messages: Optional message processing rules.
The HTTP endpoint listens at http://<address>:<port>/<path>.
The receiver expects data in InfluxDB line protocol. Multiple lines can be sent in a single POST request.
You can use curl to test the receiver:
curl http://localhost:8080/write \
--user "myUser:myPW" \
--data \
"myMetric,hostname=myHost,type=hwthread,type-id=0,unit=Hz value=400000i 1694777161164284635
myMetric,hostname=myHost,type=hwthread,type-id=1,unit=Hz value=400001i 1694777161164284635"The credentials above need not be stored in the configuration file. Each of
username, password has two sibling keys that select an alternative source:
username_env: name of an environment variable holding the valueusername_file: path to a file holding the valuepassword_env: name of an environment variable holding the valuepassword_file: path to a file holding the value
The environment variable takes precedence over the file, and the file over the
inline value. A named file that cannot be read is an error rather than a silent
fallback, so a stale credential is never used in its place. See the
util package for the full rules.