spm-agent-mongodb
v3.0.4
Published
SPM Agent for monitoring MongoDB
Downloads
99
Readme
This is the MongoDB monitoring Agent for MongoDB Monitoring with Sematext Cloud.
Preparation
Get a free Sematext account
Create a Monitoring App of type "MongoDB" and copy the App Token - or execute the commands displayed in the Sematext UI (which are described here as well)
Install Node.js on your MongoDB server
The MongoDB driver might need libkrb5-dev for Kerberos authentication (if you use Kerberos ...)
apt-get install libkrb5-dev
Setup
# Install spm-agent-mongodb
npm i spm-agent-mongodb -g
# In case you use Sematext Cloud EU (https://apps.eu.sematext.com):
# configure the API endpoints for EU.
# The following commands create the file /etc/sematext/receivers.config:
# sudo spm-mongodb-setup -r EU
# Note: To switch back to Sematext US region use
# sudo spm-mongodb-setup -r US # default for apps.sematext.com
# Install systemd or upstart service file for spm-agent-mongodb
# Create an SPM App of type MongoDB in Sematext UI
# and use your SPM Token:
sudo spm-mongodb-setup -t SPM_TOKEN -m mongodb://localhost:27017/local
# or to specify the username and password for the agent to use to connect to MongoDB
sudo spm-mongodb-setup -t SPM_TOKEN -m mongodb://UsernameHere:PasswordHere@localhost:27017/DbNameHere
Note that the monitoring agent requires admin rights to query the relevant tables. It should have ClusterAdmin role and read access to any DB.
Configuration
The setup script will store your configuration in /etc/sematext/spm-agent-mongodb.config
If you want to change the settings later edit /etc/sematext/spm-agent-mongodb.config. Then restart the Sematext MongoDB Agent after config changes, depending on the init system:
- Upstart (Ubuntu):
sudo service spm-agent-mongodb restart
- Systemd (Linux others):
sudo systemctl stop spm-agent-mongodb
sudo systemctl start spm-agent-mongodb
- Launchd (Mac OS X):
sudo launchctl stop com.sematext.spm-agent-mongodb
sudo launchctl stop com.sematext.spm-agent-mongodb
For tests you can just run the agent from command line:
spm-agent-mongodb SPM_TOKEN MONGODB_URL
Setup on Docker
The MongoDB agent is integrated in SPM-Client docker image.
The relevant SPM_CONFIG string ist:
mongodb SPM_TOKEN MONGODB_URL
.
Run SPM-Client, replace the App Token and MongoDB URL with your configuration:
docker run --name spm-client --restart=always -v /var/run/docker.sock:/var/run/docker.sock -e SPM_CONFIG="mongodb YOUR_SPM_MONGODB_TOKEN mongodb://mongodbUser:mogodbPassword@mongodb-server:port/database" sematext/spm-client
Docker-Compose example with SPM-Client and MongoDB server: docker-compose.yml.
Results
More Information:
Support
- Twitter: @sematext
- Blog: blog.sematext.com
- Homepage: www.sematext.com