Skip to content

Update Cluster Alerts watches for hits.total change #39143

@ycombinator

Description

@ycombinator

Monitoring creates watches for its Cluster Alerts feature. The definitions for these watches can be found in this folder: https://github.com/elastic/elasticsearch/tree/master/x-pack/plugin/monitoring/src/main/resources/monitoring/watches.

Some of these watches rely on hits.total being a scalar value. For example:

"source": "ctx.vars.fails_check = ctx.payload.check.hits.total != 0 && ctx.payload.check.hits.hits[0]._source.cluster_state.status != 'green';ctx.vars.not_resolved = ctx.payload.alert.hits.total == 1 && ctx.payload.alert.hits.hits[0]._source.resolved_timestamp == null;return ctx.vars.fails_check || ctx.vars.not_resolved"

Starting 7.0, Elasticsearch will default to hits.total being an object instead of a scalar value. To account for this, two sets of fixes ought to be made to the Cluster Alerts watches:

  1. In the 6.7 branch, these watches should include rest_total_hits_as_int in their search queries. This will allow a Cluster Alert watch created by a 6.7 cluster to function properly either on a 6.7 or 7.0 monitoring cluster.

  2. In the 7.0, 7.x, and master branches, these watches should be updated so any references to hits.total refer to hits.total.value instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions