Ad Widget

Collapse

Discussion thread for official Zabbix Template DB MongoDB

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BernhardMM
    Junior Member
    • Jul 2021
    • 2

    #16
    It seems there has been either a change with MongoDB 6 and instance state in a replication set, or a misconception (or I don't get the correct intention):

    As it's defined in https://git.zabbix.com/projects/AP/r...t_status.go#31 the MongoDB plugin expects to get only
    Code:
    state: 1
    and
    Code:
    state: 2
    in the rs.status() JSON. However, offline nodes now get other states, at least
    Code:
    state: 8
    I have seen. This check https://git.zabbix.com/projects/AP/r..._status.go#126 then assumes everything is fine, because the node is not
    Code:
    state: 2
    but it should rather check for
    Code:
    node.state != statePrimary
    .

    Comment

    • studero
      Member
      • Aug 2023
      • 84

      #17
      Originally posted by guiguir68

      Yup, same error here!
      I've just made theses fixes in my "MongoDB node by Zabbix agent 2" template:
      • Item "MongoDB: Unhealthy replicas"
        Preprocessing > JSONPath :
        Code:
        $.members[?(@.health == 0)].name
      • Item "MongoDB: Number of unhealthy replicas"
        Preprocessing > JSONPath :
        Code:
        $.members[?(@.health == 0)].length()

      ​
      Hello,

      I have the same problem. I need help to apply your workaround.

      My configuration is :
      Zabbix server : 6.4.12
      Zabbix agent2 : 6.4.12
      MongoDB sever : 7.0.6

      Regards
      Olivier​

      Comment

      • iprum
        Junior Member
        • Dec 2024
        • 1

        #18
        Hello!
        I am struggling to get the MongoDB monitoring to work.
        Zabbix 7.0, MongoDB cluster hosted on Kubernetes, template used MongoDB cluster by Zabbix Agent 2.
        According to the documentation, in host Macros I need to give MONGODB.CONNSTRING, which in my case contains several ip addresses, example tcp://1.1.1.1:27017,2.2.2.2:27017,3.3.3.3:27017/

        The error I receive is: Failed to create new connection: server selection error: server selection timeout, current topology: { Type: Single, Servers: [{ Addr: [1.1.1.1:27017,2.2.2.2]:27017, Type: Unknown, Last error: connection() error occured during connection handshake: dial tcp: lookup 1.1.1.1:31017,2.2.2.2: no such host }, ] }.

        What is the right format for the connection string if several nodes need to be indicated?

        Any help will be much appreciated.

        Comment


        • sandro1976
          sandro1976 commented
          Editing a comment
          I am another struggling user :-) but shouldn't you use a different approach, i.e. monitor every single node on its own?
      • sandro1976
        Junior Member
        • Sep 2022
        • 5

        #19
        Hello!
        I am trying to monitor a three nodes MongoDB 7.0.16 cluster (installed on three Debian 12 virtual machines) from a Zabbix Server 6.0.33.
        I installed zabbix-agent2 on all the nodes.
        I configured a "monitoring" user on the mongodb cluster:

        Code:
        db.createUser(
        {
        user: "zbx_monitor",
        pwd: "4e1c0d7d2c6503963c1f1fb9968e6818",
        roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
        }
        )
        I accordingly configured the {$MONGODB.PASSWORD} and {$MONGODB.USER} macros for the host (i actually tried also to hardcode those values on the plugin configuration locally in the host, with no change in the result).

        I get error like these on the zabbix agent log:

        Code:
        2024/12/30 00:51:34.038420 [MongoDB] Cannot fetch data: (Unauthorized) not authorized on test to execute command { connPoolStats: 1, maxTimeMS: 3000, lsid: { id: UUID("ebcdef90-5e16-424d-b59a-faf8277fb2af") }, $clusterTime: { clusterTime: Timestamp(1735516284, 1), signature: { hash: BinData(0, 78310CC300B
        91746C8C88AF3F6A5ECBC79CD61C0), keyId: 7453944273675747333 } }, $db: "test", $readPreference: { mode: "primaryPreferred" } }.
        2024/12/30 00:51:35.259822 [MongoDB] Cannot fetch data: (Unauthorized) not authorized on admin to execute command { serverStatus: 1, recordStats: 0, maxTimeMS: 3000, lsid: { id: UUID("ebcdef90-5e16-424d-b59a-faf8277fb2af") }, $clusterTime: { clusterTime: Timestamp(1735516294, 1), signature: { hash: BinDat
        a(0, 9C50FA059EE0DA43D6AFF71EB0FF7F7AE6C23926), keyId: 7453944273675747333 } }, $db: "admin", $readPreference: { mode: "primaryPreferred" } }.
        2024/12/30 00:51:36.621385 [MongoDB] Cannot fetch data: Failed to execute find query: (Unauthorized) not authorized on config to execute command { find: "chunks", filter: { jumbo: true }, lsid: { id: UUID("ebcdef90-5e16-424d-b59a-faf8277fb2af") }, $clusterTime: { clusterTime: Timestamp(1735516294, 1), sig
        nature: { hash: BinData(0, 9C50FA059EE0DA43D6AFF71EB0FF7F7AE6C23926), keyId: 7453944273675747333 } }, $db: "config", $readPreference: { mode: "primaryPreferred" } }.
        I wonder if MongoDB 7 is supported by my agent/server version...

        Thanks to anyone who read till here :-)

        Comment

      • nitrogear
        Junior Member
        • Apr 2009
        • 28

        #20
        Hello guys.
        I'm trying to add the template to Zabbix 6.0.39 and getting the following error:
        Cannot find template "MongoDB node by Zabbix agent 2" for host prototype "{#HOSTNAME}" of discovery rule "Config servers discovery" on "MongoDB cluster by Zabbix agent 2"
        Any idea what's wrong?

        Ok, so in order to add the cluster template you should add this template first...
        Last edited by nitrogear; 07-03-2025, 14:09.

        Comment

        • MBackrud
          Junior Member
          • May 2025
          • 1

          #21
          Regarding correct use of the MongoDB Templates...
          The one called "node" and the one called "cluster" seems to contain some of the same items and triggers... so they can not be added to the same host in Zabbix.

          I assumed that all MongoDB servers should have the "node" template and then that all MongoDB servers that is part of a cluster should ALSO have the "cluster" template.
          Is this wrong? Should MongoDB servers that is part of a cluster only use the "cluster" template?

          Comment

          Working...