Unable to fetch metrics from mongos router using Metricbeat mongodb module
Getting following response from metricbeat in kibana discover tab.
{
"_index":"metricbeat-6.6.1-2019.08.30",
"_type":"doc",
"_id":"TPRy4WwBD8jWXe3om-Qlbcq",
"_score":1,
"_source":{
"@timestamp":"2019-08-30T07:34:39.988Z",
"metricset":{
"host":<hostname>:<port>,
"rtt":13591,
"name":"status",
"module":"mongodb"
},
"event":{
"dataset":"mongodb.status",
"duration":13591785
},
"error":{
"message":"not authorized on admin to execute command { serverStatus: 1, $readPreference: { mode: \"secondaryPreferred\" }, $db: \"admin\" }"
},
"beat":{
"name":<name>,
"hostname":<hostname>,
"version":"6.6.1"
},
"host":{
//info
},
"meta":{
//info
}
},
"fields":{
"@timestamp":[
"2019-08-30T07:34:39.988Z"
]
}
}
Metricbeat version: 6.6.1
Metricbeat Configuration
module: mongodb
metricsets: ["dbstats", "status", "collstats"]
enabled: true
period: 10s
hosts: [<host1>,<host2>]
username: <username>
password: <password>
Mongos router version: 4.0.6
Mongo user roles
{
"user":<username>,
"db":"admin",
"roles":[
{
"role":"root",
"db":"admin"
},
{
"role":"userAdmin",
"db":"admin"
},
{
"role":"dbOwner",
"db":"admin"
},
{
"role":"userAdminAnyDatabase",
"db":"admin"
}
]
}
Also, the below queries are working on mongo-shell from the same user
db.runCommand({dbStats: 1})
db.runCommand( { serverStatus: 1, } )
db.runCommand( { serverStatus: 1, $readPreference: { mode: "secondaryPreferred" }} )
Thanks in advance.