使用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,但是总觉得有些 ...
随机推荐
- 第二阶段——个人工作总结DAY02
1.昨天做了什么:昨天学习了Intent跳转的知识. 2.今天打算做什么:来实现这个功能. 3.遇到的困难:不会用隐式跳转,只会用显式跳转.
- hdu1569-方格取数-二分图网络流
方格取数(2) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- Oracle用户密码认证方式
oracle用户有两种认证方式: 操作系统认证(要求该用户属于本地DBA组,然后通过操作系统认证登录oracle,从而启动数据库) 密码文件认证 oracle使用哪种认证方式决定在于两个参数: 1.r ...
- webmagic 日志使用及maven项目中排除日志依赖
我用的Spring Boot maven构建的工程,默认引入了 <dependency> <groupId>org.springframework.boot</group ...
- ECharts饼状图添加事件
和柱状图添加事件没有区别,详情如下: <!DOCTYPE html> <html> <head> <meta http-equiv="Content ...
- Oracle RAC时间同步(NTP/CTSS)
1.RAC 相关时间同步(time synchronization)Oracle Grid可用两种方式进行时间同步1)基于OS的NTP2)基于clusterware的CTSS(Cluster Time ...
- MSSQL2012中SQL调优(SQL TUNING)时CBO支持和常用的hints
虽然当前各关系库CBO都已经非常先进和智能,但因为关系库理论和实现上的限制,CBO在特殊场景下也会给出次优甚至存在严重性能问题的执行计划,而这些场景中,有一部分只能或适合通过关系库提供的hints来进 ...
- Django之路由分配系统
前言: Django大致工作流程 1.客户端发送请求(get/post)经过web服务器.Django中间件. 到达路由分配系统 2.路由分配系统根据提取 request中携带的的url路径(path ...
- SecureCRT sftp上传文件报错:put: failed to upload xxx 拒绝访问
1.问题 使用sftp上传文件时报错:put: failed to upload xxx 拒绝访问.类似下图所示: 2.原因 造成这个问题的原因可能有两个,一是要上到的那个目录剩余磁盘空间不足,二是打 ...
- Mysql设置自增字段的方法
#int : 字段类型 alter table 表名 modify 字段名 int auto_increment primary key