summaryrefslogtreecommitdiffstats
path: root/collectors/python.d.plugin/mongodb/README.md
blob: b6dd9c5f4cd7ed4519738b425a6fdcf5bfdcc6fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<!--
title: "MongoDB monitoring with Netdata"
custom_edit_url: https://github.com/netdata/netdata/edit/master/collectors/python.d.plugin/mongodb/README.md
sidebar_label: "MongoDB"
-->

# MongoDB monitoring with Netdata

Monitors performance and health metrics of MongoDB.

## Requirements

-   `python-pymongo` package v2.4+.

You need to install it manually.

Number of charts depends on mongodb version, storage engine and other features (replication):

1.  **Read requests**:

    -   query
    -   getmore (operation the cursor executes to get additional data from query)

2.  **Write requests**:

    -   insert
    -   delete
    -   update

3.  **Active clients**:

    -   readers (number of clients with read operations in progress or queued)
    -   writers (number of clients with write operations in progress or queued)

4.  **Journal transactions**:

    -   commits (count of transactions that have been written to the journal)

5.  **Data written to the journal**:

    -   volume (volume of data)

6.  **Background flush** (MMAPv1):

    -   average ms (average time taken by flushes to execute)
    -   last ms (time taken by the last flush)

7.  **Read tickets** (WiredTiger):

    -   in use (number of read tickets in use)
    -   available (number of available read tickets remaining)

8.  **Write tickets** (WiredTiger):

    -   in use (number of write tickets in use)
    -   available (number of available write tickets remaining)

9.  **Cursors**:

-   opened (number of cursors currently opened by MongoDB for clients)
-   timedOut (number of cursors that have timed)
-   noTimeout (number of open cursors with timeout disabled)

10. **Connections**:

    -   connected (number of clients currently connected to the database server)
    -   unused (number of unused connections available for new clients)

11. **Memory usage metrics**:

    -   virtual
    -   resident (amount of memory used by the database process)
    -   mapped
    -   non mapped

12. **Page faults**:

    -   page faults (number of times MongoDB had to request from disk)

13. **Cache metrics** (WiredTiger):

    -   percentage of bytes currently in the cache (amount of space taken by cached data)
    -   percentage of tracked dirty bytes in the cache (amount of space taken by dirty data)

14. **Pages evicted from cache** (WiredTiger):

    -   modified
    -   unmodified

15. **Queued requests**:

    -   readers (number of read request currently queued)
    -   writers (number of write request currently queued)

16. **Errors**:

    -   msg (number of message assertions raised)
    -   warning (number of warning assertions raised)
    -   regular (number of regular assertions raised)
    -   user (number of assertions corresponding to errors generated by users)

17. **Storage metrics** (one chart for every database)

    -   dataSize (size of all documents + padding in the database)
    -   indexSize (size of all indexes in the database)
    -   storageSize (size of all extents in the database)

18. **Documents in the database** (one chart for all databases)

-   documents (number of objects in the database among all the collections)

19. **tcmalloc metrics**

    -   central cache free
    -   current total thread cache
    -   pageheap free
    -   pageheap unmapped
    -   thread cache free
    -   transfer cache free
    -   heap size

20. **Commands total/failed rate**

    -   count
    -   createIndex
    -   delete
    -   eval
    -   findAndModify
    -   insert

21. **Locks metrics** (acquireCount metrics - number of times the lock was acquired in the specified mode)

    -   Global lock
    -   Database lock
    -   Collection lock
    -   Metadata lock
    -   oplog lock

22. **Replica set members state**

    -   state

23. **Oplog window**

    -   window (interval of time between the oldest and the latest entries in the oplog)

24. **Replication lag**

    -   member (time when last entry from the oplog was applied for every member)

25. **Replication set member heartbeat latency**

    -   member (time when last heartbeat was received from replica set member)

## Prerequisite

Create a read-only user for Netdata in the admin database.

1.  Authenticate as the admin user.

```
use admin
db.auth("admin", "<MONGODB_ADMIN_PASSWORD>")
```

2.  Create a user.

```
# MongoDB 2.x.
db.addUser("netdata", "<UNIQUE_PASSWORD>", true)

# MongoDB 3.x or higher.
db.createUser({
  "user":"netdata",
  "pwd": "<UNIQUE_PASSWORD>",
  "roles" : [
    {role: 'read', db: 'admin' },
    {role: 'clusterMonitor', db: 'admin'},
    {role: 'read', db: 'local' }
  ]
})
```

## Configuration

Edit the `python.d/mongodb.conf` configuration file using `edit-config` from the Netdata [config
directory](/docs/configure/nodes.md), which is typically at `/etc/netdata`.

```bash
cd /etc/netdata   # Replace this path with your Netdata config directory, if different
sudo ./edit-config python.d/mongodb.conf
```

Sample:

```yaml
local:
    name : 'local'
    authdb: 'admin'
    host : '127.0.0.1'
    port : 27017
    user : 'netdata'
    pass : 'netdata'
```

If no configuration is given, module will attempt to connect to mongodb daemon on `127.0.0.1:27017` address

---