NGINX provides several capabilities to monitor it's state and collect statistic data:
- get data from http_stub_status module via HTTP
- parse NGINX access and error logs
- commercial NGINX Plus has it's own stats aggregation and monitoring dashboard however providing same data as JSON.
Currently only first variant is supported by MoSKito. Stub status looks like:
Active connections: 1 server accepts handled requests 62415 65715 66065 Reading: 0 Writing: 1 Waiting: 0
Integration with MoSKito is done in form of generic plugin that is able to monitor nginx/apache httpd/other similar apps.
This plugin is located in maven module moskito-extensions/moskito-monitoring-plugin/.
If needed, add it as a maven dependency:
To enable plugin, add next lines to @pluginsConfig section in moskito.json file:
Now you have to configure monitored nginx instances in monitoring-plugin-nginx.json file(if you haven't changed configurationName in plugins section):
Make sure that line "pluginType": "nginx" is present - the plugin itself is rather generic and here is the place you tell it which type of plugin it should be.
Monitored instances can be added/deleted/changed at runtime. Duplicate names are not allowed - if found, duplicates will be ignored. Currently names are directly used as created producers IDs, so names should be rather unique and don't interfere with other moskito producers.
Username/password can be omitted if not needed.
"@metrics" property can be used to instruct plugin which metrics it should monitor. If this property is absent or empty, all available metrics will be used. If property is present, and some metrics are ignored, "Handled" metric will remain monitored in any case, as it is used for checking nginx server restarts. Sample above contains all currently available metrics.
Run MoSKito and find new producers under Nginx section in producers list.