Skip to main content

MongoDB

The Mongo component lookup allows you to form components from the records in a Postgres database.

In this example below, we form components from all the tables in the incident_commander database.

mongo-check.yml
apiVersion: canaries.flanksource.com/v1
kind: Topology
metadata:
name: mongo-collections
namespace: default
spec:
schedule: '@every 30s'
components:
- name: MongoDB
type: Table
icon: mongodb
lookup:
mongodb:
- connection: mongodb://username:password@localhost:27017/incident_commander
query: |
db.getCollectionNames().map(function(collectionName) {
const stats = db.getCollection(collectionName).stats();
return {
name: collectionName,
numRows: stats.count
};
});
display:
expr: |
results.map(result, {
'name': result.name,
'type': "Collection",
'properties': [{
"name": "Documents",
"headline": true,
"value": double(result.numRows),
}]
}).toJSON()
FieldDescriptionSchemeRequired
authUsername and password value, configMapKeyRef or SecretKeyRef for Mongo serverAuthentication
connectionConnection string to connect to the Mongo serverstringYes

Authentication

FieldDescriptionSchemeRequired
passwordSet password for authentication using string, configMapKeyRef, or SecretKeyRef.EnvVarYes
usernameSet username for authentication using string, configMapKeyRef, or SecretKeyRef.EnvVarYes