文档文档

Dropwizard 输入数据格式

使用 dropwizard 输入数据格式来解析 JSON Dropwizard 的单个 dropwizard 指标注册表的表示形式到 Telegraf 指标中。默认情况下,标签从指标名称中解析,就像它们是实际的 InfluxDB 行协议键 (measurement<,tag_set>) 一样,这可以通过定义自定义的 模板模式 来覆盖。支持所有字段值类型,stringnumberboolean

配置

[[inputs.file]]
  files = ["example"]

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

  ## Used by the templating engine to join matched values when cardinality is > 1
  separator = "_"

  ## Each template line requires a template pattern. It can have an optional
  ## filter before the template and separated by spaces. It can also have optional extra
  ## tags following the template. Multiple tags should be separated by commas and no spaces
  ## similar to the line protocol format. There can be only one default template.
  ## Templates support below format:
  ## 1. filter + template
  ## 2. filter + template + extra tag(s)
  ## 3. filter + template with field key
  ## 4. default template
  ## By providing an empty template array, templating is disabled and measurements are parsed as InfluxDB line protocol keys (measurement<,tag_set>)
  templates = []

  ## You may use an appropriate [gjson path](https://github.com/tidwall/gjson#path-syntax)
  ## to locate the metric registry within the JSON document
  # dropwizard_metric_registry_path = "metrics"

  ## You may use an appropriate [gjson path](https://github.com/tidwall/gjson#path-syntax)
  ## to locate the default time of the measurements within the JSON document
  # dropwizard_time_path = "time"
  # dropwizard_time_format = "2006-01-02T15:04:05Z07:00"

  ## You may use an appropriate [gjson path](https://github.com/tidwall/gjson#path-syntax)
  ## to locate the tags map within the JSON document
  # dropwizard_tags_path = "tags"

  ## You may even use tag paths per tag
  # [inputs.exec.dropwizard_tag_paths]
  #   tag1 = "tags.tag1"
  #   tag2 = "tags.tag2"

示例

dropwizard 指标注册表的典型 JSON

{
    "version": "3.0.0",
    "counters" : {
        "measurement,tag1=green" : {
            "count" : 1
        }
    },
    "meters" : {
        "measurement" : {
            "count" : 1,
            "m15_rate" : 1.0,
            "m1_rate" : 1.0,
            "m5_rate" : 1.0,
            "mean_rate" : 1.0,
            "units" : "events/second"
        }
    },
    "gauges" : {
        "measurement" : {
            "value" : 1
        }
    },
    "histograms" : {
        "measurement" : {
            "count" : 1,
            "max" : 1.0,
            "mean" : 1.0,
            "min" : 1.0,
            "p50" : 1.0,
            "p75" : 1.0,
            "p95" : 1.0,
            "p98" : 1.0,
            "p99" : 1.0,
            "p999" : 1.0,
            "stddev" : 1.0
        }
    },
    "timers" : {
        "measurement" : {
            "count" : 1,
            "max" : 1.0,
            "mean" : 1.0,
            "min" : 1.0,
            "p50" : 1.0,
            "p75" : 1.0,
            "p95" : 1.0,
            "p98" : 1.0,
            "p99" : 1.0,
            "p999" : 1.0,
            "stddev" : 1.0,
            "m15_rate" : 1.0,
            "m1_rate" : 1.0,
            "m5_rate" : 1.0,
            "mean_rate" : 1.0,
            "duration_units" : "seconds",
            "rate_units" : "calls/second"
        }
    }
}

将被翻译成 4 种不同的指标

measurement,metric_type=counter,tag1=green count=1
measurement,metric_type=meter count=1,m15_rate=1.0,m1_rate=1.0,m5_rate=1.0,mean_rate=1.0
measurement,metric_type=gauge value=1
measurement,metric_type=histogram count=1,max=1.0,mean=1.0,min=1.0,p50=1.0,p75=1.0,p95=1.0,p98=1.0,p99=1.0,p999=1.0
measurement,metric_type=timer count=1,max=1.0,mean=1.0,min=1.0,p50=1.0,p75=1.0,p95=1.0,p98=1.0,p99=1.0,p999=1.0,stddev=1.0,m15_rate=1.0,m1_rate=1.0,m5_rate=1.0,mean_rate=1.0

您还可以从任何 JSON 文档中解析 dropwizard 注册表,该文档在某些内部字段中包含 dropwizard 注册表。例如,要解析以下 JSON 文档

{
    "time" : "2017-02-22T14:33:03.662+02:00",
    "tags" : {
        "tag1" : "green",
        "tag2" : "yellow"
    },
    "metrics" : {
        "counters" : {
            "measurement" : {
                "count" : 1
            }
        },
        "meters" : {},
        "gauges" : {},
        "histograms" : {},
        "timers" : {}
    }
}

并将其翻译成

measurement,metric_type=counter,tag1=green,tag2=yellow count=1 1487766783662000000

您只需使用以下附加配置属性

dropwizard_metric_registry_path = "metrics"
dropwizard_time_path = "time"
dropwizard_time_format = "2006-01-02T15:04:05Z07:00"
dropwizard_tags_path = "tags"
## tag paths per tag are supported too, eg.
#[inputs.yourinput.dropwizard_tag_paths]
#  tag1 = "tags.tag1"
#  tag2 = "tags.tag2"

此页是否对您有帮助?

感谢您的反馈!


Flux 的未来

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

阅读更多

InfluxDB 3 开源版本现已公开发布 Alpha 版

InfluxDB 3 开源版本现已可用于 alpha 测试,根据 MIT 或 Apache 2 许可获得许可。

我们正在发布两个产品作为 alpha 版本的一部分。

InfluxDB 3 Core 是我们新的开源产品。它是用于时间序列和事件数据的最新数据引擎。InfluxDB 3 Enterprise 是一个商业版本,它建立在 Core 的基础上,增加了历史查询功能、读取副本、高可用性、可扩展性和细粒度的安全性。

有关如何开始使用的更多信息,请查看