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

最新文章

  1. Nonblocking I/O and select()
  2. Got the Best Employee of the year 2015 Star Award
  3. Apache2.4部署django出现403 Forbidden错误解决办法
  4. [Head First设计模式]生活中学设计模式——外观模式
  5. OpenStack 云计算基础知识
  6. centos7 docker activemq
  7. python使用cookielib库示例分享
  8. 【五子棋AI循序渐进】关于VCT,VCF的思考和核心代码
  9. .Net魔法堂:史上最全的ActiveX开发教程——自动更新、卸载篇
  10. Android SQLite (三 ) 全面详解(一)
  11. Owin管道与asp.net管道模型
  12. Sublime一些设置
  13. Ini文件操作类
  14. vs2013 cpu占用100%问题
  15. oracle 开发笔记“跨数据库查询复制”
  16. HDU 1885 Key Task 国家压缩+搜索
  17. centos7源码编译安装Ansible详细部署
  18. Android初级教程理论知识(第三章测试&数据存储&界面展现)
  19. 【22】访问者模式(Visitor Pattern)
  20. 使用mockserver来进行http接口mock

热门文章

  1. 5月13 PDO数据访问抽象层
  2. Hadoop---18/06/03 20:15:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable starting yarn daemons
  3. iOS 强大第三方资源库
  4. Django之路由分配系统
  5. 【转】[总结]vue开发常见知识点及问题资料整理(持续更新)
  6. Web应用的统一异常处理(二十四)
  7. 未能加载文件或程序集“Oracle.DataAccess”或它的某一个 依赖项。如何解决?
  8. python 利用turtle库绘制七段数码管的方式,绘制当前事件(时分秒00:00:00)
  9. sqlalchemy tree 树形分类 无限极分类的管理。预排序树,左右值树。sqlalchemy-mptt
  10. :命令模式:Command