Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use different stats of basicstats based on inputs #9170

Closed
6monlambert opened this issue Apr 22, 2021 · 2 comments
Closed

Use different stats of basicstats based on inputs #9170

6monlambert opened this issue Apr 22, 2021 · 2 comments

Comments

@6monlambert
Copy link
Contributor

6monlambert commented Apr 22, 2021

Hello,

I'd like to use the basicstat aggregator to get different metrics form different SNMP inputs.

System Info

Ubuntu 20.04
Telegraf 1.18.1 (git: HEAD d3ac9a3)

Relevant telegraf configuration

For example I have two SNMP inputs configured like this

[[inputs.snmp]]
  agents = [  "X.X.X.X" ]
  version = 2
  community = "public"
  name = "idrac-esx"

  [[inputs.snmp.field]]
     name = "system-name"
     oid  = ".1.3.6.1.2.1.1.5.0"
     is_tag = true

  [inputs.snmp.tags]
    type="esx"

  [[inputs.snmp.table]]
     name = "idrac-esx"
     inherit_tags = ["system-name", "type"]

     [[inputs.snmp.table.field]]
        name = "watts"
        oid = "IDRAC-MIB-SMIv2::amperageProbeReading"

[[inputs.snmp]]
  agents = [ "X.X.X.X" ]
  version = 2
  community = "public"
  name = "idrac-switchs"

  [[inputs.snmp.field]]
     name = "system-name"
     oid  = ".1.3.6.1.2.1.1.5.0"
     is_tag = true

  [inputs.snmp.tags]
    type="switchs"

  [[inputs.snmp.table]]
     name = "idrac-switchs"
     inherit_tags = ["system-name", "type"]

     [[inputs.snmp.table.field]]
        name = "watts"
        oid = "Dell-Vendor-MIB::envMonSupplyCurrentPower"

# Keep the aggregate basicstats of each metric passing through.
[[aggregators.basicstats]]
  ## The period on which to flush & clear the aggregator.
  period = "30s"

  ## If true, the original metric will be dropped by the
  ## aggregator and will not get sent to the output plugins.
  drop_original = true

  ## Configures which basic stats to push as fields
  stats = ["max", "sum"]

### Actual behaviour

The result of telegraf --input-filter=snmp -config telegraf.d/test.conf --test is :

> idrac-switchs,agent_host=X.X.X.X,host=poc-conso,system-name=XXX,type=switchs watts_max=36,watts_sum=196 1619087952000000000
> idrac-esx,agent_host=X.X.X.X,host=poc-conso,system-name=XXX,type=esx watts_max=196,watts_sum=206 1619087952000000000

Expected behaviour

I could not find out the best way to keep watts_max as watts for the idrac-esx host and watts_sum as watts for the idrac_switchs host. I tried using 2 aggregators and tagexclude with the "type" tag but it did not work.

If you have any idea, that would be great !
Thanks a lot

@6monlambert
Copy link
Contributor Author

6monlambert commented Apr 22, 2021

It seems that I want to do what's described in this issue : #3413

The thing is, I did not find the way to do what was asked.

I tried to differentiate my fields like this :

   [[inputs.snmp.table.field]]
      name = "srv-watts"
      oid = "IDRAC-MIB-SMIv2::amperageProbeReading"
     [[inputs.snmp.table.field]]
        name = "sw-watts"
        oid = "Dell-Vendor-MIB::envMonSupplyCurrentPower"

And I used the fieldpass parameter in basicstats, then renamed my fields :

# Keep the aggregate basicstats of each metric passing through.
[[aggregators.basicstats]]
  ## The period on which to flush & clear the aggregator.
  period = "20s"
  drop_original = false
  stats = ["max"]
  fieldpass = ["srv-watts"]

[[aggregators.basicstats]]
  period = "20s"
  drop_original = true
  stats = ["sum"]
  fieldpass = ["sw-watts"]

[[processors.rename]]
  [[processors.rename.replace]]
    field = "sw-watts_sum"
    dest = "watts"

  [[processors.rename.replace]]
    field = "srv-watts_max"
    dest = "watts"

It works but I have now conflicts with other metrics
For example, with :

[[aggregators.basicstats]]
  period = "20s"
  drop_original = **true**
  stats = ["sum"]
  fieldpass = ["sw-watts"]

I have this (telegraf --input-filter=snmp -config telegraf.conf --test) :
2021-04-22T13:45:25Z I! Starting Telegraf 1.18.1
The output is empty.
And if I change the drop_original :

[[aggregators.basicstats]]
  period = "20s"
  drop_original = **false**
  stats = ["sum"]
  fieldpass = ["sw-watts"]

It gives me (telegraf --input-filter=snmp -config telegraf.conf --test) :

> idrac-chassis,agent_host=X.X.X.X,host=poc-conso,system-name=XXX,type=chassis chassis-watts="1500.000" 1619099188000000000
> idrac-chassis,agent_host=X.X.X.X,host=poc-conso,system-name=XXX,type=chassis chassis-watts="1448.000" 1619099188000000000

I could not find from the basicstats documentation the way to do this.
The best thing for me would be to be able to apply the stats according to the type tag that I add manually on each host :

  [inputs.snmp.tags]
    type="XXX"

@6monlambert 6monlambert changed the title Use different stats of basicstat based on inputs Use different stats of basicstats based on inputs Apr 22, 2021
@6monlambert
Copy link
Contributor Author

I managed to solve this issue, it was simply a syntax error.

For the Basicstats problem, I used this syntax :

[[aggregators.basicstats]]
  ## The period on which to flush & clear the aggregator.
  period = "20s"
  drop_original = false
  stats = ["max"]
  fieldpass = ["srv-watts"]
  [aggregators.basicstats.tagpass]
     type=["esx", "backup", ...]

It is important to put the tagpass at the end of the aggregator, as written in the global documentation.
An example in the aggregator documentation would have been nice.

I found the Order command pretty useful to solve some of my issues too.
Anyway, I close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant