feat(alerts): user series-name for notifications message
This commit is contained in:
parent
bc7ad49c63
commit
ccb1e0a23a
4 changed files with 14 additions and 8 deletions
|
|
@ -5,7 +5,7 @@ def get_all_alerts():
|
|||
with pg_client.PostgresClient(long_query=True) as cur:
|
||||
query = """SELECT -1 AS tenant_id,
|
||||
alert_id,
|
||||
project_id,
|
||||
projects.project_id,
|
||||
detection_method,
|
||||
query,
|
||||
options,
|
||||
|
|
@ -13,10 +13,13 @@ def get_all_alerts():
|
|||
alerts.name,
|
||||
alerts.series_id,
|
||||
filter,
|
||||
change
|
||||
change,
|
||||
COALESCE(metrics.name || '.' || (COALESCE(metric_series.name, 'series ' || index)) || '.count',
|
||||
query ->> 'left') AS series_name
|
||||
FROM public.alerts
|
||||
LEFT JOIN metric_series USING (series_id)
|
||||
INNER JOIN projects USING (project_id)
|
||||
LEFT JOIN metric_series USING (series_id)
|
||||
LEFT JOIN metrics USING (metric_id)
|
||||
WHERE alerts.deleted_at ISNULL
|
||||
AND alerts.active
|
||||
AND projects.active
|
||||
|
|
|
|||
|
|
@ -228,7 +228,7 @@ def generate_notification(alert, result):
|
|||
"alertId": alert["alertId"],
|
||||
"tenantId": alert["tenantId"],
|
||||
"title": alert["name"],
|
||||
"description": f"has been triggered, {alert['query']['left']} = {left} ({alert['query']['operator']} {right}).",
|
||||
"description": f"has been triggered, {alert['seriesName']} = {left} ({alert['query']['operator']} {right}).",
|
||||
"buttonText": "Check metrics for more details",
|
||||
"buttonUrl": f"/{alert['projectId']}/metrics",
|
||||
"imageUrl": None,
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ def get_all_alerts():
|
|||
with pg_client.PostgresClient(long_query=True) as cur:
|
||||
query = """SELECT tenant_id,
|
||||
alert_id,
|
||||
project_id,
|
||||
projects.project_id,
|
||||
detection_method,
|
||||
query,
|
||||
options,
|
||||
|
|
@ -13,10 +13,13 @@ def get_all_alerts():
|
|||
alerts.name,
|
||||
alerts.series_id,
|
||||
filter,
|
||||
change
|
||||
change,
|
||||
COALESCE(metrics.name || '.' || (COALESCE(metric_series.name, 'series ' || index)) || '.count',
|
||||
query ->> 'left') AS series_name
|
||||
FROM public.alerts
|
||||
LEFT JOIN metric_series USING (series_id)
|
||||
INNER JOIN projects USING (project_id)
|
||||
LEFT JOIN metric_series USING (series_id)
|
||||
LEFT JOIN metrics USING (metric_id)
|
||||
WHERE alerts.deleted_at ISNULL
|
||||
AND alerts.active
|
||||
AND projects.active
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ def generate_notification(alert, result):
|
|||
"alertId": alert["alertId"],
|
||||
"tenantId": alert["tenantId"],
|
||||
"title": alert["name"],
|
||||
"description": f"has been triggered, {alert['query']['left']} = {left} ({alert['query']['operator']} {right}).",
|
||||
"description": f"has been triggered, {alert['seriesName']} = {left} ({alert['query']['operator']} {right}).",
|
||||
"buttonText": "Check metrics for more details",
|
||||
"buttonUrl": f"/{alert['projectId']}/metrics",
|
||||
"imageUrl": None,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue