2018-02-16 08:00:10 +08:00
|
|
|
# HTTP Input Plugin
|
|
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
The HTTP input plugin collects metrics from one or more HTTP(S) endpoints. The
|
|
|
|
|
endpoint should have metrics formatted in one of the supported [input data
|
|
|
|
|
formats](../../../docs/DATA_FORMATS_INPUT.md). Each data format has its own
|
|
|
|
|
unique set of configuration options which can be added to the input
|
|
|
|
|
configuration.
|
2018-02-16 08:00:10 +08:00
|
|
|
|
2022-10-27 03:58:36 +08:00
|
|
|
## Global configuration options <!-- @/docs/includes/plugin_config.md -->
|
|
|
|
|
|
|
|
|
|
In addition to the plugin-specific configuration settings, plugins support
|
|
|
|
|
additional global and plugin configuration settings. These settings are used to
|
|
|
|
|
modify metrics, tags, and field or create aliases and configure ordering, etc.
|
|
|
|
|
See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|
|
|
|
|
2023-01-12 23:55:21 +08:00
|
|
|
[CONFIGURATION.md]: ../../../docs/CONFIGURATION.md#plugins
|
2022-10-27 03:58:36 +08:00
|
|
|
|
2023-02-03 00:31:23 +08:00
|
|
|
## Secret-store support
|
|
|
|
|
|
|
|
|
|
This plugin supports secrets from secret-stores for the `username` and
|
|
|
|
|
`password` option.
|
|
|
|
|
See the [secret-store documentation][SECRETSTORE] for more details on how
|
|
|
|
|
to use them.
|
|
|
|
|
|
|
|
|
|
[SECRETSTORE]: ../../../docs/CONFIGURATION.md#secret-store-secrets
|
|
|
|
|
|
2021-11-25 02:56:55 +08:00
|
|
|
## Configuration
|
2018-02-16 08:00:10 +08:00
|
|
|
|
2022-05-24 21:49:47 +08:00
|
|
|
```toml @sample.conf
|
2018-02-16 08:00:10 +08:00
|
|
|
# Read formatted metrics from one or more HTTP endpoints
|
|
|
|
|
[[inputs.http]]
|
|
|
|
|
## One or more URLs from which to read formatted metrics
|
|
|
|
|
urls = [
|
|
|
|
|
"http://localhost/metrics"
|
|
|
|
|
]
|
|
|
|
|
|
2018-02-16 10:36:01 +08:00
|
|
|
## HTTP method
|
|
|
|
|
# method = "GET"
|
|
|
|
|
|
2018-02-16 09:54:08 +08:00
|
|
|
## Optional HTTP headers
|
|
|
|
|
# headers = {"X-Special-Header" = "Special-Value"}
|
|
|
|
|
|
2018-12-12 11:12:00 +08:00
|
|
|
## HTTP entity-body to send with POST/PUT requests.
|
|
|
|
|
# body = ""
|
|
|
|
|
|
|
|
|
|
## HTTP Content-Encoding for write request body, can be set to "gzip" to
|
|
|
|
|
## compress body or "identity" to apply no encoding.
|
|
|
|
|
# content_encoding = "identity"
|
|
|
|
|
|
2020-04-15 03:31:26 +08:00
|
|
|
## Optional file with Bearer token
|
|
|
|
|
## file content is added as an Authorization header
|
|
|
|
|
# bearer_token = "/path/to/file"
|
|
|
|
|
|
2018-02-16 08:00:10 +08:00
|
|
|
## Optional HTTP Basic Auth Credentials
|
|
|
|
|
# username = "username"
|
|
|
|
|
# password = "pa$$word"
|
|
|
|
|
|
2021-04-23 21:37:27 +08:00
|
|
|
## OAuth2 Client Credentials. The options 'client_id', 'client_secret', and 'token_url' are required to use OAuth2.
|
|
|
|
|
# client_id = "clientid"
|
|
|
|
|
# client_secret = "secret"
|
|
|
|
|
# token_url = "https://indentityprovider/oauth2/v1/token"
|
|
|
|
|
# scopes = ["urn:opc:idm:__myscopes__"]
|
|
|
|
|
|
2020-11-27 06:16:25 +08:00
|
|
|
## HTTP Proxy support
|
2022-10-21 02:40:37 +08:00
|
|
|
# use_system_proxy = false
|
2020-11-27 06:16:25 +08:00
|
|
|
# http_proxy_url = ""
|
|
|
|
|
|
2018-05-05 07:33:23 +08:00
|
|
|
## Optional TLS Config
|
|
|
|
|
# tls_ca = "/etc/telegraf/ca.pem"
|
|
|
|
|
# tls_cert = "/etc/telegraf/cert.pem"
|
|
|
|
|
# tls_key = "/etc/telegraf/key.pem"
|
2022-08-09 19:36:47 +08:00
|
|
|
## Minimal TLS version to accept by the client
|
|
|
|
|
# tls_min_version = "TLS12"
|
2018-05-05 07:33:23 +08:00
|
|
|
## Use TLS but skip chain & host verification
|
2018-02-16 08:00:10 +08:00
|
|
|
# insecure_skip_verify = false
|
|
|
|
|
|
2021-07-14 05:58:49 +08:00
|
|
|
## Optional Cookie authentication
|
|
|
|
|
# cookie_auth_url = "https://localhost/authMe"
|
|
|
|
|
# cookie_auth_method = "POST"
|
|
|
|
|
# cookie_auth_username = "username"
|
|
|
|
|
# cookie_auth_password = "pa$$word"
|
2022-07-09 05:10:46 +08:00
|
|
|
# cookie_auth_headers = { Content-Type = "application/json", X-MY-HEADER = "hello" }
|
2021-07-14 05:58:49 +08:00
|
|
|
# cookie_auth_body = '{"username": "user", "password": "pa$$word", "authenticate": "me"}'
|
|
|
|
|
## cookie_auth_renewal not set or set to "0" will auth once and never renew the cookie
|
|
|
|
|
# cookie_auth_renewal = "5m"
|
|
|
|
|
|
2018-02-16 09:54:08 +08:00
|
|
|
## Amount of time allowed to complete the HTTP request
|
2018-02-16 08:00:10 +08:00
|
|
|
# timeout = "5s"
|
|
|
|
|
|
2019-10-22 05:23:36 +08:00
|
|
|
## List of success status codes
|
|
|
|
|
# success_status_codes = [200]
|
|
|
|
|
|
2018-02-16 08:00:10 +08:00
|
|
|
## Data format to consume.
|
|
|
|
|
## Each data format has its own unique set of configuration options, read
|
|
|
|
|
## more about them here:
|
|
|
|
|
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
|
|
|
|
|
# data_format = "influx"
|
2018-02-16 09:54:08 +08:00
|
|
|
|
2018-02-16 08:00:10 +08:00
|
|
|
```
|
|
|
|
|
|
2022-07-14 22:38:39 +08:00
|
|
|
## Example Output
|
|
|
|
|
|
|
|
|
|
This example output was taken from [this instructional article][1].
|
|
|
|
|
|
|
|
|
|
[1]: https://docs.influxdata.com/telegraf/v1.21/guides/using_http/
|
|
|
|
|
|
|
|
|
|
```shell
|
|
|
|
|
citibike,station_id=4703 eightd_has_available_keys=false,is_installed=1,is_renting=1,is_returning=1,legacy_id="4703",num_bikes_available=6,num_bikes_disabled=2,num_docks_available=26,num_docks_disabled=0,num_ebikes_available=0,station_status="active" 1641505084000000000
|
|
|
|
|
citibike,station_id=4704 eightd_has_available_keys=false,is_installed=1,is_renting=1,is_returning=1,legacy_id="4704",num_bikes_available=10,num_bikes_disabled=2,num_docks_available=36,num_docks_disabled=0,num_ebikes_available=0,station_status="active" 1641505084000000000
|
|
|
|
|
citibike,station_id=4711 eightd_has_available_keys=false,is_installed=1,is_renting=1,is_returning=1,legacy_id="4711",num_bikes_available=9,num_bikes_disabled=0,num_docks_available=36,num_docks_disabled=0,num_ebikes_available=1,station_status="active" 1641505084000000000
|
|
|
|
|
```
|
|
|
|
|
|
2021-11-25 02:56:55 +08:00
|
|
|
## Metrics
|
2018-02-16 08:00:10 +08:00
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
The metrics collected by this input plugin will depend on the configured
|
|
|
|
|
`data_format` and the payload returned by the HTTP endpoint(s).
|
2018-02-16 09:54:08 +08:00
|
|
|
|
|
|
|
|
The default values below are added if the input format does not specify a value:
|
|
|
|
|
|
|
|
|
|
- http
|
|
|
|
|
- tags:
|
|
|
|
|
- url
|
2021-07-14 05:58:49 +08:00
|
|
|
|
2021-11-25 02:56:55 +08:00
|
|
|
## Optional Cookie Authentication Settings
|
2021-07-14 05:58:49 +08:00
|
|
|
|
2022-06-08 05:37:08 +08:00
|
|
|
The optional Cookie Authentication Settings will retrieve a cookie from the
|
|
|
|
|
given authorization endpoint, and use it in subsequent API requests. This is
|
|
|
|
|
useful for services that do not provide OAuth or Basic Auth authentication,
|
|
|
|
|
e.g. the [Tesla Powerwall API][tesla], which uses a Cookie Auth Body to retrieve
|
|
|
|
|
an authorization cookie. The Cookie Auth Renewal interval will renew the
|
|
|
|
|
authorization by retrieving a new cookie at the given interval.
|
|
|
|
|
|
|
|
|
|
[tesla]: https://www.tesla.com/support/energy/powerwall/own/monitoring-from-home-network
|