Documentation

在InfluxDB中对Graphite协议的支持

石墨输入

关于UDP/IP操作系统缓冲区大小的说明

如果您使用的是UDP输入并运行Linux或FreeBSD,请调整您的UDP缓冲区大小限制,see here for more details.

配置

每个 Graphite 输入允许设置绑定地址、目标数据库和协议。如果数据库不存在,它将在输入初始化时自动创建。还可以设置写入一致性级别。如果任何写入操作未满足配置的一致性保证,将会发生错误,数据将不会被索引。默认的一致性级别是 ONE

每个 Graphite 输入还会对接收到的点进行内部批处理,因为批量写入数据库效率更高。默认的 批处理大小 为 1000,待处理批 因子为 5,批处理超时 为 1 秒。这意味着输入将写入最大大小为 1000 的批次,但如果在添加第一个点到批次后的 1 秒内,批次未达到 1000 个点,则无论大小如何,它都会发出该批次。待处理批因子控制一次可以在内存中存在多少个批次,允许输入传输一个批次,同时仍在构建其他批次。

解析指标

Graphite 插件允许使用 Graphite 行协议保存测量值。默认情况下,启用 Graphite 插件将允许您收集指标并使用指标名称作为测量值进行存储。如果您发送一个名为 servers.localhost.cpu.loadavg.10 的指标,它将把完整的指标名称作为测量值存储,而没有提取的标签。

虽然这个默认设置可以工作,但在InfluxDB中存储测量值并不是理想的方法,因为它没有利用标签。对于大型数据集,它的性能也不会最优,因为查询将被迫使用正则表达式,而这在规模上是已知的表现不佳。

要从度量中提取标签,必须配置一个或多个模板将度量解析为标签和测量。

模板

模板允许将度量名称的部分匹配用作存储度量中的标签键。它们的格式与Graphite度量名称相似。分隔符之间的值用作标签键。与Graphite度量部分匹配的标签键的位置用作值。如果没有值,则跳过Graphite部分。

特殊值 measurement 用于定义测量名称。它可以有一个尾随 *,以指示应使用度量的其余部分。如果未指定 measurement,则使用完整的度量名称。

基本匹配

servers.localhost.cpu.loadavg.10

  • 模板: .host.resource.measurement*
  • 输出: measurement =loadavg.10 标签 =host=localhost resource=cpu

多个测量与标签匹配

可以在模板中多次指定measurement以提供对测量名称的更多控制。标签也可以多次匹配。多个值将使用Separator配置变量连接在一起。默认情况下,此值为.

servers.localhost.localdomain.cpu.cpu0.user

  • 模板: .host.host.measurement.cpu.measurement
  • 输出: measurement = cpu.user tags = host=localhost.localdomain cpu=cpu0

由于 . 需要对测量进行双引号查询,您可能希望将其设置为 _ 以简化解析后度量的查询。

servers.localhost.cpu.cpu0.user

  • 分隔符: _
  • 模板: .host.measurement.cpu.measurement
  • 输出: measurement = cpu_user tags = host=localhost cpu=cpu0

添加标签

如果接收到的度量中不存在,可以添加额外的标签。您可以通过在模式后指定它们来添加额外的标签。标签的格式与行协议相同。多个标签用逗号分隔。

servers.localhost.cpu.loadavg.10

  • 模板: .host.resource.measurement* region=us-west,zone=1a
  • 输出: measurement = loadavg.10 tags = host=localhost resource=cpu region=us-west zone=1a

字段

可以通过使用关键字 field 来指定字段键。如果没有指定 field 关键字,则默认情况下度量将写入名为 value 的字段。

字段键也可以通过指定 field* 从输入指标名称的第二个“半部”派生(例如 measurement.measurement.field*)。这不能与“measurement*”一起使用!

可以通过附加字段修改测量指标,例如:

输入:

sensu.metric.net.server0.eth0.rx_packets 461295119435 1444234982
sensu.metric.net.server0.eth0.tx_bytes 1093086493388480 1444234982
sensu.metric.net.server0.eth0.rx_bytes 1015633926034834 1444234982
sensu.metric.net.server0.eth0.tx_errors 0 1444234982
sensu.metric.net.server0.eth0.rx_errors 0 1444234982
sensu.metric.net.server0.eth0.tx_dropped 0 1444234982
sensu.metric.net.server0.eth0.rx_dropped 0 1444234982

使用模板:

sensu.metric.* ..measurement.host.interface.field

成为数据库条目:

> select * from net
name: net
---------
time      host  interface rx_bytes    rx_dropped  rx_errors rx_packets    tx_bytes    tx_dropped  tx_errors
1444234982000000000 server0  eth0    1.015633926034834e+15 0   0   4.61295119435e+11 1.09308649338848e+15  0 0

多个模板

一个模板可能不适用于所有指标。例如,使用多个插件与diamond将生成不同格式的指标。如果您需要使用多个模板,则需要定义一个前缀过滤器,必须在应用模板之前匹配。

筛选器

过滤器的格式与模板类似,但更像通配符表达式。当多个过滤器匹配一个度量时,会选择更具体的那个。过滤器通过在模板之前添加来进行配置。

例如,

servers.localhost.cpu.loadavg.10
servers.host123.elasticsearch.cache_hits 100
servers.host456.mysql.tx_count 10
servers.host789.prod.mysql.tx_count 10
  • servers.* 将匹配所有值
  • servers.*.mysql 将匹配 servers.host456.mysql.tx_count 10
  • servers.localhost.* 将匹配 servers.localhost.cpu.loadavg
  • servers.*.*.mysql 将匹配 servers.host789.prod.mysql.tx_count 10

默认模板

如果未定义模板过滤器,或者您只是想要一个基本模板,您可以定义一个默认模板。这个模板将适用于任何尚未匹配过滤器的指标。

dev.http.requests.200
prod.myapp.errors.count
dev.db.queries.count
  • env.app.measurement* 会创建
    • measurement=requests.200 标签=env=dev,app=http
    • measurement= errors.count 标签=env=prod,app=myapp
    • measurement=queries.count 标签=env=dev,app=db

全局标签

如果您需要将相同的一组标签添加到所有指标中,您可以在插件级别全局定义它们,而不是在每个模板描述中定义。

最小配置

[[graphite]]
  enabled = true
  # bind-address = ":2003"
  # protocol = "tcp"
  # consistency-level = "one"

  ### If matching multiple measurement files, this string will be used to join the matched values.
  # separator = "."

  ### Default tags that will be added to all metrics.  These can be overridden at the template level
  ### or by tags extracted from metric
  # tags = ["region=us-east", "zone=1c"]

  ### Each template line requires a template pattern.  It can have an optional
  ### filter before the template and separated by spaces.  It can also have optional extra
  ### tags following the template.  Multiple tags should be separated by commas and no spaces
  ### similar to the line protocol format.  The can be only one default template.
  # templates = [
  #   "*.app env.service.resource.measurement",
  #   # Default template
  #   "server.*",
 #]

自定义配置

[[graphite]]
   enabled = true
   separator = "_"
   tags = ["region=us-east", "zone=1c"]
   templates = [
     # filter + template
     "*.app env.service.resource.measurement",

     # filter + template + extra tag
     "stats.* .host.measurement* region=us-west,agent=sensu",

     # filter + template with field key
     "stats.* .host.measurement.field",

     # default template. Ignore the first Graphite component "servers"
     ".measurement*",
 ]

两个石墨监听器,UDP 和 TCP,配置

[[graphite]]
  enabled = true
  bind-address = ":2003"
  protocol = "tcp"
  # consistency-level = "one"

[[graphite]]
  enabled = true
  bind-address = ":2004" # the bind address
  protocol = "udp" # protocol to read via
  udp-read-buffer = 8388608 # (8*1024*1024) UDP read buffer size

来自 README 在 GitHub 上的内容。



Flux的未来

Flux 正在进入维护模式。您可以像现在一样继续使用它,而无需对您的代码进行任何更改。

阅读更多

InfluxDB 3 开源版本现已公开Alpha测试

InfluxDB 3 Open Source is now available for alpha testing, licensed under MIT or Apache 2 licensing.

我们将发布两个产品作为测试版的一部分。

InfluxDB 3 核心,是我们新的开源产品。 它是一个用于时间序列和事件数据的实时数据引擎。 InfluxDB 3 企业版是建立在核心基础之上的商业版本,增加了历史查询能力、读取副本、高可用性、可扩展性和细粒度安全性。

有关如何开始的更多信息,请查看: