Skip to content

Commit

Permalink
feat(slo): Add range filter to slo indicators by default (elastic#166390
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kdelemme authored Sep 14, 2023
1 parent f3b280f commit e344865
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 42 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,23 @@ export class HistogramTransformGenerator extends TransformGenerator {
}

private buildSource(slo: SLO, indicator: HistogramIndicator) {
const filter = getElastichsearchQueryOrThrow(indicator.params.filter);
return {
index: parseIndex(indicator.params.index),
runtime_mappings: this.buildCommonRuntimeMappings(slo),
query: filter,
query: {
bool: {
filter: [
{
range: {
[indicator.params.timestampField]: {
gte: `now-${slo.timeWindow.duration.format()}`,
},
},
},
getElastichsearchQueryOrThrow(indicator.params.filter),
],
},
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,23 @@ export class KQLCustomTransformGenerator extends TransformGenerator {
}

private buildSource(slo: SLO, indicator: KQLCustomIndicator) {
const filter = getElastichsearchQueryOrThrow(indicator.params.filter);
return {
index: parseIndex(indicator.params.index),
runtime_mappings: this.buildCommonRuntimeMappings(slo),
query: filter,
query: {
bool: {
filter: [
{
range: {
[indicator.params.timestampField]: {
gte: `now-${slo.timeWindow.duration.format()}`,
},
},
},
getElastichsearchQueryOrThrow(indicator.params.filter),
],
},
},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,23 @@ export class MetricCustomTransformGenerator extends TransformGenerator {
}

private buildSource(slo: SLO, indicator: MetricCustomIndicator) {
const filter = getElastichsearchQueryOrThrow(indicator.params.filter);
return {
index: parseIndex(indicator.params.index),
runtime_mappings: this.buildCommonRuntimeMappings(slo),
query: filter,
query: {
bool: {
filter: [
{
range: {
[indicator.params.timestampField]: {
gte: `now-${slo.timeWindow.duration.format()}`,
},
},
},
getElastichsearchQueryOrThrow(indicator.params.filter),
],
},
},
};
}

Expand Down

0 comments on commit e344865

Please sign in to comment.