AMID - Another.js Mongo Internet Driver
Node.js REST interface for MongoDB, we modified mongodb-rest (https://github.com/tdegrunt/mongodb-rest) to manage more operation:
- counting elements
- "distinct" operations
- excel/csv export
- list of available db collection
- list of keys of a specific query
- Multithreading support
It's now also possible to search by date range and are managed sort operations. On this link there is an availabe a GUI that use AMID to query data over mongo collections:
Installation is now via npm: npm install amid
.
After that you can just issue amid-rest
on the command line and the server should start.
Here is shown an example of a monitoring system that integrate Nagios, MongoDB and AMID Rest Interface, to have a realtime monitoring of both services and application logs.
Application's datas arrives on MongoDB thanks to TD-Agent that is a service that can send logs data from file directly to a Mongo instance. Datas in Mongo collections are exposed through a rest interface with AMID.
Nagios queries services status with the NRPE client - or with ssh remote commands - installed on monitored servers, and the status of the applications with AMID, searching every minute errors in the differents Mongo collections.
The resulting status of services and applications is sent to a Grafite server to have realtime graphing on Grafana, while the collected logs are available for searching thanks to a web application (AMID GUI).
The follows is a partial list of the involved components:
- https://www.mongodb.org
- http://docs.treasuredata.com/articles/td-agent
- https://www.nagios.org
- http://www.thruk.org
- http://graphite.wikidot.com
- https://github.com/shawn-sterling/graphios
- http://grafana.org
- https://github.com/mariano-fiorentino/amidGUI
Supported REST requests:
GET /db/collection
- Returns all documentsGET /db/collection?query=%7B%22isDone%22%3A%20false%7D
- Returns all documents satisfying queryGET /db/collection?query=%7B%22isDone%22%3A%20false%7D&limit=2&skip=2
- Ability to add options to query (limit, skip, etc)GET /db/collection/id
- Returns document with idGET db
- List all collection/documentGET /db/collection/?operation=key
- List all key of collectionGET /db/collection/?operation=excel&query=%7B%22isDone%22%3A%20false%7D
- export query in excelGET /db/collection/?sort=[{"property":null,"direction":"ASC"}]
- Returns all document soted by ASCGET /db/collection?query=%7B%22isDone%22%3A%20false%7D&operation=count
- Count elementsGET /db/collection?operation=distinct&fields=Market&sort=[{"property":null,"direction":"ASC"}]
- Distinct and sort operationGET /db/collection/?sort={"creationDate":-1}&skip=100&limit=100
- Example to sort by the field "creationdate", -1 is for ASC sorts, 1 means DESC sortsPOST /db/collection
- Insert new document in collection (document in POST body)PUT /db/collection/id
- Update document with id (updated document in PUT body)DELETE /db/collection/id
- Delete document with id
Content Type:
- Please make sure
application/json
is used as Content-Type when using POST/PUT with request body's.
Dependencies:
- "express": "~4.0.0",
- "morgan": "~1.0.0",
- "body-parser": "~1.0.0",
- "method-override": "~1.0.0",
- "mongodb": "~1.4.0",
- "jade": "~1.9.4",
- "log4js": "~0.6.0",
- "excel-export": "~0.4.0"
- Mariano Fiorentino
- Andrea Negro