Skip to content
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

Fix alert follow up for custom queries #10253

Merged
merged 1 commit into from May 23, 2019

Conversation

Projects
None yet
2 participants
@thomseddon
Copy link
Contributor

commented May 23, 2019

RunFollowUp checks if there is a custom sql query attached to the alert and uses this before invoking GenSQL to build the query. However, the custom query column was not included when selecting
alerts so the GenSQL function was always invoked.

This patch includes the alert_rules.query in the loadAlerts function used by RunFollowUp.

See $alert['query'] is checked here: https://github.com/librenms/librenms/blob/master/includes/alerts.inc.php#L630-L632
But this will never be set as it's not included in the loadAlerts query

This only caused a problem because I built a custom query which returned multiple rows, where the number of rows returned represents the number of instances of the alert on the device. This fix also allows the libre to detect if an alert has got better/worse when using a custom query.

DO NOT DELETE THIS TEXT

Please note

Please read this information carefully. You can run ./scripts/pre-commit.php to check your code before submitting.

Testers

If you would like to test this pull request then please run: ./scripts/github-apply <pr_id>, i.e ./scripts/github-apply 5926
After you are done testing, you can remove the changes with ./scripts/github-remove. If there are schema changes, you can ask on discord how to revert.

Fix alert follow up for custom queries
RunFollowUp checks if there is a custom sql query attached to
the alert and uses this before invoking GenSQL to build the query.
However, the custom query column was not included when selecting
alerts so the GenSQL function was always invoked.

This patch includes the alert_rules.query in the loadAlerts function
used by RunFollowUp.

@thomseddon thomseddon force-pushed the thomseddon:fix/alerts-custom-sql branch from b7228ed to 0fdaffd May 23, 2019

@murrant
Copy link
Member

left a comment

Thanks.

@murrant murrant merged commit f7e365f into librenms:master May 23, 2019

6 checks passed

Inspection Summary
Details
Node: analysis
Details
Travis CI - Pull Request Build Passed
Details
WIP Ready for review
Details
codeclimate All good!
Details
license/cla Contributor License Agreement is signed.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.