使用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+telegraf 伺服器監控UXGrafana伺服器
- Telegraf+Influxdb+Grafana構建監控平臺UXGrafana
- 快速搭建grafana+influxdb+telegraf,以及常見問題GrafanaUX
- Telegraf+Influxdb+Grafana自動化運維監控UXGrafana運維
- 在Telegraf上報的監控資料中新增固定的標籤列
- RedMonk分析師包括Flux查詢語言和Telegraf指標代理等UX指標
- 使用dumi生成react元件庫文件併發布到github pagesReact元件Github
- 如何通過github提升自己Github
- 文件模型(JSON)使用介紹模型JSON
- SpringBoot介面 - 如何生成介面文件之非侵入方式(通過註釋生成)Smart-Doc?Spring Boot
- 使用apidoc文件神器,快速生成api文件API
- golang通過反射使用json字串呼叫struct的指定方法及返回json結果Golang反射JSON字串Struct
- Cocos Creator 玩家輸入事件(摘自官方文件)事件
- 拯救懶癌文件君 - VuePress + Travis CI + Github Pages 自動線上生成文件VueGithub
- 通過shell解析dump生成parfile
- 通過Go來分析和建立JSONGoJSON
- 通過VuePress管理專案文件(二)Vue
- 通過VuePress管理專案文件(一)Vue
- Data Guard的三種保護模式(摘自官方文件)模式
- Linux 通過命令列解析JSON字串Linux命令列JSON字串
- 使用工具生成 Protocol 易讀文件Protocol
- 【Python】生成html文件-使用dominatePythonHTML
- 通過GitHub Blame深入分析Redux原始碼GithubRedux原始碼
- 通過GitHub Action自動部署Maven專案GithubMaven
- Install VMware Tools in a Linux Guest(摘自vmware幫助文件)Linux
- 以實現MongoDB副本集狀態的監控為例,看Telegraf系統中Exec輸入外掛如何編寫部署MongoDB
- 介面文件生成
- 通過類名動態生成物件物件
- mysql通過ssl的方式生成祕鑰MySql
- php 透過 JSON RPC 與 golang 通訊PHPJSONRPCGolang
- Oracle 通過儲存過程來生成CSV檔案Oracle儲存過程
- 使用GhostDoc為程式碼生成註釋文件
- Laravel API 文件生成器生成指定的 API 文件LaravelAPI
- 通過git shell 在Github上傳本地專案Github
- 通過gitHub獲取vlc-Android原始碼GithubAndroid原始碼
- 使用golang編寫prometheus metrics exporterGolangPrometheusExport