Skip to content

Commit

Permalink
app/vmui: show less lines at metrics explorer when the instance isn't…
Browse files Browse the repository at this point in the history
… selected

Show min, max and avg graphs across instances for the selected job.
This should improve usability of such a graphs when the job contains many instances.

Updates #3386
  • Loading branch information
valyala committed Dec 24, 2022
1 parent 8a1775f commit 8579aec
Showing 1 changed file with 23 additions and 5 deletions.
Expand Up @@ -45,15 +45,33 @@ const ExploreMetricItem: FC<ExploreMetricItemGraphProps> = ({
const base = `{${params.join(",")}}`;
if (isBucket) {
if (instance) {
return `histogram_quantiles("quantile", 0.5, 0.95, 0.99, sum(increase(${base})) by (vmrange, le))`;
return `
label_map(
histogram_quantiles("__name__", 0.5, 0.95, 0.99, sum(rate(${base})) by (vmrange, le)),
"__name__",
"0.5", "q50",
"0.95", "q95",
"0.99", "q99",
)`;
}
return `histogram_quantile(0.95, sum(increase(${base})) by (instance, vmrange, le))`;
return `
with (q = histogram_quantile(0.95, sum(rate(${base})) by (instance, vmrange, le))) (
alias(min(q), "q95min"),
alias(max(q), "q95max"),
alias(avg(q), "q95avg"),
)`;
}
const queryBase = rateEnabled ? `rate(${base})` : base;
if (instance) {
return `sum(${queryBase})`;
const queryBase = rateEnabled ? `label_match(rollup_rate(${base}), "rollup", "max")` : `max_over_time(${base})`;
return `alias(max(${queryBase}), "max")`;
}
return `sum(${queryBase}) by (instance)`;
const queryBase = rateEnabled ? `rollup_rate(${base})` : `rollup(${base})`;
return `
with (q = ${queryBase}) (
alias(min(label_match(q, "rollup", "min")), "min"),
alias(max(label_match(q, "rollup", "max")), "max"),
alias(avg(label_match(q, "rollup", "avg")), "avg"),
)`;
}, [name, job, instance, rateEnabled, isBucket]);

const { isLoading, graphData, error, warning } = useFetchQuery({
Expand Down

0 comments on commit 8579aec

Please sign in to comment.