0

只是一个关于收藏家标签的问题。我有一个如下所示的配置文件:

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 数据),所以我不太确定我哪里出错了。

有人可以帮我理解我哪里出错了吗?

更新

根据下面格雷格的回答,我的问题是我没有完全正确的 CollectorExpr。

使用scollector -li 能够提出正确的 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' 
4

1 回答 1

1

scollector -l我相信 CollectorExpr 是一个正则表达式,它必须与指标中使用的收集器标记值的输出相匹配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]应该可以从主机名中提取值,但请记住,除非您在 scollector.toml 文件中设置 FullHost = true,否则所有主机名都会被截断为其短名称(无 FQDN)。我的猜测是您的设置失败,因为 CollectorExpr 不正确。尝试类似:

[[TagOverride]]
  CollectorExpr = "vsphere-"
    [TagOverride.MatchedTags]
      Host = '^(?P<customer>.{5})(?P<datacenter>.{5})(?P<environment>[^.]+)'

如果这不起作用,请尝试在开发环境中使用“[TagOverride.Tags]”以查看是否可以将测试标签/值添加到这些指标。

于 2016-11-17T23:53:03.403 回答