Skip to content

Telegraf adds irrelevant hostname from ShardHostData while gathering stats #17418

@I-Hate-NONE

Description

@I-Hate-NONE

Relevant telegraf.conf

[[outputs.influxdb]]
  urls = ["http://localhost:8086"]
  retention_policy= "autogen"
  write_consistency = "any"
  timeout = "30s"

[[inputs.mongodb]]
  servers = [ "mongodb://test:test@<replicasetnode>:27017/?connect=direct" ]
  gather_perdb_stats = true
  gather_col_stats = true
  gather_top_stat = true
  [inputs.mongodb.tags]
    "component_name" = "mgs"
    "ReplicaSet_name" = "test"

Logs from Telegraf

n/a

System info

master (https://github.com/influxdata/telegraf/tree/master)

Docker

No response

Steps to reproduce

I have a replica set with 3 nodes. I'm looking at the update_count metric to check the rate for a particular collection for a particular host. I have host label = my target host and hostname = the 2nd or the 3rd node in the replica set. Checked and debugged the code and saw that you:

  1. Set the 'original' host's tag first:
    tags["hostname"] = s.hostname
  2. Override it with another value:
    d.Tags["hostname"] = host.Name
  3. In the end, when constructing a query for host = host1 I get two chart with (host=host1, hostname=host2) and (host=host1m hostname=host3) and I don't get a chart to see how many updates have been executed for my host1.

Expected behavior

Create a metric to show stats for a necessary host

Actual behavior

Two metrics are created; each looks like a separate counter; it's impossible to get the query to show the data for the dedicated primary.

Image

Additional info

I may be missing something so would be grateful if you show me the proper way to set this up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions