我正在尝试将Kapacitor与我们的influxdb和collectd设置进行整合。 然而,这似乎并没有工作,我不明白为什么。
Collectd和Influxdb运行正常,我认为Kapacitor可以连接到influxdb。 在kapacitor日志中我看到这个:
[influxdb] 2016/04/22 09:46:42 I! started UDP listener for collectd_db default
这是collectdlogging指标的influxdb数据库的名称。
我创build了以下刻度文件,并将其上传到kapacitor并启用它:
stream .from().measurement('cpu_value') .where(lambda: "type" == "percent") .where(lambda: "type_instance" == "idle") .alert() .crit(lambda: "value" < 100) // Whenever we get an alert write it to a file. .log('/tmp/alerts.log')
这只是一个testing脚本,希望能够产生一些输出。
该脚本已启用:
Name Type Enabled Executing Databases and Retention Policies cpu_tick stream true true ["collectd_db"."default"]
但是,我没有看到任何录音:
[centos@ip-xx-xx-xx-xx tmp]$ kapacitor list recordings ID Type Size Created
“cpu_value”是我的数据库中的有效测量。
这是我在我的错误日志中得到的:
[cpu_alert:stream1] 2016/04/28 13:00:51 E! error while evaluating WHERE expression: name "percent" is undefined. Names in scope: time,value,host,instance,type,type_instance
Kapacitor的作者在这里…
在Kapacitor lambdaexpression式中,单引号与双引号的含义不同。
这个expression式.where(lambda: "type" == "percent")表示只保留数据点的type字段或标记值等于percent字段或标记的值。 根据错误
[cpu_alert:stream1] 2016/04/28 13:00:51 E! 评估WHEREexpression式时出错:名称“percent”未定义。 名称范围:时间,值,主机,实例,types,type_instance
percent字段或标记不存在。
如果要筛选types值等于文字percent点,则需要使用单引号。
.where(lambda: "type" == 'percent')
你的下一个expression式也是如此。
.where(lambda: "type_instance" == 'idle')
如果你愿意,你也可以ANDexpression式一起使用
.where(lambda: "type" == 'percent' AND "type_instance" == 'idle')
当Kapacitorfind多个邻接它的语句将它们转换成引擎盖下的And'edexpression式时。
这里是相关的文档解释报价的差异https://docs.influxdata.com/kapacitor/v0.12/introduction/getting_started/#keep-the-quotes-in-mind
至于为什么没有录音,我不能没有更多的上下文来回答你如何创build一个录音。