func writeGroups()

in tooling/prometheus-rules/main.go [321:368]


func writeGroups(groups armalertsmanagement.PrometheusRuleGroupResource, into io.Writer) error {
	tmpl, err := template.New("prometheusRuleGroup").Parse(`
resource {{.name}} 'Microsoft.AlertsManagement/prometheusRuleGroups@2023-03-01' = {
  name: '{{.groups.Name}}'
  location: resourceGroup().location
  properties: {
    rules: [
{{- range .groups.Properties.Rules}}
      {
        alert: '{{.Alert}}'
		enabled: {{.Enabled}}
{{- if .Labels}}
		labels: {
{{- range $key, $value := .Labels}}
			{{$key}}: '{{$value}}'
{{- end }}
		}
{{- end -}}
{{- if .Annotations}}
		annotations: {
{{- range $key, $value := .Annotations}}
			{{$key}}: '{{$value}}'
{{- end }}
		}
{{- end }}
		expression: '{{.Expression}}'
{{- if .For }}
        for: '{{.For}}'
{{- end }}
        severity: {{.Severity}}
      }
{{- end -}}
    ]
    scopes: [
      azureMonitoring
    ]
  }
}
`)
	if err != nil {
		return err
	}

	return tmpl.Execute(into, map[string]any{
		"name":   bicepName(groups.Name),
		"groups": groups,
	})
}