SNMP Support
SNMP support is available for Enterprise licenses only.
-
This page explains how to use SNMP to monitor RavenDB and what metrics can be accessed.
-
In this page:
Overview
-
Simple Network Management Protocol (SNMP) is an Internet-standard protocol for collecting and organizing information about managed devices on IP networks. It is used primarily for monitoring network services. SNMP exposes management data in the form of variables (metrics) that describe the system status and configuration. These metrics can then be remotely queried (and, in some circumstances, manipulated) by managing applications.
-
In RavenDB we have support for SNMP which allows monitoring tools like Zabbix, PRTG, and Datadog direct access to the internal details of RavenDB. We expose a long list of metrics: CPU and memory usage, server total requests, the loaded databases, and database-specific metrics like the number of indexed items per second, document writes per second, storage space each database takes, and more.
-
You can still monitor what is going on with RavenDB directly from the Studio, or by using one of our monitoring tools. However, using SNMP might be easier in some cases. As users start running large numbers of RavenDB instances, it becomes impractical to deal with each of them individually, and using a monitoring system that can watch many servers becomes advisable.
Enabling SNMP in RavenDB
-
To monitor RavenDB using SNMP you must first set the Monitoring.Snmp.Enabled configuration key to true.
-
To learn how to modify a configuration key, refer to the Configuration Overview article,
which outlines all available options. -
For example, add this key to your settings.json file and restart the server.
{
...
"Monitoring.Snmp.Enabled": true
...
}
SNMP configuration options
There are several configurable SNMP properties in RavenDB:
For SNMPv1:
- Monitoring.Snmp.Port
The SNMP port.
Default:161
- Monitoring.Snmp.SupportedVersions
List of supported SNMP versions.
Default:"V2C;V3"
For SNMPv2c:
- Monitoring.Snmp.Community
The community string is used as a password.
It is sent with each SNMPGET
request and allows or denies access to the monitored device.
Default:"ravendb"
For SNMPv3:
- Monitoring.Snmp.AuthenticationProtocol
Authentication protocol.
Default:"SHA1"
- Monitoring.Snmp.AuthenticationUser
The user for authentication.
Default:"ravendb"
- Monitoring.Snmp.AuthenticationPassword
The authentication password. When set tonull
the community string is used instead.
Default:null
- Monitoring.Snmp.PrivacyProtocol
Privacy protocol.
Default:None
- Monitoring.Snmp.PrivacyPassword
Privacy password.
Default:"ravendb"
-
See article Monitoring Options for the full list of SNMP configuration keys.
-
To learn how to modify a configuration key, refer to the Configuration Overview article,
which outlines all available options.
The Metrics
Access metrics via monitoring tools
-
Querying the exposed metrics using a monitoring tool is typically straightforward (see this Zabbix example).
-
For a simplified setup, we have provided a few templates which can be found here.
These templates include the metrics and their associated OIDs.
Access metrics via SNMP agents
-
The metrics can be accessed directly using any SNMP agent such as Net-SNMP.
Each metric has a unique object identifier (OID) and can be accessed individually. -
The most basic SNMP commands are
snmpget
,snmpset
andsnmpwalk
.
For example, you can execute the following snmpget commands to retrieve the server's up-time metric.
##### For SNMPv2c:
// Request:
snmpget -v 2c -c ravendb live-test.ravendb.net 1.3.6.1.4.1.45751.1.1.1.3
// Result:
iso.3.6.1.4.1.45751.1.1.1.3 = Timeticks: (29543973) 3 days, 10:03:59.73
* `ravendb` is the community string (set via the [Monitoring.Snmp.Community](../../../server/configuration/monitoring-configuration#monitoring.snmp.community) configuration key).
* `"live-test.ravendb.net"` is the host.
##### For SNMPv3:
snmpget -v 3 -l authNoPriv -u ravendb -a SHA \
-A ravendb live-test.ravendb.net 1.3.6.1.4.1.45751.1.1.1.3
* `-l authNoPriv` - sets the security level to use authentication but no privacy.
* `-u ravendb` - sets the user for authentication purposes to "ravendb".
* `-a SHA` - sets the authentication protocol to SHA.
* `-A ravendb` - sets the authentication password to "ravendb".
Access metrics via HTTP
Access single OID value:
-
An individual OID value can be retrieved via HTTP
GET
endpoint:
<serverUrl>/monitoring/snmp?oid=<oid>
-
For example, a cURL request for the server up-time metric:
// Request:
curl -X GET http://live-test.ravendb.net/monitoring/snmp?oid=1.3.6.1.4.1.45751.1.1.1.3
// Result:
{ "Value" : "4.21:32:56.0700000" }
Access multiple OID values:
-
Multiple OID values can be retrieved by making either a
GET
or aPOST
request to the following HTTP endpoint:<serverUrl>/monitoring/snmp/bulk
-
For example, cURL requests for the server managed memory and unmanaged memory metrics:
curl -X GET "http://live-test.ravendb.net/monitoring/snmp/bulk? \
oid=1.3.6.1.4.1.45751.1.1.1.6.7&oid=1.3.6.1.4.1.45751.1.1.1.6.8"
curl -X POST \
-H "Content-Type: application/json" \
-d '{ "OIDs": ["1.3.6.1.4.1.45751.1.1.1.6.7", "1.3.6.1.4.1.45751.1.1.1.6.8"]}' \
http://localhost:8080/monitoring/snmp/bulk
{
"Results": [
{ "OID": "1.3.6.1.4.1.45751.1.1.1.6.7", "Value": "410" },
{ "OID": "1.3.6.1.4.1.45751.1.1.1.6.8", "Value": "4" }
]
}
-
You can get a list of all OIDs along with their description via this HTTP
GET
endpoint:
<serverUrl>/monitoring/snmp/oids
-
For example: http://live-test.ravendb.net/monitoring/snmp/oids
List of OIDs
-
RavenDB's root OID is: 1.3.6.1.4.1.45751.1.1.
-
Values represented by
X
,D
, orI
in the OIDs list below will be:X
:
0
- any kind of collection
1
- a generation-0 or generation-1 collection
2
- a blocking generation-2 collection
3
- a background collection (this is always a generation 2 collection)D
- Database numberI
- Index number
OID | Metric (Cluster) |
---|---|
3.1.1 | Current node tag |
3.1.2 | Current node state |
3.2.1 | Cluster term |
3.2.2 | Cluster index |
3.2.3 | Cluster ID |