Creating alert definitions with CLI
Thomas Segismont
tsegismo at redhat.com
Fri Oct 10 13:09:14 UTC 2014
Le 10/10/2014 14:53, Michael Burman a écrit :
> Hi,
>
> About the long standing RFE (BZ 617202), I'd like to ask for your opinions. I've done some work and a preliminary implementation that would make creating definitions through CLI as close as possible to the GUI interface. Now I would like to have some opinions, if I'm taking the right route and if you have any wishes. I try to employ the builder-pattern in this case and I tried to use existing domain-models (I haven't changed any existing ones to preserve backwards compatibility) whenever it made sense.
>
> So here's the sort of query language I have in place now ("working" example):
>
> AlertDefinitionTemplate template = new AlertDefinitionTemplate()
> .enabled(true)
> .description("description")
> .name("name")
> .priority(AlertPriority.MEDIUM)
> .alertProtocol(BooleanExpression.ANY);
>
> // Set recovery rules
> template.recovery()
> .disableWhenFired(false);
>
> // Set dampening rules
> template.dampening()
> .category(AlertDampening.Category.CONSECUTIVE_COUNT)
> .occurences(2);
>
> // Add AlertConditions
> template.addCondition(AvailabilityCondition.class)
> .availability(AlertConditionOperator.AVAIL_GOES_DOWN);
>
> template.addCondition(AbsoluteValueCondition.class)
> .comparator(AlertConditionOperator.GREATER_THAN)
> .value(90.0)
> .metric(11465);
>
> Function names might not be consistent yet in all cases (I've tried to keep them short, but in some cases I couldn't think of very short descriptive one). There's no PR yet for this.
>
> - Micke
I like the approach which will be perfect for the Remote API user. For
the CLI, maybe creating a Javascript-friendly builder would be even better.
More information about the rhq-devel
mailing list