Allow multiple queries per custom metric

Problem to solve

Currently we do not allow users to create a custom metric which uses multiple queries. Some examples of where you would want to do this, are: various percentiles, max and avg.

For a concrete example, consider our sample Workhorse Latency chart which needs to utilize two queries:

  • Average latency: avg(histogram_quantile(0.95, rate(gitlab_workhorse_request_duration_seconds_bucket[5m])))
  • Max latency: max(histogram_quantile(0.95, rate(gitlab_workhorse_request_duration_seconds_bucket[5m])))

This is because the query is different in order to calculate the average and maximum latencies. Without this support, it will need to be two charts which is not an effective use of space.

Target audience

DevOps Persona

Further details

Proposal

We should enhance our New Metric page to also support multiple queries. We should support the same options that are supported in the underlying data model.

  • Link Query and Unit Label fields together
  • Add the option to add an additional query, for example a + type icon
  • When adding new query, add an additional pair of Query and Unit Label fields to the list

What does success look like, and how can we measure that?

A user is able to define multiple queries on a single chart, using custom metrics.

Links / references

Edited by silv