Skip to content

Commit

Permalink
feat: add owner attribute to rules and dashboards (#674)
Browse files Browse the repository at this point in the history
* feat: add owner attribute to rules and dashboards

* feat: code quality corrections
  • Loading branch information
michaelpearsonHO authored Sep 17, 2024
1 parent e95ffcf commit 2c80b45
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions monitoring-as-code/mixin-defs/generic-mixin.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ local mixinFunctions = import '../src/lib/mixin-functions.libsonnet';
// Define product name and technow details
local config = {
product: 'generic',
owner: 'enablement team',
applicationServiceName: '',
servicenowAssignmentGroup: '',
// Alerts set to test only - remove/adjust once ready for alerts for production
Expand Down
1 change: 1 addition & 0 deletions monitoring-as-code/mixin-defs/monitoring-mixin.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ local mixinFunctions = import '../src/lib/mixin-functions.libsonnet';
// Define product name and technow details
local config = {
product: 'monitoring',
owner: 'monitoring-owner',
applicationServiceName: 'Monitoring and Logging Components',
servicenowAssignmentGroup: 'HO_PLATFORM',
// Alerts set to test only - remove/adjust once ready for alerts for production
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ local createDocsTextPanel(dashboardName) =
transparent=true
);

// Creates a common set of Grafana dashboard tags for dashboard discovery.
// @param config The global config for the product having its standard tags created.
// @returns string of comma seperated dashboard tags.
local createDashboardTags(config) =
'product:%(product)s,owner:%(owner)s,mac-version:%(macVersion)s' % {
product: config.product,
owner: config.owner,
macVersion: config.macVersion,
};

// Creates the description for an SLI
// @param sliSpec The spec for the SLI having its standard elements created
// @returns The description for the SLI
Expand Down Expand Up @@ -420,4 +430,5 @@ local createServiceTemplates(config) =
createServiceTemplates(config): createServiceTemplates(config),
createAveragedSliTypesPanel(sloTargetLegend, sliSpec, avgSloStatusExpr, avgErrorBudgetExpr, avgSloTargetExpr): createAveragedSliTypesPanel(sloTargetLegend, sliSpec, avgSloStatusExpr, avgErrorBudgetExpr, avgSloTargetExpr),
createDocsTextPanel(dashboardName): createDocsTextPanel(dashboardName),
createDashboardTags(config): createDashboardTags(config),
}
4 changes: 2 additions & 2 deletions monitoring-as-code/src/dashboards/detail-dashboard.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// what the service is doing

// MaC imports
local stringFormattingFunctions = import '../util/string-formatting-functions.libsonnet';
local macConfig = import '../mac-config.libsonnet';
local stringFormattingFunctions = import '../util/string-formatting-functions.libsonnet';
local dashboardFunctions = import './dashboard-standard-elements.libsonnet';

// Grafana imports
Expand Down Expand Up @@ -301,7 +301,7 @@ local createDetailDashboard(journeyKey, config, links, sliSpecList) =
dashboard.new(
title=stringFormattingFunctions.capitaliseFirstLetters(std.join(' / ', [macConfig.macDashboardPrefix.title, config.product, journeyKey, 'detail'])),
uid=std.join('-', [macConfig.macDashboardPrefix.uid, config.product, journeyKey, 'detail']),
tags=[config.product, 'mac-version: %s' % config.macVersion, journeyKey, 'detail-view'],
tags=std.split(dashboardFunctions.createDashboardTags(config), ',') + ['journey:' + journeyKey, 'view:detail'],
schemaVersion=18,
editable=true,
time_from='now-3h',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ local createJourneyDashboards(config, sliList, links) =
dashboard.new(
title=stringFormattingFunctions.capitaliseFirstLetters(std.join(' / ', [macConfig.macDashboardPrefix.title, config.product, journeyKey])),
uid=std.join('-', [macConfig.macDashboardPrefix.uid, config.product, journeyKey]),
tags=[config.product, 'mac-version: %s' % config.macVersion, journeyKey, 'journey-view'],
tags=std.split(dashboardFunctions.createDashboardTags(config), ',') + ['journey:' + journeyKey, 'view:journey'],
schemaVersion=18,
editable=true,
time_from='now-3h',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ local createProductDashboard(config, sliList, links) =
dashboard.new(
title=stringFormattingFunctions.capitaliseFirstLetters(std.join(' / ', [macConfig.macDashboardPrefix.title, config.product])),
uid=std.join('-', [macConfig.macDashboardPrefix.uid, config.product]),
tags=[config.product, 'mac-version: %s' % config.macVersion, 'product-view'],
tags=std.split(dashboardFunctions.createDashboardTags(config), ',') + ['view:product'],
schemaVersion=18,
editable=true,
time_from='now-3h',
Expand Down
1 change: 1 addition & 0 deletions monitoring-as-code/src/mac-config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ local alertPayloadTemplate = {
assignment_group: '%(config.servicenowAssignmentGroup)s',
runbook_id: '%(runbookUrl)s',
aws_account: '%(config.awsAccount)s',
owner: '%(config.owner)s',
};

// File exports
Expand Down
2 changes: 2 additions & 0 deletions monitoring-as-code/src/mixin-builder.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ local updateConfig(passedConfig) =
grafanaUrl: getUrl('grafana', passedConfig.grafanaUrl, account),
// looking to amend
silenceUrl: if std.objectHas(passedConfig, 'alertmanagerUrl') then getUrl('alertmanager', passedConfig.alertmanagerUrl, account) else getUrl('grafana', passedConfig.grafanaUrl, account),
owner: if std.objectHas(passedConfig, 'owner') then passedConfig.owner else passedConfig.servicenowAssignmentGroup,
templates: dashboardFunctions.createServiceTemplates(passedConfig),
};

Expand All @@ -47,6 +48,7 @@ local updateSliSpecList(config, passedSliSpecList) =
[sliKey]+: {
sliLabels: {
service: config.product,
owner: config.owner,
sli: sliKey,
journey: journeyKey,
mac_version: config.macVersion,
Expand Down

0 comments on commit 2c80b45

Please sign in to comment.