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

使用json通过telegraf生成metrics(摘自telegraf github文档)的更多相关文章

  1. 使用Swashbuckle.AspNetCore生成.NetCore WEBAPI的接口文档

    一.问题 使用Swashbuckle.AspNetCore生成.NetCore WEBAPI的接口文档的方法 二.解决方案 参考文章:https://docs.microsoft.com/zh-cn/ ...

  2. .NET项目工程生成一份项目帮助文档chm--Sandcastle工具

    Sandcastle的,由Microsoft创建的,是从创建MSDN风格的文档中使用的工具.NET程序集和关联的XML注释文件.目前的版本是 2010年6月发布.这是命令行并没有GUI前端,项目管理功 ...

  3. 用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档

    博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档.

  4. 使用Sandcastle工具为.NET项目工程生成一份项目帮助文档chm

    Sandcastle的,由Microsoft创建的,是从创建MSDN风格的文档中使用的工具.NET程序集和关联的XML注释文件.目前的版本是2010年6月发布.这是命令行并没有GUI前端,项目管理功能 ...

  5. 生成基于Maven的项目文档站点

    在Maven中,可以使用“mvn site”,为您的项目信息生成文档站点. mvn site 生成的网站是在项目的“target/site”文件夹中. mvn site 示例 请参见通过“mvn si ...

  6. Linux内核官方文档atomic_ops.txt【摘自Linux 内核文档】

    摘自Linux内核文档 Documentation/atomic_ops.txt,不是本人原创 Semantics and Behavior of Atomic and Bitmask Operati ...

  7. maven 学习---生成基于Maven的项目文档站点

    在Maven中,可以使用“mvn site”,为您的项目信息生成文档站点. mvn site 生成的网站是在项目的“target/site”文件夹中. mvn site 示例 请参见通过“mvn si ...

  8. java.lang.NoSuchFieldError: RAW_XML_FILE_HEADER,调用XWPFTemplate动态合并生成一个新的docx文档时报错

    在使用 org.apache.poi 对office文件  根据表单内容和已上次的附件 动态合并成一个新的文档时,本地调试完全ok 但是发布倒Linux环境上就老是报这个错误java.lang.NoS ...

  9. 使用Doxygen工具生成Cocos2D-x 2.1.0文档

    Doxygen是一种开源跨平台的工具,其功能是从程序源代码中抽取类.方法.成员的注释,形成一个和源代码配套的API(Application Programming Interface,应用程序编程接口 ...

  10. 生成自己的Webapi帮助文档(一)

    最近Webapi接口的开发刚刚进入尾声,随之而来的是让用户知道接口的详细参数信息,看过淘宝的接口文档,但网上没找到他的实现方式 虽然新建Webapi时C#也会给你一个帮助文档的Area,但是总觉得有些 ...

随机推荐

  1. 【Java】【3】BeanUtils.copyProperties();将一个实体类的值复制到另外一个实体类

    正文: a,b为对象 BeanUtils.copyProperties(a,  b); 1,BeanUtils是org.springframework.beans.BeanUtils, a拷贝到b 2 ...

  2. vijos1448校门外的树

    描述 校门外有很多树,有苹果树,香蕉树,有会扔石头的,有可以吃掉补充体力的……如今学校决定在某个时刻在某一段种上一种树,保证任一时刻不会出现两段相同种类的树,现有两个操作:K=1,K=1,读入l.r表 ...

  3. Let's Encrypt 免费通配符 SSL 证书申请教程——但是也需要email,域名所有权等,如果是黑产用的话会这样用吗?会不会暴露自己身份???

    Let's Encrypt 免费通配符 SSL 证书申请教程 from:https://blog.csdn.net/English0523/article/details/79608464 2018 ...

  4. PHP配置方法

    由于php是一个zip文件(非install版),安装较为简单,解压就行.把解压的 php5.2.1-Win32重命名为 php5.并复制到C盘目录下.即安装路径为 c:\php5 1 找到php目录 ...

  5. linux nginx 添加到全局变量中(环境变量)

    ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/ /usr/local/bin/就是环境变量目录

  6. CSS3 的box-shadow进阶之 - 动画篇 - 制作辐射动画

    本篇文章是上一篇讲box-shadow基础知识的延伸,建议先花几分钟阅读那篇文章,点击阅读,再来看这篇. 除了box-shadow属性知识外,制作动画,还需要对CSS3的animation, @key ...

  7. chrome console 阻止 Navigated to

    阻止如图 chrome 如图信息

  8. Uva 10635 - Prince and Princess 问题转化,元素互不相同(在自身序列中独特)的两个数列的LCS,LIS 难度: 2

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  9. python 笔记数据类型

    python基础: 采用缩进方式     4个空格的缩进 大小写敏感 数据类型和变量 数据类型 计算机顾名思义就是可以做数学计算的机器,因此,计算机程序理所当然地可以处理各种数值,但是,计算机能处理的 ...

  10. PC/FORTH 编辑程序

    body, table{font-family: 微软雅黑} table{border-collapse: collapse; border: solid gray; border-width: 2p ...