Skip to content

Commit

Permalink
602 fix dashboard and silence urls (#603)
Browse files Browse the repository at this point in the history
* add support for grafana alertmanager silence url

* refactor: minor change to alertmanager config for alerts

* refactor: correct grafana silence path

* fix: minor corrections to monitoring-mixin and deploy script

* fix: remove account and environment parameters from docker run

* refactor: remove redundant comment

---------

Co-authored-by: peterjakemanHO <[email protected]>
  • Loading branch information
michaelpearsonHO and peterjakemanHO authored Aug 14, 2023
1 parent 0344c82 commit b823360
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion monitoring-as-code/run-mixin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ mkdir "$PWD"/_input
cp "$input_path"/"$mixin"-mixin.jsonnet "$PWD"/_input/mixin.jsonnet

# Errors if account is not np, pr or localhost
(echo "$account" | grep -v -Eq "^(np|pr|localhost)$") &&
(echo "$account" | grep -v -Eq "^(np|pr|localhost|green)$") &&
echo "Invalid account type" >&2 &&
exit 1

Expand Down
13 changes: 11 additions & 2 deletions monitoring-as-code/src/alerts/burn-rate-alerts.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ local createBurnRateAlerts(config, sliSpec, sliKey, journeyKey) =
local alertName = std.join('_', [std.strReplace(macConfig.macDashboardPrefix.uid, '-', '_'), config.product, journeyKey, sliKey, sliSpec.sliType, 'ErrorBudgetBurn']),
local severity = getSeverity(errorBudgetBurnWindow, config, sliSpec),
local alertTitle = createAlertTitle(errorBudgetBurnWindow, config, sliSpec, sliKey, journeyKey),
local grafSilencePath = 'alerting/silence/new?alertmanager=alertmanager&matcher=alertname=%(alertName)s' % {
alertName: alertName,
},
local amSilencePath = '#/silences/new?filter={alertname%%3D%%22%(alertName)s%%22, journey%%3D%%22%(journey)s%%22, service%%3D%%22%(service)s%%22}' % {
alertName: alertName,
journey: journeyKey,
service: config.product,
},

local alertPayloadConfig = getAlertPayloadConfig(alertName, severity, alertTitle, errorBudgetBurnWindow, config, sliSpec, sliKey, journeyKey),
local alertPayload = createAlertPayload(alertPayloadConfig),
Expand Down Expand Up @@ -137,8 +145,9 @@ local createBurnRateAlerts(config, sliSpec, sliKey, journeyKey) =
journeyUid: std.join('-', [macConfig.macDashboardPrefix.uid, config.product, journeyKey]),
environment: if std.objectHas(config, 'generic') && config.generic then '' else '?var-environment=%s' % config.environment,
},
silenceurl: '%(alertmanagerUrl)s/#/silences/new?filter={alertname%%3D%%22%(alertName)s%%22, journey%%3D%%22%(journey)s%%22, service%%3D%%22%(service)s%%22}' % {
alertmanagerUrl: config.alertmanagerUrl,
silenceurl: '%(silenceUrl)s/%(silencePath)s' % {
silenceUrl: config.silenceUrl,
silencePath: if std.objectHas(config, 'alertmanagerUrl') then amSilencePath else grafSilencePath,
alertName: alertName,
journey: journeyKey,
service: config.product,
Expand Down
3 changes: 2 additions & 1 deletion monitoring-as-code/src/mixin-builder.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ local updateConfig(passedConfig) =
account: account,
macVersion: macVersion,
grafanaUrl: getUrl('grafana', passedConfig.grafanaUrl, account),
alertmanagerUrl: getUrl('alertmanager', passedConfig.alertmanagerUrl, account),
// looking to amend
silenceUrl: if std.objectHas(passedConfig, 'alertmanagerUrl') then getUrl('alertmanager', passedConfig.alertmanagerUrl, account) else getUrl('grafana', passedConfig.grafanaUrl, account),
templates: dashboardFunctions.createServiceTemplates(passedConfig),
};

Expand Down

0 comments on commit b823360

Please sign in to comment.