# What this PR does Prepare insight metrics for adding `service_name` label. This PR updates metrics cache structure, supporting both old and new version of cache. `service_name` label can be added with additional PR when all metric cache is updated. ## Which issue(s) this PR closes https://github.com/grafana/oncall-private/issues/2610 ## 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] Added the relevant release notes label (see labels prefixed w/ `release:`). These labels dictate how your PR will show up in the autogenerated release notes.
70 lines
1.8 KiB
Python
70 lines
1.8 KiB
Python
import datetime
|
|
import typing
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
class AlertGroupStateDict(typing.TypedDict):
|
|
firing: int
|
|
acknowledged: int
|
|
silenced: int
|
|
resolved: int
|
|
|
|
|
|
class AlertGroupsTotalMetricsDict(typing.TypedDict):
|
|
integration_name: str
|
|
team_name: str
|
|
team_id: int
|
|
org_id: int
|
|
slug: str
|
|
id: int
|
|
services: typing.Dict[str, AlertGroupStateDict]
|
|
|
|
|
|
class AlertGroupsResponseTimeMetricsDict(typing.TypedDict):
|
|
integration_name: str
|
|
team_name: str
|
|
team_id: int
|
|
org_id: int
|
|
slug: str
|
|
id: int
|
|
services: typing.Dict[str, list]
|
|
|
|
|
|
class UserWasNotifiedOfAlertGroupsMetricsDict(typing.TypedDict):
|
|
user_username: str
|
|
org_id: int
|
|
slug: str
|
|
id: int
|
|
counter: int
|
|
|
|
|
|
class RecalculateMetricsTimer(typing.TypedDict):
|
|
recalculate_timeout: int
|
|
forced_started: bool
|
|
|
|
|
|
class RecalculateOrgMetricsDict(typing.TypedDict):
|
|
organization_id: int
|
|
force: bool
|
|
|
|
|
|
METRICS_PREFIX = "oncall_" if settings.IS_OPEN_SOURCE else "grafanacloud_oncall_instance_"
|
|
USER_WAS_NOTIFIED_OF_ALERT_GROUPS = METRICS_PREFIX + "user_was_notified_of_alert_groups"
|
|
|
|
ALERT_GROUPS_TOTAL = "oncall_alert_groups_total"
|
|
ALERT_GROUPS_RESPONSE_TIME = "oncall_alert_groups_response_time_seconds"
|
|
|
|
METRICS_RESPONSE_TIME_CALCULATION_PERIOD = datetime.timedelta(days=7)
|
|
|
|
METRICS_CACHE_LIFETIME = 93600 # 26 hours. Should be higher than METRICS_RECALCULATE_CACHE_TIMEOUT
|
|
|
|
METRICS_CACHE_TIMER = "metrics_cache_timer"
|
|
METRICS_RECALCULATION_CACHE_TIMEOUT = 86400 # 24 hours. Should be less than METRICS_CACHE_LIFETIME
|
|
METRICS_RECALCULATION_CACHE_TIMEOUT_DISPERSE = (0, 3600) # 1 hour
|
|
|
|
METRICS_ORGANIZATIONS_IDS = "metrics_organizations_ids"
|
|
METRICS_ORGANIZATIONS_IDS_CACHE_TIMEOUT = 3600 # 1 hour
|
|
|
|
SERVICE_LABEL = "service_name"
|
|
NO_SERVICE_VALUE = "No service"
|