使用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
使用json通过telegraf生成metrics(摘自telegraf github文档)的更多相关文章
- 使用Swashbuckle.AspNetCore生成.NetCore WEBAPI的接口文档
一.问题 使用Swashbuckle.AspNetCore生成.NetCore WEBAPI的接口文档的方法 二.解决方案 参考文章:https://docs.microsoft.com/zh-cn/ ...
- .NET项目工程生成一份项目帮助文档chm--Sandcastle工具
Sandcastle的,由Microsoft创建的,是从创建MSDN风格的文档中使用的工具.NET程序集和关联的XML注释文件.目前的版本是 2010年6月发布.这是命令行并没有GUI前端,项目管理功 ...
- 用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档
博客搬到了fresky.github.io - Dawei XU,请各位看官挪步.最新的一篇是:用Swashbuckle给ASP.NET Core的项目自动生成Swagger的API帮助文档.
- 使用Sandcastle工具为.NET项目工程生成一份项目帮助文档chm
Sandcastle的,由Microsoft创建的,是从创建MSDN风格的文档中使用的工具.NET程序集和关联的XML注释文件.目前的版本是2010年6月发布.这是命令行并没有GUI前端,项目管理功能 ...
- 生成基于Maven的项目文档站点
在Maven中,可以使用“mvn site”,为您的项目信息生成文档站点. mvn site 生成的网站是在项目的“target/site”文件夹中. mvn site 示例 请参见通过“mvn si ...
- Linux内核官方文档atomic_ops.txt【摘自Linux 内核文档】
摘自Linux内核文档 Documentation/atomic_ops.txt,不是本人原创 Semantics and Behavior of Atomic and Bitmask Operati ...
- maven 学习---生成基于Maven的项目文档站点
在Maven中,可以使用“mvn site”,为您的项目信息生成文档站点. mvn site 生成的网站是在项目的“target/site”文件夹中. mvn site 示例 请参见通过“mvn si ...
- java.lang.NoSuchFieldError: RAW_XML_FILE_HEADER,调用XWPFTemplate动态合并生成一个新的docx文档时报错
在使用 org.apache.poi 对office文件 根据表单内容和已上次的附件 动态合并成一个新的文档时,本地调试完全ok 但是发布倒Linux环境上就老是报这个错误java.lang.NoS ...
- 使用Doxygen工具生成Cocos2D-x 2.1.0文档
Doxygen是一种开源跨平台的工具,其功能是从程序源代码中抽取类.方法.成员的注释,形成一个和源代码配套的API(Application Programming Interface,应用程序编程接口 ...
- 生成自己的Webapi帮助文档(一)
最近Webapi接口的开发刚刚进入尾声,随之而来的是让用户知道接口的详细参数信息,看过淘宝的接口文档,但网上没找到他的实现方式 虽然新建Webapi时C#也会给你一个帮助文档的Area,但是总觉得有些 ...
随机推荐
- element中使用button会刷新一遍页面
会刷新: <el-form-item> <button @click="register('form')" class="submitBtn&qu ...
- python-day79--知识回顾
内容回顾: 1. 可迭代对象.迭代器.生成器是什么?什么区别? 可迭代对象,含有__iter__,返回一个迭代器 迭代器,含有__iter__,__next__方法 生成器,yield,__next_ ...
- CF-339D-线段树
http://codeforces.com/problemset/problem/339/D 给出一个序列.每次更改其中一个值然后询问序列的f(),序列的f()定义为: 每相邻两个元素按位或得到长度减 ...
- HDU-6395-矩阵快速幂
Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total ...
- 兼容IE8的video写法
<video width="100%" height="515px" controls preload> <source src=" ...
- Grafana安装配置介绍
一.Grafana介绍 Grafana是一个可视化面板(Dashboard),有着非常漂亮的图表和布局展示,功能齐全的度量仪表盘和图形编辑器,支持Graphite.zabbix.InfluxDB.Pr ...
- Git Diff 格式分析
参考: http://stackoverflow.com/questions/2529441/how-to-read-the-output-from-git-diff https://www.git- ...
- C# 语法特性 - 匿名方法(C#2.0)
概述 匿名方法的本质其实就是委托. 编译后会生成委托对象,生成方法,然后把方法装入委托对象,最后赋值给声明的委托变量. (匿名方法可以省略参数:编译的时候会自动为这个方法按照委托签名的参数添加参数) ...
- server library[unbound] 服务未绑定解决办法
情景如下:
- [CodeForces - 447E] E - DZY Loves Fibonacci Numbers
E DZY Loves Fibonacci Numbers In mathematical terms, the sequence Fn of Fibonacci numbers is define ...