-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for custom mongodb commands #4445
Add support for custom mongodb commands #4445
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Foremost, I think this sort of conflicts with #3919
@chakflying I think this is your area ⇒ I would rather not interfere:
what do you think about this?
Can this be integrated into your plan, or what level of refactoring need to be done to accommodate it?
Given the level of change (basically a rewrite) that this PR adds to the mongodb
monitor, I think some additional changes are necessary.
- Please extract this monitor to the newer
monitor-type
variant of implementing monitors. see chore:extracted the group monitor to a different monitoring type #4395 for an example - To be make verifying that this works simpler, please attach how you tested it to the description. (
docker run...
, query executed) ^^
We discussed this a bit in #3857. Personally, I think the code change here is relatively small, and is good preparation if we wanted to support this generically in the future. I'm not against merging this if people wanted this feature. |
Thank you for the response, I migrated to the new monitor type and added some info for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested seems to work okay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my side there are no roadblocks.
Works as intended.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as resolved.
This comment was marked as resolved.
Does this also work for MongoDB Atlas? |
We have not tested that (we have tested the docker container), but you can report the findings. |
https://github.com/louislam/uptime-kuma/blob/master/CONTRIBUTING.md#can-i-create-a-pull-request-for-uptime-kuma
Tick the checkbox if you understand [x]:
Description
Extends the MongoDB monitor to allow running custom MongoDB commands and optionally comparing the value against an expected value.
Besides being able to check database content, this is useful to further check the health of MongoDB, especially clusters. For example, the hello command offers various health information which can be queried and checked with this change.
From a UI standpoint, this adds a command input, a json query input and an expected value input. All are basically the same as comparable HTTP(s) Json query inputs and other DB monitors inputs.
All new fields are optional, and the default command is still the ping command that was used before. All commands are checked for the ok result, so the behaviour without using the new inputs is the same as before.
If the Json Query is set, it'll be applied to the query result. If json query result is undefined, the monitor will produce a failure. The Json query without expected value is basically checking if the value exists. If the expected value is set, it will be compared to the result.
Type of change
Checklist
Screenshots
Testing
Test MongoDB
docker run --name test-mongodb -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin mongo
Connection string:
mongodb://admin:admin@localhost:27017
Test query:
{ "hello": 1 }
Here are the tests I ran:
mongodb-monitor-tests.json