E! [inputs.mongodb] failed to gather data: "(Unauthorized) not authorized on admin to execute command { serverStatus: 1, recordStats: 0, lsid: { id: UUID(\"e43e855553d0d\") }, $db: \"admin\" }"

I’m trying to get the metric of mongDB for monitoring purpose
The plugin i used in telegraf was below
[[inputs.mongodb]]
servers = [“mongodb://mongoadmin:admin@1.1.7.103:27017/admin”]
gather_perdb_stats = true
gather_col_stats = true

when i trying to debug the telegraf whether the mongoDB plugin is wokring or not its showing me the below error
E! [inputs.mongodb] failed to gather data: “(Unauthorized) not authorized on admin to execute command { serverStatus: 1, recordStats: 0, lsid: { id: UUID("e43e855553d0d") }, $db: "admin" }”

can anyone help me with this .

This error message letting the user you used does not have permissions. It is also possible that your URL is incorrect and you do not need the /admin suffix at the end as you are suppose to only give the IP address and port of your server.

Check out more on the mongodb readme:

I have tried both ways , but none of them not worked
servers = [“mongodb://mongoadmin:admin@1.1.7.103:27017”]
servers = [“mongodb://mongoadmin:admin@1.1.7.103:27017/?connect=direct”]