Refactor Prometheus results handling
What does this MR do?
Knowing the result type of prometheus queries is important, this refactor adds this to the data we pull from prometheus, so charts have more details on how information should be displayed.
Why do this?
- Each normalization operation should be aware of the
resultType
so data can be handled according to the type, without risking ignoring data. - Some data is duplicated to allow panels to easily access data available to them.
- If user uses
query
(instead ofquery_range
) the data shape will be consistent. -
matrix
shaped data is still the default and priority.
Screenshots
Sanity check:
As a simple check, I created queries that would fetch both matrix
and vector
result types to see how they are displayed:
This is the dashboard source
---
dashboard: Environment metrics
priority: 1
panel_groups:
- group: System metrics (Kubernetes)
priority: 15
panels:
- title: Memory Usage (Total) 01
type: area-chart
y_label: Total Memory Used (GB)
metrics:
- id: system_metrics_kubernetes_container_memory_total
metric_id: 1
query_range: avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"})
by (job)) without (job) /1024/1024/1024
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 02
type: area-chart
y_label: Total Memory Used (GB)
metrics:
- id: metric_2
metric_id: 2
query_range: container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"}
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 03
type: area-chart
y_label: Total Memory Used (GB)
metrics:
- id: metric_3
metric_id: 3
query: avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"})
by (job)) without (job) /1024/1024/1024
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 04
type: area-chart
y_label: Total Memory Used (GB)
metrics:
- id: metric_4
metric_id: 4
query: container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"}
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 05
type: single-stat
y_label: Total Memory Used (GB)
metrics:
- id: metric_5
metric_id: 5
query: avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"})
by (job)) without (job) /1024/1024/1024
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 06
type: single-stat
y_label: Total Memory Used (GB)
metrics:
- id: metric_6
metric_id: 6
query: container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"}
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 07
type: column
y_label: Total Memory Used (GB) 7
metrics:
- id: metric_7
metric_id: 7
query: avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"})
by (job)) without (job) /1024/1024/1024
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 08
type: column
y_label: Total Memory Used (GB) 8
metrics:
- id: metric_8
metric_id: 8
query: container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"}
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 09
type: bar
y_label: Total Memory Used (GB) 9
metrics:
- id: metric_9
metric_id: 9
query: avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"})
by (job)) without (job) /1024/1024/1024
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 10
type: bar
y_label: Total Memory Used (GB) 10
metrics:
- id: metric_10
metric_id: 10
query: container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"}
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 11
type: heatmap
y_label: Total Memory Used (GB) 11
metrics:
- id: metric_11
metric_id: 11
query: avg(sum(container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"})
by (job)) without (job) /1024/1024/1024
label: Total (GB)
unit: GB
- title: Memory Usage (Total) 12
type: heatmap
y_label: Total Memory Used (GB) 12
metrics:
- id: metric_12
metric_id: 12
query: container_memory_usage_bytes{container_name!="POD",pod_name=~"^{{ci_environment_slug}}-(.*)",namespace="{{kube_namespace}}"}
label: Total (GB)
unit: GB
Does this MR meet the acceptance criteria?
Conformity
- [-] Changelog entry
- [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides - [-] Database guides
- [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
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 #220492 (closed)
Edited by 🤖 GitLab Bot 🤖