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

[Alerting Framework] Create a new rule count/summary endpoint #119226

Closed
jasonrhodes opened this issue Nov 19, 2021 · 5 comments
Closed

[Alerting Framework] Create a new rule count/summary endpoint #119226

jasonrhodes opened this issue Nov 19, 2021 · 5 comments
Labels
discuss enhancement New value added to drive a business result Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)

Comments

@jasonrhodes
Copy link
Member

jasonrhodes commented Nov 19, 2021

In #116476 we were discussing how to search for rules, and @ymao1 pointed us to the GET rule by ID or FIND rules endpoints. We're going to move forward with those but I thought it might be useful to have an endpoint that could make a more efficient ES query and just return the overall counts for some things, based on the same filter/query options available int he find rules endpoint.

For example:

  • Total rules that match
    • Enabled/disabled
    • Muted/not muted
    • Count per execution status

The basic idea is just that we want this above information in as performant a way as can be managed, and right now we'll have to query the rules and loop over the results to count these. Thoughts?

@jasonrhodes jasonrhodes added enhancement New value added to drive a business result Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams) labels Nov 19, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-alerting-services (Team:Alerting Services)

@ymao1
Copy link
Contributor

ymao1 commented Nov 19, 2021

Alerting rules client currently has an "aggregate" API that returns a count of rules by execution status. This was implemented before the saved objects client added aggregation support so what it really does is perform a find query for each execution status and reduce the results into a single result.

public async aggregate({
options: { fields, ...options } = {},
}: { options?: AggregateOptions } = {}): Promise<AggregateResult> {
// Replace this when saved objects supports aggregations https://github.com/elastic/kibana/pull/64002
const alertExecutionStatus = await Promise.all(
AlertExecutionStatusValues.map(async (status: string) => {
const { filter: authorizationFilter } = await this.authorization.getFindAuthorizationFilter(
AlertingAuthorizationEntity.Rule,
alertingAuthorizationFilterOpts
);
const filter = options.filter
? `${options.filter} and alert.attributes.executionStatus.status:(${status})`
: `alert.attributes.executionStatus.status:(${status})`;
const { total } = await this.unsecuredSavedObjectsClient.find<RawAlert>({
...options,
filter:
(authorizationFilter && filter
? nodeBuilder.and([
esKuery.fromKueryExpression(filter),
authorizationFilter as KueryNode,
])
: authorizationFilter) ?? filter,
page: 1,
perPage: 0,
type: 'alert',
});
return { [status]: total };
})
);
return {
alertExecutionStatus: alertExecutionStatus.reduce(
(acc, curr: { [status: string]: number }) => Object.assign(acc, curr),
{}
),
};
}

The intent was always to replace this with a real aggregation once the saved objects client supported aggregations, which it now does: #96292, so it seems like it would make the most sense to update the find API to take aggregations as an input.

@kobelb kobelb added the needs-team Issues missing a team label label Jan 31, 2022
@botelastic botelastic bot removed the needs-team Issues missing a team label label Jan 31, 2022
@gmmorris
Copy link
Contributor

I think this got forgotten and should have been added to the R&AM project board for triage.
If I read this correctly - we want to extend the find api to support aggs.

cc @XavierM

@jasonrhodes
Copy link
Member Author

@simianhacker if you want to confirm for @XavierM if this is still something we'd like to have, in case they want more specific requirements?

@kdelemme
Copy link
Contributor

kdelemme commented Dec 7, 2022

@XavierM Do you have plans for this?

@kdelemme kdelemme removed the Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" label Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss enhancement New value added to drive a business result Team:ResponseOps Label for the ResponseOps team (formerly the Cases and Alerting teams)
Projects
No open projects
Development

No branches or pull requests

6 participants