使用json通過telegraf生成metrics(摘自telegraf github文件)
JSON:
The JSON data format flattens JSON into metric fields. NOTE: Only numerical values are converted to fields, and they are converted into a float. strings are ignored unless specified as a tag_key (see below).
So for example, this JSON:
{
“a”: 5,
“b”: {
“c”: 6
},
“ignored”: “I’m a string”
}
Would get translated into fields of a measurement:
myjsonmetric a=5,b_c=6
The measurement name is usually the name of the plugin, but can be overridden using the name_override config option.
JSON Configuration:
The JSON data format supports specifying “tag keys”. If specified, keys will be searched for in the root-level of the JSON blob. If the key(s) exist, they will be applied as tags to the Telegraf metrics.
For example, if you had this configuration:
[[inputs.exec]]
## Commands array
commands = [“/tmp/test.sh”, “/usr/bin/mycollector –foo=bar”]
## measurement name suffix (for separating different commands)
name_suffix = “_mycollector”
## 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 = “json”
## List of tag names to extract from top-level of JSON server response
tag_keys = [
“my_tag_1”,
“my_tag_2”
]
with this JSON output from a command:
{
“a”: 5,
“b”: {
“c”: 6
},
“my_tag_1”: “foo”
}
Your Telegraf metrics would get tagged with “my_tag_1”
exec_mycollector,my_tag_1=foo a=5,b_c=6
If the JSON data is an array, then each element of the array is parsed with the configured settings. Each resulting metric will be output with the same timestamp.
For example, if the following configuration:
[[inputs.exec]]
## Commands array
commands = [“/usr/bin/mycollector –foo=bar”]
## measurement name suffix (for separating different commands)
name_suffix = “_mycollector”
## 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 = “json”
## List of tag names to extract from top-level of JSON server response
tag_keys = [
“my_tag_1”,
“my_tag_2”
]
with this JSON output from a command:
[
{
“a”: 5,
“b”: {
“c”: 6
},
“my_tag_1”: “foo”,
“my_tag_2”: “baz”
},
{
“a”: 7,
“b”: {
“c”: 8
},
“my_tag_1”: “bar”,
“my_tag_2”: “baz”
}
]
Your Telegraf metrics would get tagged with “my_tag_1” and “my_tag_2”
exec_mycollector,my_tag_1=foo,my_tag_2=baz a=5,b_c=6
exec_mycollector,my_tag_1=bar,my_tag_2=baz a=7,b_c=8
相關文章
- 通過 Telegraf + InfluxDB + Grafana 快速搭建監控體系的詳細步驟UXGrafana
- Telegraf+Influxdb+Grafana構建監控平臺UXGrafana
- 一文搞懂指標採集利器 Telegraf指標
- 快速搭建grafana+influxdb+telegraf,以及常見問題GrafanaUX
- Telegraf+Influxdb+Grafana自動化運維監控UXGrafana運維
- RedMonk分析師包括Flux查詢語言和Telegraf指標代理等UX指標
- 在Telegraf上報的監控資料中新增固定的標籤列
- 使用dumi生成react元件庫文件併發布到github pagesReact元件Github
- SpringBoot介面 - 如何生成介面文件之非侵入方式(通過註釋生成)Smart-Doc?Spring Boot
- 使用apidoc文件神器,快速生成api文件API
- 【Python】生成html文件-使用dominatePythonHTML
- 通過Go來分析和建立JSONGoJSON
- 拯救懶癌文件君 - VuePress + Travis CI + Github Pages 自動線上生成文件VueGithub
- php 透過 JSON RPC 與 golang 通訊PHPJSONRPCGolang
- 通過VuePress管理專案文件(一)Vue
- 通過VuePress管理專案文件(二)Vue
- Go語言使用swagger生成介面文件GoSwagger
- 使用工具生成 Protocol 易讀文件Protocol
- Flutter json解析json_serializable的使用及自動化生成模板FlutterJSON
- 高效生成JSON串——json-genJSON
- 通過GitHub Blame深入分析Redux原始碼GithubRedux原始碼
- 通過GitHub Action自動部署Maven專案GithubMaven
- JSON Editor 中文文件JSON
- 介面文件生成
- 以實現MongoDB副本集狀態的監控為例,看Telegraf系統中Exec輸入外掛如何編寫部署MongoDB
- 通過類名動態生成物件物件
- Intellij IDEA 通過資料庫生成 POJOIntelliJIdea資料庫POJO
- Laravel API 文件生成器生成指定的 API 文件LaravelAPI
- 使用golang編寫prometheus metrics exporterGolangPrometheusExport
- 通過git shell 在Github上傳本地專案Github
- 使用【APIDOC】生成JavaWeb的API文件(HTML,MarkDown,PDF)APIJavaWebHTML
- java通過url呼叫遠端介面返回json資料JavaJSON
- ajax與json通過程式碼的簡單應用JSON
- 如何通過閱讀文件,構建概念模型?模型
- github或gitee等dev cloud使用actions通過yml配置實現自動化部署GithubGiteedevCloud
- ABAP文件生成工具
- 介面文件生成工具
- Java 生成 PDF 文件Java