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. DVWA--XSS解题过程

    XSS概念:通常指黑客通过HTML注入纂改了网页,插入恶意脚本,从而在用户浏览网页时,控制用户浏览器的一种攻击. XSS有三种: 反射型xss:只是简单地把用户输入的数据反射给浏览器,简单来说,黑客往 ...

  2. 十六、JAVA基础(堆和栈)

    一.堆和栈 堆和栈都是JAVA中的存储结构,也就是说,都是内存中存放数据的地方. 1.堆:(存放由new创建的对象和数组) 引用类型的变量,内存分配一般在堆上或者常量池(字符串常量,基本数据类型常量) ...

  3. Thinkphp5 Nginx Pathinfo配置

    server { listen ; server_name sui.com; root /tmmee/sad.cn/public; index index.php index.html index.h ...

  4. vue-router 按需加载

    vue的单页面(SPA)项目,必然涉及路由按需的问题.以前我们是这么做的 //require.ensure是webpack里面的,这样做会将单独拉出来作为一个chunk文件 const Login = ...

  5. 百度AI认为最漂亮的中国女星是----范冰冰

    一.程序说明 1.1 程序说明 之前写调用百度AI接口的程序,然后刷到了两条明星的新闻,就想到了写个给明星颜值排下名的程序. 程序的关键点是两个,第一个是百度AI接口的调用这点其实直接使用早前实现的类 ...

  6. xinetd黑/白名单配置教程(以telnet为例)

    对于诸如telnet等托管于xinetd的服务,当请求到来时由于是通过xinetd进行通知,所以可以直接在xinetd上配置白名单允许和拒绝哪些ip连接服务. 本文主要参考xinetd.conf的ma ...

  7. windows安装weblogic并集成到eclipse

    1.下载 java是跨平台的,所以windows下载和linux一样的jar文件安装就行,当然也可以使用windows安装程序来安装. (weblogic下载不需要购买--oracle产品都是补丁和技 ...

  8. python格式化日期

    #!/usr/bin/python # -*- coding: UTF-8 -*- import time import calendar """ 时间元组(年.月.日. ...

  9. 微信小程序生成二维码

    微信小程序客户端生成二维码的方法, 请参考这里: https://github.com/demi520/wxapp-qrcode  代码片段如下: const QR = require(". ...

  10. JQuery操作input

    // 不可编辑 $("#id").attr("disabled","disabled"); $("#id").remov ...