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 = < Monitoring interval for agents in seconds >
threads = < Number of threads to be used for agent creation >
scan_databases = < Set to 1 to enable this token to monitor the databases of the configured instances >
agent_per_database = < Set to 1 to enable this token to monitor the databases of the configured instances. >
db_agent_prefix = < Prefix for the database agents created. >
modules_prefix = < Prefix for created modules >
execute_custom_queries = < Set to 1 to enable the use of custom queries >
analyze_connections = < Set to 1 to enable connection monitoring >
engine_uptime = < Set to 1 to enable runtime monitoring >
query_stats = < Set to 1 to enable query statistics monitoring >
network = < Set to 1 to enable network statistics monitoring >
latency = < Set to 1 to enable latency statistics monitoring >
Example
agents_group_id = 10
interval = 300
threads = 1
modules_prefix = Mongodb.
scan_databases = 1
agent_per_database = 1
db_agent_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 file content will be a list of target instances, separating each instance by commas or lines. The connection URI for each one must be specified.
Example
mongodb://172.17.0.2:27017
mongodb://172.17.0.7:27017
If you want to monitor specific databases within an instance, you must specify them using "|" and separate each database with ";".
Example:
mongodb://172.17.0.7:27017|pandora_db;pandora_db2
If you want to exclude specific databases from a query, you must specify them using "|" and separate each database with ";", including an exclamation mark ! before the "|" :
Example :
mongodb://172.17.0.7:27017!|pandora_db;pandora_db2
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)
One module must be defined for each custom query to be monitored. Modules must follow this structure:
check_begin --> Module opening tag
name --> Module name
description --> Module description.
operation --> Operation type: value (returns a single value) | full (returns all rows as string).
datatype --> Module type: generic_data | generic_data_string | generic_proc.
min_warning --> Minimum warning threshold
max_warning --> Maximum warning threshold
str_warning --> Warning string threshold
warning_inverse --> Set to 1 to invert the warning threshold interval
min_critical --> Minimum critical threshold
max_critical --> Maximum critical threshold
str_critical --> Critical string threshold
critical_inverse --> Set to 1 to invert the critical threshold interval
module_interval --> This interval is calculated as a multiplier of the agent interval.
crontab --> 5-field cron expression (minute, hour, day of month, month, day of week).
The query only runs when the current date/time matches the expression.
If not specified, the query runs on every interval.
Format: crontab <minute> <hour> <day_of_month> <month> <day_of_week>
Examples:
* * * * * → every minute (always)
0 9 * * 1-5 → Monday to Friday at 09:00
*/15 * * * * → every 15 minutes
* 12-15 * * 1 → Mondays between 12:00 and 15:59
target --> Custom query.
Allowed commands: dbStats, collStats, find, count, aggregate, listCollections.
target_instances --> Custom queries will be executed on databases belonging to the instances
configured here. If not specified, all instances will be monitored,
same as specifying "all". To select specific ones, separate with ",".
target_databases --> Custom queries will be executed on databases configured here.
If not specified, all databases will be monitored,
same as specifying "all". To select specific ones, separate with ",".
check_end --> Module closing tag
Module against specific instances and databases
check_begin
name DatabaseStats
description Database statistics
operation value
datatype generic_data
target db.runCommand({ dbStats: 1 })
target_instances mongodb://172.17.0.2:27017
target_databases pandora_db, pandora_db2
check_end
Module with find on all instances and databases
check_begin
name Getcollection
description get collection
datatype generic_data_string
min_warning 10
target db.system.version.find({})
target_instances all
target_databases all
check_end
Module with find using ObjectId
check_begin
name Getdocument
description get document
datatype generic_data_string
min_warning 10
target db.mi_coleccion.find({ "_id": ObjectId("655b4a235d797f3769d6b03e") })
check_end
Module with crontab (runs only Monday to Friday at 09:00)
check_begin
name daily_db_stats
description Daily database stats
operation value
datatype generic_data
target db.runCommand({ dbStats: 1 })
target_instances all
target_databases all
crontab 0 9 * * 1-5
check_end
Module with crontab (only during office hours 8:00–18:00)
check_begin
name office_documents
description Document count during office hours
operation value
datatype generic_data
target db.mi_coleccion.find({ "active": true })
target_instances all
target_databases all
crontab * 8-17 * * 1-5
check_end
Module with crontab every 30 minutes
check_begin
name check_every_half_hour
description Check every 30 minutes
operation value
datatype generic_data
target db.runCommand({ dbStats: 1, scale: 1 })
target_instances all
target_databases all
crontab */30 * * * *
check_end
Crontab filter behavior
- At the beginning of each plugin execution, all custom queries are evaluated.
- Queries without the
crontabfield always run (classic behavior, backward compatible). - Queries with
crontabare only included if the current date/time matches the cron expression. - Queries rejected by crontab do not generate database connections or queries.
- The filter runs once before spawning monitoring threads.
Cron expression format
The expression follows the standard 5-field format separated by spaces:
| Field | Allowed values |
|---|---|
| Minute | 0-59 |
| Hour | 0-23 |
| Day of month | 1-31 |
| Month | 1-12 |
| Day of week | 0-7 (0 and 7 = Sunday, 1 = Monday) |
Each field supports the following formats:
*— any valueN— exact value (e.g.5)N-M— range (e.g.9-17)*/N— every N units (e.g.*/15= every 15 minutes)N-M/N— range with step (e.g.0-30/10= 0, 10, 20, 30)A,B,C— comma-separated list of values
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") })