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. Linux上部署多个tomcat端口设置

    在Linux上部署多个tomcat主要是防止端口冲突的问题, tomcat服务器需配置三个端口才能启动,安装时默认启用了这三个端口,当要运行多个tomcat服务时需要修改这三个端口,不能相同.端口一: ...

  2. poj 1080 基因组(LCS)

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19376   Accepted:  ...

  3. CRM WEB UI 03搜索界面新建按钮调到详细界面

    这个和上一个差不多,简单说下: 1.因为NEW是在创建搜索界面的时候加的,所以此时只需在结果界面重定义NEW事件: method EH_ONNEW. OP_NEW( ). endmethod. 2.结 ...

  4. 78. Subsets C++回溯法

    本题还是基本的回溯法.就是回溯函数的参数选择上要花点心思! class Solution { public: void backTrack(vector<int> ans, vector& ...

  5. Django之信号和序列化

    前言 Django的信号要从一张抽象图和一个需求说起: 赛道:Django 赛车:http请求 基础设施:Django设置的信号 一.Django内置信号类型 1.既然赛道上有各种基础设置,那么Dja ...

  6. PHP指针相关函数

    1.each each — 返回数组中当前的键/值对并将数组指针向前移动一步 $arr = array("one", "two", "three&qu ...

  7. 随机数类Random

    我们来学习下,用来产生随机数的类Random,它也属于引用数据类型. 这个Random类,它可以产生多种数据类型的随机数,在这里我们主要介绍生成整数与小数的方式. l  方法简介 public int ...

  8. QuickStart系列:docker部署之PostgreSQL

    mysql --> mariadb --> postgresql 官网简介 https://www.postgresql.org/ 使用的镜像名称 centos/postgresql-96 ...

  9. RabbitMQ fanout类型的Exchange

    就目前来说,Exchange是与消息发送端有关的,因为它可以指定将消息发送到哪个或哪些队列中. 本篇文章介绍的fanout类型就是指定将消息群发到与Exchange绑定的所有队列中. fanout这个 ...

  10. vue-13-插件

    Vue.js 的插件应当有一个公开方法 install MyPlugin.install = function (Vue, options) { // 1. 添加全局方法或属性 Vue.myGloba ...