MongoDB
This document describes the MongoDB functionality of PandoraFMS discovery.
- Introduction
- Pre requisites
- Parameters and configuration
- Manual execution
- Discovery
- Agents generated by the plugin
Introduction
The purpose of this plugin is to monitor MongoDB databases, through metrics that are key to know the performance and status of the databases, such as the number of connections, number of queries, latency, network and uptime. This data will be reflected in PandoraFMS, in modules that will provide the statistical value, inside an agent that will represent each database.
This plugin is developed to be used with Pandora FMS Discovery, so unlike other plugins it does not generate agents by XML, but everything discovered is returned in the plugin's JSON output.
Pre requisites
This plugin performs remote connections to the databases to be monitored, so it is necessary to ensure connectivity between the Pandora FMS server and these databases.
In turn the following permissions are required for the user used to connect.
For databases
role read or dbAdmin
For server stats
role clusterMonitor or clusterAdmin
Parameters and configuration
Parameters
--conf | Path to configuration file |
--target_databases | Path to the configuration file containing the database targets |
--target_agents | Path to the configuration file containing the agent targets |
--custom_queries | Path to the configuration file containing the modules with custom queries |
Configuration file (--conf)
agents_group_id = < ID of the group in which the agents will be created >
interval = < Agent monitoring interval in seconds >
uri = < Connection string in URI format >
threads = < Number of threads to use for agent creation >
module_prefix = <Modules Prefix>
execute_custom_queries = < Activate with 1 to enable the use of custom queries. >
analyze_connections = < Enable with 1 to enable connection monitoring >
engine_uptime = <Enable with 1 to enable runtime monitoring>
query_stats = < Enable with 1 to enable query statistics monitoring >
network = < Activate with 1 to enable network statistics monitoring >
latency = < Enable with 1 to enable latency statistics monitoring >
Example
agents_group_id = 10
interval = 300
uri = mongodb://172.17.0.3:27017
threads = 1
modules_prefix = Mongodb.
execute_custom_queries = 1
analyze_connections = 1
network = 1
query_stats = 1
latency = 1
engine_uptime = 1
List of target databases (--target_databases)
The content of the file will be a list of target databases, separating each database by commas or lines. The format for a database will be its name:
Example
admin
db_analytics
db_geospatial
db_guides
List of target agents (--target_agents)
The content of the file will be a list of agent name bases, separating each agent by commas or lines. These agent names will be used to dump the information from each target database into the corresponding indicated agent name, rather than letting the plugin generate the agent names automatically.
The position of each agent name in the listing must match the position of the target database in its own listing, that is, the name for the first target database will be the first name in this listing, taking into account that blank lines are ignored.
Example
agente1,,agente3
agente4
agente5,agente6,agente7,,agente9
Custom queries (--custom_queries)
A module must be entered for each custom query to be monitored. The modules must follow a structure, which is as follows:
check_begin --> Module opening label
name --> Module name
description --> Module description.
operation --> Operation type, value | full -> value returns a simple value, full returns all rows in a string
datatype --> Module type
min_warning --> Minimum warning threshold setting
max_warning --> Maximum warning threshold configuration
str_warning --> Warning string configuration
warning_inverse --> Enable inverse interval with 1 for warning threshold
min_critical --> Minimum critical threshold setting
max_critical --> Maximum critical threshold configuration
str_critical --> Critical string configuration
critical_inverse --> Activate inverse interval with 1 for critical threshold
module_interval --> This interval is calculated as a multiplier of the agent interval.
target --> Custom query
target_databases --> Database agents in which the module will be created. Select according to the name that has been assigned to the database agent. The one that has been put in target agents.
check_end --> Module closing label.
Example
check_begin
name DatabaseStats
description Database statistics
operation value
datatype generic_data
target db.runCommand({ dbStats: 1 })
target_databases all
check_end
check_begin
name Getcollection
description get collection
datatype generic_data_string
min_warning 10
target db.system.version.find({})
target_databases agent2
check_end
check_begin
name Getdocument
description get document
#operation value
datatype generic_data_string
min_warning 10
target db.mi_coleccion.find({ "_id": ObjectId("655b4a235d797f3769d6b03e") })
target_databases agent4
check_end
Queries for the target parameter of the modules
Commands can be executed according to the following format:
db.runCommand(< command >)
or
runCommand(< command >)
To know the expected response, to configure the type of module in string or data as required.
As a precaution only the following type of commands will be executed : dbStats,collStats,find,cound,aggregate,listCollections
Find queries can be run to obtain data from collections and documents:
db.< collection >.find({})
or
< collection >.find({})
With the possibility of specifying queries within the find method:
db.< collection >.find({ "<key document": "value" })
Example:
db.mi_collection.find({ "_id": ObjectId("655b4a235d797f3769d6b03e") })
Manual execution
The format of the plugin execution is as follows:
./pandora_mongodb \
--conf < path to the configuration file > \
--target_databases < path to the configuration file containing the target databases > \
[ --target_agents < path to agent configuration file > ] \
For example:
./pandora_mongodb \
--conf /usr/share/pandora_server/util/plugin/mongodb.conf \
--target_databases /usr/share/pandora_server/util/plugin/targets.conf \
--target_agents /usr/share/pandora_server/util/plugin/target_agents.conf
Discovery
This plugin can be integrated with Pandora FMS Discovery.
To do this, you must load the ".disco" package that you can download from the Pandora FMS library:
https://pandorafms.com/library/
Once loaded, MongoDB environments can be monitored by creating Discovery tasks from the Management > Discovery > Applications section.
For each task, the following minimum data will be requested:
- MongoDB target strings : List of Mongodb targets to monitor by the task. It will be a list separated by commas or lines. Each target database can be defined by adding its name.
- Uri – Standard MongoDB connection URI to connect to a MongoDB database server
It is also possible to adjust the task configuration to customize the desired monitoring:
- Max threads: to optimize execution time, multiple threads may be configured to monitor the task agents. Note that configuring multiple threads may increase the task CPU usage.
- Target agent: List of target agents for the MongoDB targets to monitor. That is, the names with which the agents of each target defined in the task will be generated. It will be a comma or line separated list. The position of the names in the list should match the position of the MongoDB targets in your list, that is, the first name will be used for the first target and so on. If the list is separated by lines, blank lines will be ignored. If no agent name is specified for a target, its name will be used as the agent name.
- Custom module prefix: Text included as prefix for all the generated module names. It is useful to locate the modules generated by the task or to distinguish them from others.
- Check engine uptime: If enabled it will monitor the uptime of the targets.
- Retrieve query statistics: If enabled it will monitor query statistics.
- Analyze connections: If enabled, it will monitor connections.
- Retrieve latency statistics: If enabled, it will monitor latency.
- Retrieve network statistics: If enabled, it will monitor the networks.
- Execute custom queries: If activated you will enable the possibility of executing custom queries.
- Custom queries: Modules can be specified with custom queries.
Tasks that are successfully completed will have an execution summary with the following information:
- Total agents: Total agents generated by the task.
- Targets up: Total number of targets to which it has been possible to connect.
- Targets down: Total number of targets to which it has not been possible to connect.
Tasks that are not completed successfully will have an execution summary recording the errors that occurred.
Agents generated by the plugin
The plugin will create an agent for each target database. That agent will contain the following modules
If engine_uptime is activated:
uptime | Displays the time the MongoDB server has been running since its last reset or startup. |
If query_stats is activated:
queries command | Number of MongoDB queries involving command operations. |
queries delete | Number of delete operations performed on the MongoDB database. |
queries getmore | Number of "getmore" operations executed, "getmore" is used to get more results from a query when the results do not fit in a single batch. |
queries insert | Number of insert operations performed on the MongoDB database. |
queries query | Number of query operations performed on the MongoDB database. |
queries update | Number of update operations performed on the MongoDB database. |
If analyze_connections is activated:
connections available | Number of available connections on the MongoDB server |
connections current | Current number of active connections on the MongoDB server |
connections totalCreated | Total number of connections that have been created on the MongoDB server since it was started or restarted. |
MONGODB connection | Current connection availability |
If latency is activated:
commands latency | Average latency of command type operations in MongoDB. |
commands ops | Total number of command type operations performed in MongoDB. |
reads latency | Average latency of read operations in MongoDB. |
reads ops | Total number of read operations performed on MongoDB. |
writes latency | Average latency of MongoDB write operations. |
writes ops | Total number of write operations performed on MongoDB. |
If network is activated:
bytesIn | Total number of bytes that have been received by the MongoDB server since it was started or restarted. |
bytesOut | Total number of bytes that have been sent by the MongoDB server to clients or applications since it was started or restarted. |
numRequests | Total number of requests that the MongoDB server has received since it was started or restarted. |