Fix metrics and dashboard (#2895)

# What this PR does

## Which issue(s) this PR fixes
https://github.com/grafana/oncall/issues/2897

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
This commit is contained in:
Yulya Artyukhina 2023-08-29 15:52:24 +02:00 committed by GitHub
parent 1ff6ac3380
commit 4a8d0f3ad3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 34 deletions

View file

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Fixed
- Fix metrics calculation and OnCall dashboard, rename dashboard @Ferril ([#2895](https://github.com/grafana/oncall/pull/2895))
## v1.3.28 (2023-08-29)
### Changed

View file

@ -53,19 +53,19 @@ def is_allowed_to_start_metrics_calculation(organization_id, force=False) -> boo
"""Check if metrics_cache_timer doesn't exist or if recalculation was started by force."""
recalculate_timeout = get_metrics_recalculation_timeout()
metrics_cache_timer_key = get_metrics_cache_timer_key(organization_id)
metrics_cache_timer: typing.Optional[RecalculateMetricsTimer]
metrics_cache_timer = cache.get(metrics_cache_timer_key)
metrics_cache_timer: RecalculateMetricsTimer = cache.get(
metrics_cache_timer_key,
{
if metrics_cache_timer:
if not force or metrics_cache_timer.get("forced_started", False):
return False
else:
metrics_cache_timer["forced_started"] = True
else:
metrics_cache_timer = {
"recalculate_timeout": recalculate_timeout,
"forced_started": force,
},
)
if not force or metrics_cache_timer.get("forced_started", False):
return False
else:
metrics_cache_timer["forced_started"] = True
}
metrics_cache_timer["recalculate_timeout"] = recalculate_timeout
cache.set(metrics_cache_timer_key, metrics_cache_timer, timeout=recalculate_timeout)

View file

@ -59,8 +59,10 @@ class ApplicationMetricsCollector:
# user was notified of alert groups metrics: counter
user_was_notified, missing_org_ids_3 = self._get_user_was_notified_of_alert_groups_metric(org_ids)
# update new metric gradually
missing_org_ids_3 = self._update_new_metric(USER_WAS_NOTIFIED_OF_ALERT_GROUPS, org_ids, missing_org_ids_3)
# This part is used for releasing new metrics to avoid recalculation for every metric.
# Uncomment with metric name when needed.
# # update new metric gradually
# missing_org_ids_3 = self._update_new_metric(USER_WAS_NOTIFIED_OF_ALERT_GROUPS, org_ids, missing_org_ids_3)
# check for orgs missing any of the metrics or needing a refresh, start recalculation task for missing org ids
missing_org_ids = missing_org_ids_1 | missing_org_ids_2 | missing_org_ids_3

View file

@ -79,7 +79,7 @@
"uid": "${datasource}"
},
"gridPos": {
"h": 2,
"h": 3,
"w": 24,
"x": 0,
"y": 2
@ -104,7 +104,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 4
"y": 5
},
"id": 19,
"panels": [],
@ -152,7 +152,7 @@
"h": 7,
"w": 5,
"x": 0,
"y": 5
"y": 6
},
"id": 25,
"options": {
@ -263,7 +263,7 @@
"h": 7,
"w": 6,
"x": 5,
"y": 5
"y": 6
},
"id": 1,
"options": {
@ -363,7 +363,7 @@
"h": 7,
"w": 5,
"x": 11,
"y": 5
"y": 6
},
"id": 29,
"options": {
@ -446,7 +446,7 @@
"h": 7,
"w": 4,
"x": 16,
"y": 5
"y": 6
},
"id": 14,
"options": {
@ -531,7 +531,7 @@
"h": 7,
"w": 4,
"x": 20,
"y": 5
"y": 6
},
"id": 32,
"options": {
@ -648,7 +648,7 @@
"h": 10,
"w": 24,
"x": 0,
"y": 12
"y": 13
},
"id": 24,
"options": {
@ -762,7 +762,7 @@
"h": 9,
"w": 24,
"x": 0,
"y": 22
"y": 23
},
"id": 34,
"options": {
@ -802,7 +802,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 31
"y": 32
},
"id": 11,
"panels": [],
@ -866,7 +866,7 @@
"h": 23,
"w": 12,
"x": 0,
"y": 32
"y": 33
},
"id": 20,
"options": {
@ -982,7 +982,7 @@
"h": 23,
"w": 12,
"x": 12,
"y": 32
"y": 33
},
"id": 21,
"options": {
@ -1052,7 +1052,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 55
"y": 56
},
"id": 38,
"panels": [],
@ -1142,7 +1142,7 @@
"h": 10,
"w": 24,
"x": 0,
"y": 56
"y": 57
},
"id": 36,
"options": {
@ -1236,7 +1236,7 @@
"h": 11,
"w": 12,
"x": 0,
"y": 66
"y": 67
},
"id": 35,
"options": {
@ -1349,7 +1349,7 @@
"h": 11,
"w": 12,
"x": 12,
"y": 66
"y": 67
},
"id": 37,
"options": {
@ -1411,7 +1411,7 @@
"h": 1,
"w": 24,
"x": 0,
"y": 77
"y": 78
},
"id": 12,
"panels": [],
@ -1475,7 +1475,7 @@
"h": 11,
"w": 12,
"x": 0,
"y": 78
"y": 79
},
"id": 22,
"options": {
@ -1591,7 +1591,7 @@
"h": 11,
"w": 12,
"x": 12,
"y": 78
"y": 79
},
"id": 23,
"options": {
@ -1878,7 +1878,7 @@
"time_options": ["5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d"]
},
"timezone": "browser",
"title": "OnCall Metrics",
"version": 1,
"title": "OnCall Insights",
"version": 2,
"weekStart": ""
}

View file

@ -105,7 +105,7 @@
{
"type": "dashboard",
"path": "dashboards/oncall_metrics_dashboard.json",
"name": "OnCall Metrics"
"name": "OnCall Insights"
}
],
"routes": [