Skip to content

Telegraf plugin for mongodb incorrect determine node ROLE #11275

@mishutka-mmx

Description

@mishutka-mmx

Relevant telegraf.conf

[[outputs.file]]
   ## Files to write to, "stdout" is a specially handled file.
   files = ["stdout", "/root/metrics.out"]

     data_format = "influx"
[[inputs.mongodb]]

#servers = ["mongodb://telegraf:manager@localhost:27017/admin"]
servers = ["mongodb://admin:admin@localhost:27017/admin"]
gather_cluster_status = true
gather_perdb_stats = true
gather_col_stats = true
gather_top_stat = true
col_stats_dbs = []
interval = "30s"

Logs from Telegraf

/usr/bin/telegraf --config ./my.conf --debug  
2022-06-09T07:48:04Z I! Starting Telegraf 1.22.3
2022-06-09T07:48:04Z I! Loaded inputs: mongodb
2022-06-09T07:48:04Z I! Loaded aggregators: 
2022-06-09T07:48:04Z I! Loaded processors: 
2022-06-09T07:48:04Z I! Loaded outputs: file
2022-06-09T07:48:04Z I! Tags enabled: LifeCycle=Text host=gmv01ndbmgr01 ims_system_id=666
2022-06-09T07:48:04Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"gmv01ndbmgr01", Flush Interval:10s
2022-06-09T07:48:04Z D! [agent] Initializing plugins
2022-06-09T07:48:04Z D! [agent] Connecting outputs
2022-06-09T07:48:04Z D! [agent] Attempting connection to [outputs.file]
2022-06-09T07:48:04Z D! [agent] Successfully connected to outputs.file
2022-06-09T07:48:04Z D! [agent] Starting service inputs
2022-06-09T07:48:14Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2022-06-09T07:48:24Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2022-06-09T07:48:30Z E! [inputs.mongodb] error getting col stats from "system.tenantMigration.oplogView": (CommandNotSupportedOnView) Namespace local.system.tenantMigration.oplogView is a view, not a collection
2022-06-09T07:48:34Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2022-06-09T07:48:44Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2022-06-09T07:48:54Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2022-06-09T07:49:00Z E! [inputs.mongodb] error getting col stats from "system.tenantMigration.oplogView": (CommandNotSupportedOnView) Namespace local.system.tenantMigration.oplogView is a view, not a collection
mongodb,LifeCycle=Text,host=gmv01ndbmgr01,hostname=localhost:27017,ims_system_id=666,node_type=PRI,rs_name=MYRS version="5.0.9",tcmalloc_pageheap_reserve_count=66i,connections_total_created=159i,queued_writes=0i,repl_apply_batches_num=0i,repl_updates=0i,tcmalloc_pageheap_total_decommit_bytes=3355439104i,wtcache_app_threads_page_read_time=170i,cursor_no_timeout=0i,repl_deletes=0i,commands_per_sec=3i,total_avai

System info

Telegraf 1.22.3

Docker

No response

Steps to reproduce

1.mongodb 5.0.9 or earlier
2. telegraf user has root permissions in mangodb
3. Simple config for telegraf to run

Expected behavior

TAG node_type should be PRI for master and REPL for slave

Actual behavior

TAG node_type always determine as node_type=PRI

Additional info

Hello.
Telegraf plugin for mongodb incorrect determine node ROLE

Runnig telegraf on master or replica nodes always determine tag node_type as node_type=PRI

If we check inside mongo - it's return correct role:

MYRS:SECONDARY> rs.isMaster()
{
"topologyVersion" : {
"processId" : ObjectId("62a02de8670dfa2c17709f73"),
"counter" : NumberLong(6)
},
"hosts" : [
"192.0.62.152:27017",
"192.0.62.151:27017",
"192.0.62.157:27017"
],
"setName" : "MYRS",
"setVersion" : 7,
"ismaster" : false,
...

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/mongodbbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions