只是关于scollector标记的问题。我有一个如下所示的配置文件:
Host = "bosun01:80"
BatchSize = 5000
[Tags]
customer = "Admin"
environment = "bosun"
datacenter = "SITE1"
[[Vsphere]]
Host = "CUST2SITE1VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[Vsphere]]
Host = "CUST3SITE1VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[Vsphere]]
Host = "CUST4SITE1VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[Vsphere]]
Host = "CUST4SITE2VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[TagOverride]]
CollectorExpr = "Vsphere"
[TagOverride.MatchedTags]
Host = '^(?P<customer>.{5})(?P<datacenter>.{5})(?P<environment>)\.[.]+'
我们的想法是我们可以从不同的vSphere服务器检索和标记数据。
我对文档的理解是,这将为我们提供许多不同的标记值,这些标记值基于Vsphere主机名中的正则表达式。初始标记用于本地主机,我们使用覆盖来自Vsphere的数据。
然而,当我实现这一点时,我注意到这些指标是以&#34; bosun&#34;的原始环境标记进入的。而不是应用覆盖。
我尝试了另一种配置:
Host = "bosun01:80"
BatchSize = 5000
[Tags]
customer = "Admin"
environment = "bosun"
datacenter = "SITE1"
[[Vsphere]]
Host = "CUST2SITE1VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[TagOverride]]
[TagOverride.Tags]
environment = "Env01"
[[Vsphere]]
Host = "CUST3SITE1VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[TagOverride]]
[TagOverride.Tags]
environment = "Env02"
[[Vsphere]]
Host = "CUST4SITE1VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[TagOverride]]
[TagOverride.Tags]
environment = "Env03"
[[Vsphere]]
Host = "CUST4SITE2VC01.F.Q.D.N"
User = "user"
Password = "pass"
[[TagOverride]]
[TagOverride.Tags]
environment = "Env04"
但是我看到了类似的行为(最后一个环境标记应用于所有vpshere数据),所以我不太确定我哪里出错了。
有人可以帮我理解我在哪里错了吗?
更新
根据Greg的回答,我的问题是我没有让CollectorExpr完全正确。
使用scollector -l
我能够找到正确的CollectorExpr。
# ./scollector-linux-amd64 -l | grep vsphere
vsphere-CUST1-SITE1-MGMTVC01
vsphere-CUST1-SITE2-MGMTVC01
vsphere-CUST1-SITE1-CLIVC01
vsphere-CUST1-SITE2-CLIVC01
#
我们的配置(对于那些寻找示例的人)最终得到了这样的结果:
Host = "hwbosun01:80"
BatchSize = 5000
[Tags]
customer = "Customer1"
environment = "bosun"
datacenter = "eq"
[[Vsphere]]
Host = "CUST1-SITE1-MGMTVC01"
User = "user"
Password = "pass"
[[Vsphere]]
Host = "CUST1-SITE2-MGMTVC01"
User = "user"
Password = "pass"
[[Vsphere]]
Host = "CUST1-SITE1-CLIVVC01"
User = "user"
Password = "pass"
[[Vsphere]]
Host = "CUST-SITE1-CLIVVC01"
User = "user"
Password = "pass"
[[TagOverride]]
CollectorExpr = "CUST-SITE1-MGMTVC01"
[TagOverride.Tags]
environment = "vsphere.mgmt"
datacenter = 'site1'
[[TagOverride]]
CollectorExpr = "CUST-SITE1-MGMTVC01"
[TagOverride.Tags]
environment = "vsphere.mgmt"
datacenter = 'site2'
[[TagOverride]]
CollectorExpr = "CUST-SITE1-CLIVC01"
[TagOverride.Tags]
environment = "vsphere.mgmt"
datacenter = 'site1'
[[TagOverride]]
CollectorExpr = "CUST-SITE1-CLIVC01"
[TagOverride.Tags]
environment = "vsphere.mgmt"
datacenter = 'site2'
答案 0 :(得分:1)
我相信CollectorExpr是一个正则表达式,必须与scollector -l
的输出或scollector.collector.duration
指标中使用的收集器标记值匹配。我们的vsphere实例为ny-vsphere02获取vsphere-ny-vsphere02的标记值,为nyhq-vsphere01获取vsphere-nyhq-vsphere01的标记值。以下设置应与这些收集器名称匹配:
[[TagOverride]]
CollectorExpr = "vsphere-ny-"
[TagOverride.Tags]
datacenter = 'ny'
[[TagOverride]]
CollectorExpr = "vsphere-nyhq-"
[TagOverride.Tags]
datacenter = 'nyhq'
使用[TagOverride.MatchedTags]
代替[TagOverride.Tags]
应该可以从主机名中提取值,但请记住,除非设置FullHost = true,否则所有主机名都会被截断为其短名称(无FQDN)在scollector.toml文件中。我的猜测是你的设置失败,因为CollectorExpr不正确。尝试类似:
[[TagOverride]]
CollectorExpr = "vsphere-"
[TagOverride.MatchedTags]
Host = '^(?P<customer>.{5})(?P<datacenter>.{5})(?P<environment>[^.]+)'
如果这不起作用,请尝试使用&#39; [TagOverride.Tags]&#39;在开发环境中查看是否可以为这些指标添加测试标记/值。