influxdb中,series是一个很重要的概念,它是retentionPolicy、measurement、tag set相同的集合,包含了监控对象的元数据信息,series的数量=RP*measurement*tag set。

一般来讲,监控对象稳定后,series基本是固定的;influxdb将series放在内存作为索引,加快了数据查询,这使得series的数量不能太大,否则influxdb内存会被撑爆,默认单个database内series限制为<100W个。

// influxdb.conf
# The maximum series allowed per database before writes are dropped.  This limit can prevent
# high cardinality issues at the database level.  This limit can be disabled by setting it to
# 0.
# max-series-per-database = 1000000

series集合的例子:每一行代表一个series

序号retention policymeasuermenttag set
1autogencpu.used.percentlocation=sh,node=node1001
2autogencpu.used.percentlocation=bj,node=node3001
3autogencpu.used.percentlocation=sz,node=5001

查询series信息

查询所有的series
# influx -execute 'show series  on opsultra'

统计所有的series数量
# influx -execute 'show series  on opsultra' |wc -l

将series导出到csv
# influx -execute 'show series  on opsultra' -format 'csv' > /tmp/series.csv

查询series cardinality

cardinality反应了series的维度,即不同的series的数量:

查询series的维度
# influx -execute 'show series cardinality on opsultra'

将series的维度导出到csv: 按measurement进行cardinality进行统计
# influx -execute 'show series exact cardinality on opsultra' -format 'csv' > /tmp/series.csv

cardinality的计算

某个measuremnt的cardinality值 = distinct(tag1-value) * distinct(tag2-value) * ...
也就说所有tag可能取值的乘积。

When influxdb counts cardinality in a Measurement, 
it counts the combination of all tags. 

For example, if my measurement has the following tags: 
3 os, 200 devices, 3 browsers, 
then the cardinality is > 3x200x3=1800. 

参考:
https://jasper-zhang1.gitbook...
https://docs.influxdata.com/i...
https://puyuan.github.io/infl...


a朋
63 声望39 粉丝

引用和评论

0 条评论