collectd java_collectd 的数据如何映射到influxdb

collectd 的数据如何映射到influxdb

本文将使用collectdctl 向influxdb 发送数据, 同时介绍collectd 的数据是如何映射到influxdb 中(创建measurements,series)

配置influxdb

[[collectd]]

enabled = true

bind-address = "127.0.0.1:25826"

database = "collectd"

retention-policy = ""

# typesdb

typesdb = "/usr/local/Cellar/collectd/5.8.0/share/collectd/types.db"

配置collected

LoadPlugin cpu

LoadPlugin memory

LoadPlugin network

LoadPlugin unixsock

查看influxdb 确认collectd push 数据

collectdctl listval

localhost/load/load

localhost/memory/memory-active

localhost/memory/memory-free

localhost/memory/memory-inactive

localhost/memory/memory-wired

localhost/interface-en0/if_errors

localhost/interface-en0/if_octets

influx -database 'collectd' -execute 'show series'

load_longterm,host=localhost,type=load

load_midterm,host=localhost,type=load

load_shortterm,host=localhost,type=load

memory_value,host=localhost,type=memory,type_instance=active

memory_value,host=localhost,type=memory,type_instance=free

memory_value,host=localhost,type=memory,type_instance=inactive

memory_value,host=localhost,type=memory,type_instance=wired

interface_rx,host=localhost,instance=en0,type=if_errors

interface_rx,host=localhost,instance=en0,type=if_octets

interface_tx,host=localhost,instance=en0,type=if_errors

interface_tx,host=localhost,instance=en0,type=if_octets

cat /usr/local/Cellar/collectd/5.8.0/share/collectd/types.db

load shortterm:GAUGE:0:5000, midterm:GAUGE:0:5000, longterm:GAUGE:0:5000

memory value:GAUGE:0:281474976710656

if_errors rx:DERIVE:0:U, tx:DERIVE:0:U

if_octets rx:DERIVE:0:U, tx:DERIVE:0:U

collectdb 用identifier 来描述一条数据,identifier相当与KV数据库的Key。

identifier 格式如下

[/][-]/[-]

collectdb用types.db的映射关系来描述Value 的格式

identifier 的type 一定要在types.db中 找到否则报错

1. localhost/load/load

type:load

types.db 定义

load shortterm:GAUGE:0:5000, midterm:GAUGE:0:5000, longterm:GAUGE:0:5000

2. localhost/interface-en0/if_octets

type: if_octets

types.db 定义

if_octets rx:DERIVE:0:U, tx:DERIVE:0:U

3. localhost/memory/memory-free

type: memory (free 并不是type)

memory value:GAUGE:0:281474976710656

8. 其实通过4,5,6 的数据我们很容易看数collectd 到influxdb的映射关系

1. localhost/load/load

plugin: load

type: load

typeValue: shortterm, midterm, longterm

映射到influxdb

measurements: load_shortterm load_midterm load_longterm

tags: host=localhost,type=load

2. localhost/memory/memory-active

plugin: memory

type: memory

typeValue: Value

映射到influxdb

measurements: memory_value

tags: host=localhost,type=memory,type_instance=active

3. localhost/interface-en0/if_octets

plugin: interface

type: if_octets

typeValue: rx, tx

measurements: interface_rx, interface_tx

tags: host=localhost,instance=en0,type=if_octets

9. collectd 的 identifier

[/][-]/[-]

的`plugin_typeValue`构成了influxdb的measurements

tags:hostname=, instance=, type=, type_instance=

由于 plugin_instance , type_instace 是可选的

所以collectd 倒入influxdb的数据tags 至少由hostname, type

10. 练习

1. collectdctl putval localhost/xxx/load N:111

influxdb 会新建xxx_longterm, xxx_shortterm, xxx_midterm measurement

tag hostname=localhost,type=load

2. collectdctl putval localhost/xxx/if_octets N:1:100

influxdb 会新建xxx_rx, xxx_tx measurement

3.echo "test running:GAUGE:0:U" >> /usr/local/Cellar/collectd/5.8.0/share/collectd/types.db

collectdct putval localhost xxx/test N:1000

influxdb 会新建xxx_test measurement

```

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值