-
Notifications
You must be signed in to change notification settings - Fork 288
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 metric_agg_script to MetricAggregationRule #558
Conversation
742c2c8
to
b223e65
Compare
Relevant issue in the old issue tracker Yelp/elastalert#2901 |
Thanks for the contribution! A unit test can be added to the existing
Once you have this included, and confirmed the latest codebase works with your PR please update the checklist and we'll get this merged in. |
Copied from SpikeMetricAggregationRule, which originally copied generate_aggregation_query from MetricAggregationRule and added these two lines. So this commit just makes the two generate_aggregation_query look the same, which just works and I'm not really sure why no one has done it before.
aa52fa0
to
c8760a5
Compare
c8760a5
to
e7f0575
Compare
There you go! Rebased to master and added a test. (Also now I see how this works without a whole elasticsearch in the background, makes sense!) |
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.
I'm approving this to get it merged in. It would be good to update the schema.yaml
file with this metric_agg_script
parameter at some point, for both rule types. It's currently missing completely so that's why I'm not holding up this PR.
Description
Copied from SpikeMetricAggregationRule, which originally copied
generate_aggregation_query from MetricAggregationRule and added these
two lines.
So this commit just makes the two generate_aggregation_query look the
same, which just works and I'm not really sure why no one has done it
before.
Should not be a breaking change since it just adds an optional rule attribute.
Checklist
make test-docker
with my changes.Questions or Comments
No idea how to unit test this. It runs against a mocked elasticsearch, right? I was planning to not write any until I saw this checklist so uh, that's a tomorrow problem.
Most of my manual testing was with an out of tree extension, but I haven't gotten around to test this specific version of the code, so that one is unchecked.
I can't really add a changelog entry before creating the pull request.About the code: to be honest, this is a really lazy change, but it follows the trend of someone copypasting one version of
generate_aggregation_query
, modifying it a little and never applying that change to the original.I don't know what's the best way to deduplicate these things, and doing something like
MetricAggregationRule.generate_aggregation_query(self)
would be needlessly obscure imo. Can't really deduplicate the docs.