refactor: Update alert rules to generate sql query and store in db #4748

Merged
merged 2 commits into from Oct 14, 2016

Projects

None yet

5 participants

@laf
Member
laf commented Oct 8, 2016

Please note

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

Should remain backwards compatible.

Rather than running GenSQL all the time for both polling and alerting we now do this when a rule is edited / added (and also daily just in case) and then store the query to be used directly. This saves us doing un-indexed queries against information_schema DB.

I've put a blocker on this purely because the schema number i've used is 144 as I already have 143 out for the sensors polling and whilst people test that I don't want to cause any conflicts.

laf added some commits Oct 6, 2016
@laf laf refactor: Update alert rules to generate sql query and store in db
e0ddeec
@laf laf moved schema file 6a97e44
@laf
Member
laf commented Oct 8, 2016 edited

Just to give some info on this, it will save 1 MySQL query per alert rule per device. So 10 alert rules on 50 devices = 500 queries per poller run saved.

Will also save 1 MySQL query per alert rule run for alerts.php.

Example. 1 Host, 10 alert rules:

Old:

MySQL: Cell[1/0s] Row[25/0.02s] Rows[9/0.01s] Column[3/0s] Update[1/0s] Insert[2/0s] Delete[0/0s]

New:

MySQL: Cell[1/0s] Row[15/0.01s] Rows[9/0.01s] Column[3/0s] Update[1/0s] Insert[2/0s] Delete[0/0s]
@murrant
Contributor
murrant commented Oct 10, 2016

Seems reasonable to me, that query to information_schema bothered me when I was working on the device_group stuff as well.

@laf laf removed the Blocker label Oct 11, 2016
@laf
Member
laf commented Oct 11, 2016

Update schema file number

@scrutinizer-notifier

The inspection completed: 2 new issues, 1 updated code elements

@laf
Member
laf commented Oct 14, 2016

Just as an FYI that we've been running this at work for most of the week.

@Rosiak
Contributor
Rosiak commented Oct 14, 2016 edited

I am not able to test this properly.

@murrant
Contributor
murrant commented Oct 14, 2016

I don't use alerting really, so if it works for you 👍

@laf laf merged commit e1fac85 into librenms:master Oct 14, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@laf laf deleted the laf:alert-rule-cache branch Oct 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment