1

无法使用 Metricbeat mongodb 模块从 mongos 路由器获取指标

在 kibana 发现选项卡中从 metricbeat 获得以下响应。

{
   "_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 版本:6.6.1 Metricbeat 配置

    module: mongodb
    metricsets: ["dbstats", "status", "collstats"]
    enabled: true
    period: 10s
    hosts: [<host1>,<host2>]
    username: <username>
    password: <password>

Mongos 路由器版本:4.0.6 Mongo 用户角色

{
   "user":<username>,
   "db":"admin",
   "roles":[
      {
         "role":"root",
         "db":"admin"
      },
      {
         "role":"userAdmin",
         "db":"admin"
      },
      {
         "role":"dbOwner",
         "db":"admin"
      },
      {
         "role":"userAdminAnyDatabase",
         "db":"admin"
      }
   ]
}

此外,以下查询正在同一用户的 mongo-shell 上工作

    db.runCommand({dbStats: 1})
    db.runCommand( { serverStatus: 1, } )
    db.runCommand( { serverStatus: 1, $readPreference: { mode: "secondaryPreferred" }} )

提前致谢。

4

0 回答 0