问题描述
我在使用 Telegraf processors.regex
时遇到间歇性问题(至少这是我的最佳猜测)
我们正在使用以下电报配置
- /etc/telegraf
- telegraf.conf(仅配置
[[agent]]
) - telegraf.d
- inputs.conf
- 输出.conf
- processors.conf
- telegraf.conf(仅配置
inputs.conf
[[inputs.http]]
urls = [
"http://myserver.mycompany.com:8080/some/rest/api",]
username = "user"
password = "password"
name_override = "monitor"
interval = "600s"
timeout = "3s"
data_format = "json"
json_query = "rows"
json_string_fields = [ "size" ]
tagexclude = ["host"]
outputs.conf
[[outputs.influxdb]]
database = "metrics"
urls = ["http://influxdb.mycompany.com:8086"]
processors.conf
[[processors.converter]]
[processors.converter.fields]
integer = [ "size" ]
# Process order is VERY important here
# Rename the url tag to target
[[processors.rename]]
[[processors.rename.replace]]
tag = "url"
dest = "target"
# Extract the target name from the url (I kNow we just renamed it ... weird)
[[processors.regex]]
[[processors.regex.tags]]
key = "url"
pattern='^http://(?P<target>[^:/]+).+'
replacement = "${target}"
当我跑步时:
telegraf --config telegraf.conf --config-directory telegraf.d --test --debug --input-filter http
我取回了我期望的数据,url
已被替换为正则表达式 target
即
monitor,target=myserver.mycompany.com size=123456789i 1627647959000000000
问题出在我创建的 grafana 图中,我看到的是原始完整 url http://myserver.mycompany.com:8080/some/rest/api
而不是处理后的 myserver.mycompany.com
。另外非常偶尔当我运行电报测试时,我会看到 target
返回完整的未处理 url,即
monitor,target=http://myserver.mycompany.com:8080/some/rest/api size=123456789i 1627647959000000000
数据正确且已处理,即 json 中返回的 size
字符串始终转换为 int,而 url
始终重命名为 target
。
更奇怪的是,我已经将这个配置(在 input.http 中使用不同的 url 取决于区域)推送到许多服务器,其中大多数都按预期工作,只有少数具有这种行为。我已经检查并确保每个服务器上的所有 Telegraf 版本都匹配(1.19.1)并且它们都在 Centos 7 上运行。我也尝试从 influxdb 中清除数据。
在目标中返回 url 的少数服务器总是这样做,即使当我对它们运行 Telegraf 测试时,它们显示主机已被剥离。
关于下一步该往哪里看的任何提示?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)