scollector - 从 vsphere 标记指标
scollector - tagging metrics from vsphere
只是关于 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 的数据。
但是,当我实施此操作时,我注意到这些指标随 "bosun" 的原始环境标签一起出现,而不是应用覆盖。
我试过另一种配置:
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'
我认为 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,否则所有主机名都会被截断为其短名称(无 FQDN) = 在 scollector.toml 文件中为真。我的猜测是您的设置失败,因为 CollectorExpr 不正确。尝试类似的东西:
[[TagOverride]]
CollectorExpr = "vsphere-"
[TagOverride.MatchedTags]
Host = '^(?P<customer>.{5})(?P<datacenter>.{5})(?P<environment>[^.]+)'
如果这不起作用,请尝试在开发环境中使用“[TagOverride.Tags]”,看看是否可以将测试 tags/values 添加到这些指标。
只是关于 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 的数据。
但是,当我实施此操作时,我注意到这些指标随 "bosun" 的原始环境标签一起出现,而不是应用覆盖。
我试过另一种配置:
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'
我认为 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,否则所有主机名都会被截断为其短名称(无 FQDN) = 在 scollector.toml 文件中为真。我的猜测是您的设置失败,因为 CollectorExpr 不正确。尝试类似的东西:
[[TagOverride]]
CollectorExpr = "vsphere-"
[TagOverride.MatchedTags]
Host = '^(?P<customer>.{5})(?P<datacenter>.{5})(?P<environment>[^.]+)'
如果这不起作用,请尝试在开发环境中使用“[TagOverride.Tags]”,看看是否可以将测试 tags/values 添加到这些指标。