文档文档

Form URL-encoded 输入数据格式

使用 form-urlencoded 数据格式解析 application/x-www-form-urlencoded 数据,例如 HTTP 查询字符串。

一个常见的用例是将其与 http_listener_v2 输入插件配对,以解析 HTTP 请求正文或查询参数。

配置

[[inputs.http_listener_v2]]
  ## Address and port to host HTTP listener on
  service_address = ":8080"

  ## Part of the request to consume.  Available options are "body" and
  ## "query".
  data_source = "body"

  ## 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 = "form_urlencoded"

  ## Array of key names which should be collected as tags.
  ## By default, keys with string value are ignored if not marked as tags.
  form_urlencoded_tag_keys = ["tag1"]

示例

基本解析

配置

[[inputs.http_listener_v2]]
  name_override = "mymetric"
  service_address = ":8080"
  data_source = "query"
  data_format = "form_urlencoded"
  form_urlencoded_tag_keys = ["tag1"]

请求

curl -i -XGET 'http://localhost:8080/telegraf?tag1=foo&field1=0.42&field2=42'

输出

mymetric,tag1=foo field1=0.42,field2=42

此页是否对您有帮助?

感谢您的反馈!


Flux 的未来

Flux 即将进入维护模式。您可以继续像现在这样使用它,而无需更改任何代码。

阅读更多

现已全面上市

InfluxDB 3 Core 和 Enterprise

快速启动。更快扩展。

获取更新

InfluxDB 3 Core 是一个开源、高速的最新数据引擎,可实时收集和处理数据,并将其持久化到本地磁盘或对象存储。InfluxDB 3 Enterprise 基于 Core 的基础构建,增加了高可用性、读取副本、增强的安全性以及数据压缩,从而实现更快的查询和优化的存储。InfluxDB 3 Enterprise 的免费层可供非商业家庭或业余爱好者使用。

有关更多信息,请查看