I have a distributed Mongodb setup and I'm trying to configure it with Icinga2 using the following link as reference,
https://admin-docs.com/databases/mongodb/mongodb-administration/monitor-mongodb-using-icinga/
As mine is a distributed setup, Icinga should connect to Mongodb along with hostname parameter as,
mongo -h ipaddress
Without this, Icinga2 dashboard shows the following error for all the MongoDB monitoring services,
CRITICAL - Connection to Mongo server on 127.0.0.1:27017 has failed
How do I configure my Icinga2 setup to use hostname in the command?
Finally got it working, pretty simple, just had to set the variable value for mongodb_address using the following,
apply Service "Mongodb Connection" {
check_command = "mongodb"
command_endpoint = host.vars.client_endpoint
vars.mongodb_address = "$address$"
assign where host.vars.client_endpoint && host.vars.os == "MongoOnLinux"
}
Here, $address$ is in built variable for host IP Address