Only userAdmin got created when I injected Telegraf into Cluster Pod

Hello there,

I am injecting a Sumologic-Telegraf side car into Percona Mongodb Cluster to collect metrics. During the pod initialization, mongod container was created first, Telegraf container creation was kicked in after mongod container was started. As observed, then the pod status keeps flapping.

mongo-2-rs-0                             2/2     Running            13         44m
mongo-2-rs-0                             1/2     Error              13         44m
mongo-2-rs-0                             1/2     CrashLoopBackOff   13         45m

As investigated, there is only one user: userAdmin, was created. I manually created user: clusterMonitor, then the pod runs into normal mode. it seems the kick-in time of side car defined in annotations should be controlled. With the given annotations, I haven’t find a solution. If you can shed a light on this problem, it will be appreciated.

rs:PRIMARY> db.createUser(
...   {
...     user: 'clusterMonitor',
...     pwd: 'xxxxxxx',
...     roles: [ { role: 'userAdminAnyDatabase', db: 'admin' } ]
...   }
... );
Successfully added user: {
	"user" : "clusterMonitor",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		}
	]
}

The helm chart is from

    annotations:
      telegraf.influxdata.com/class: sumologic-prometheus
      prometheus.io/scrape: "true"
      prometheus.io/port: "9273"
      telegraf.influxdata.com/inputs: |+
        [[inputs.mongodb]]
          servers = ["mongodb://clusterMonitor:xxxxxxxx@127.0.0.1:2707/?connect=direct"]
          gather_perdb_stats = true
          gather_col_stats = true
          [inputs.mongodb.tags]
            environment="k8s-2"
            component="database"
            db_system="mongodb"
            db_cluster="mongo-2"
1 Like

By now, the problem is not resolved yet. But we decided not to adopt this approach because it duplicates the metrics as telegraf agent runs on each pod.

1 Like