我的电报出现间歇性问题processors.regex
(至少这是我的最佳猜测)
我们正在使用以下电报配置
- /etc/telegraf
- telegraf.conf(仅配置
[[agent]]
) - 电报
- 输入.conf
- 输出.conf
- 处理器.conf
- telegraf.conf(仅配置
输入.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"]
输出.conf
[[outputs.influxdb]]
database = "metrics"
urls = ["http://influxdb.mycompany.com:8086"]
处理器.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 图中,我看到的是原始完整 urlhttp://myserver.mycompany.com:8080/some/rest/api
而不是处理后的myserver.mycompany.com
. 当我运行电报测试时,我也会看到target
返回完整的未处理网址,即
monitor,target=http://myserver.mycompany.com:8080/some/rest/api size=123456789i 1627647959000000000
数据正确且已处理,即size
json 中返回的字符串始终转换为 int 并url
始终重命名为target
.
更奇怪的是,我已经将此配置(在 input.http 中使用不同的 url,具体取决于区域)推送到了许多服务器,并且它们中的大多数都按预期工作,只有少数具有这种行为。我已经检查并确保每台服务器上的所有 Telegraf 版本都匹配(1.19.1)并且它们都在 Centos 7 上运行。我还尝试从 influxdb 中清除数据。
在目标中返回 url 的少数服务器总是这样做,即使当我对它们运行 telegraf 测试时,它们显示主机已按应有的方式被剥离。
关于下一步看哪里的任何提示?