Skip to content

Display metric label value in single stat panel

What does this MR do?

Single stat charts in the metrics dashboard display the actual metric value. This MR adds support for a new property called field in the YML file so that a particular metric label value can be displayed instead of the actual value. These labels are present in the result set of the PromQL along with the actual value.

Result set for above dashboard

single_stat.yml___Metrics_Dashboard___production___Administrator___sandbox2___GitLab_2020-07-02_12-16-22

Why field?

We're trying to make it easy for Grafana users to migrate to metrics dashboard. Grafana uses field as well. Check the screenshot.

grafana_dashboard

Sample dashboard YML

dashboard: 'Metrics Dev'
panel_groups:
  - group: 'Stat'
    panels:
      - title: "🐤 Before"
        type: "single-stat"
        field: prom_version # <-------- This is the new property
        metrics:
        - id: 1110
          query: 'label_replace(topk(1, count(prometheus_build_info) by (version)), "prom_version", "@$1", "version", "(.*)")'
          label: "Prom version"
          unit: ' '
      - title: "🚀 After"
        type: "single-stat"
        metrics:
        - id: 1111
          query: 'label_replace(topk(1, count(prometheus_build_info) by (version)), "prom_version", "@$1", "version", "(.*)")'
          label: "Prom version"
          unit: ' '

Screenshots

- Before After
If field is present Screen_Shot_2020-07-02_at_12.12.17_PM Screen_Shot_2020-07-02_at_12.12.47_PM
If field is not present Screen_Shot_2020-07-02_at_11.55.01_AM image

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team

Closes #220361 (closed)

Edited by Dhiraj Bodicherla

Merge request reports

Loading