Telegraf – additional tags for your inputs

I have this scenario, i would like to monitor all our Microsoft sql databases in our setup using Telegraf. I dont want to install telegraf agent in every server, i want to collect SQL database metrics remotely from a single location. What is the challenge? If you use the default setup, telegraf will not tag the remote hostname in its metric, it will use our telegraf hostname. That means you can’t tell the difference between databases .

Solution ? i found out that we can add additional tags in the configure
[inputs.sqlserver.tags]

[[inputs.sqlserver]]
  # QA1 DB 
  servers = [
    "Server=localhost;Port=1433;User Id=sa;Password=myp@ssw0rd;"
  ]
[inputs.sqlserver.tags]
    sql_db_remote_host = "localhost"

[[inputs.sqlserver]]
  # QA1 DB 
  servers = [
    "Server=server02;Port=1433;User Id=sa;Password=myp@ssw0rd;"
  ]
[inputs.sqlserver.tags]
    sql_db_remote_host = "server02"

If you use this configure, you will see this tag “sql_db_remote_host” in the metrics.

Leave a Reply

Your email address will not be published. Required fields are marked *