HTTP 监听器 v2 输入插件
此插件监听通过 HTTP 发送的、采用任何支持的 数据格式 的指标。
如果您希望 Telegraf 作为 InfluxDB v1 或 InfluxDB v2 的代理/中继,建议改用 influxdb__listener 或 influxdb_v2_listener 插件。
引入版本: Telegraf v1.9.0 标签: server 操作系统支持: all
服务输入
此插件是服务输入。普通插件收集由 interval 设置确定的指标。服务插件启动一个服务来监听并等待指标或事件发生。服务插件与普通插件的两个主要区别是:
- 全局或插件特定的
interval设置可能不适用 --test、--test-wait和--once的 CLI 选项可能不会为此插件生成输出
全局配置选项
插件支持其他全局和插件配置设置,用于修改指标、标签和字段,创建别名以及配置插件顺序等任务。更多详情请参阅 CONFIGURATION.md。
配置
# Generic HTTP write listener
[[inputs.http_listener_v2]]
## Address to host HTTP listener on
## can be prefixed by protocol tcp, or unix if not provided defaults to tcp
## if unix network type provided it should be followed by absolute path for unix socket
service_address = "tcp://:8080"
## service_address = "tcp://:8443"
## service_address = "unix:///tmp/telegraf.sock"
## Permission for unix sockets (only available for unix sockets)
## This setting may not be respected by some platforms. To safely restrict
## permissions it is recommended to place the socket into a previously
## created directory with the desired permissions.
## ex: socket_mode = "777"
# socket_mode = ""
## Paths to listen to.
# paths = ["/telegraf"]
## Save path as http_listener_v2_path tag if set to true
# path_tag = false
## HTTP methods to accept.
# methods = ["POST", "PUT"]
## Optional HTTP headers
## These headers are applied to the server that is listening for HTTP
## requests and included in responses.
# http_headers = {"HTTP_HEADER" = "TAG_NAME"}
## HTTP Return Success Code
## This is the HTTP code that will be returned on success
# http_success_code = 204
## maximum duration before timing out read of the request
# read_timeout = "10s"
## maximum duration before timing out write of the response
# write_timeout = "10s"
## Maximum allowed http request body size in bytes.
## 0 means to use the default of 524,288,000 bytes (500 mebibytes)
# max_body_size = "500MB"
## Part of the request to consume. Available options are "body" and
## "query".
# data_source = "body"
## Set one or more allowed client CA certificate file names to
## enable mutually authenticated TLS connections
# tls_allowed_cacerts = ["/etc/telegraf/clientca.pem"]
## Add service certificate and key
# tls_cert = "/etc/telegraf/cert.pem"
# tls_key = "/etc/telegraf/key.pem"
## Minimal TLS version accepted by the server
# tls_min_version = "TLS12"
## Optional username and password to accept for HTTP basic authentication.
## You probably want to make sure you have TLS configured above for this.
# basic_username = "foobar"
# basic_password = "barfoo"
## Optional setting to map http headers into tags
## If the http header is not present on the request, no corresponding tag will be added
## If multiple instances of the http header are present, only the first value will be used
# http_header_tags = {"HTTP_HEADER" = "TAG_NAME"}
## 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"Metrics
指标从 data_source 参数指定的请求部分收集,并根据 data_format 的值进行解析。
示例输出
故障排除
发送行协议
curl -i -XPOST 'https://:8080/telegraf' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'发送 JSON
curl -i -XPOST 'https://:8080/telegraf' --data-binary '{"value1": 42, "value2": 42}'发送查询参数
curl -i -XGET 'https://:8080/telegraf?host=server01&value=0.42'此页面是否有帮助?
感谢您的反馈!
支持和反馈
感谢您成为我们社区的一员!我们欢迎并鼓励您对 Telegraf 和本文档提出反馈和 bug 报告。要获取支持,请使用以下资源
具有年度合同或支持合同的客户可以 联系 InfluxData 支持。