bosunscollector

scollector - tagging metrics from vsphere


just a question about scollector tagging. I have a config file that looks like this:

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>)\.[.]+'

with the idea being that we can retrieve and tag data from different vsphere servers.

My understanding of the docs is that this will give us a number of different tag values based what is regex'd out of the Vsphere hostname. The initial tags are for the local host, and the we use overrides for the data coming from Vsphere.

However when i implement this, I notice that these metrics are coming in with the original environment tag of "bosun" rather than the override being applied.

I have tried an alternate config:

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"

But i am seeing similar behavior (the last environment tag is applied to all vpshere data), so im not quite sure where i am going wrong.

Can someone help me understand where i am going wrong here ?

Update

As per Greg's answer below, my problem was that i didnt have the CollectorExpr quite right.

Using scollector -l i was able to come up with the correct CollectorExpr.

# ./scollector-linux-amd64 -l | grep vsphere
vsphere-CUST1-SITE1-MGMTVC01
vsphere-CUST1-SITE2-MGMTVC01
vsphere-CUST1-SITE1-CLIVC01
vsphere-CUST1-SITE2-CLIVC01
#

Our config (for those looking for examples) ended up something like this:

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' 

Solution

  • I believe CollectorExpr is a regular expression that must match against the output of scollector -l or the collector tag values used in the scollector.collector.duration metric. Our vsphere instances get the tag values of vsphere-ny-vsphere02 for ny-vsphere02 and vsphere-nyhq-vsphere01 for nyhq-vsphere01. The following settings should match against those collector names:

    [[TagOverride]]
      CollectorExpr = "vsphere-ny-"
        [TagOverride.Tags]
          datacenter = 'ny'
    
    [[TagOverride]]
      CollectorExpr = "vsphere-nyhq-"
        [TagOverride.Tags]
          datacenter = 'nyhq'
    

    Using [TagOverride.MatchedTags] instead of [TagOverride.Tags] should work to extract the value out of the hostname, but keep in mind that all the hostnames are truncated to their shortname (no FQDN) unless you set FullHost = true in the scollector.toml file. My guess is your settings are failing because the CollectorExpr is incorrect. Try something like:

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

    If that doesn't work try using '[TagOverride.Tags]' in a dev environment to see if you can add test tags/values to those metrics.