Is there some more documention/examples on how to ...
# support
s
Is there some more documention/examples on how to customize alert channel messages/descriptions with those labels? We have several alerts that apply to many services, I'd like to just have the alert name and the specific service_name label in there, including support for multiple services, something "XY: serviceA, serviceB". Right now the default in PagerDuty and the non-configurable e-mail channel start with the very long ruleId and the ruleSource.
n
s
not sure if that's what I'm looking for. I'm looking to adjust what by defaut looks like this in pagerduty
Copy code
ALERT NAME for (ruleId="0196af92-c498-7b1c-aebe-f5fc9d6676dc", ruleSource="<https://DOMAIN/alerts/edit?ruleId=0196af92-c498-7b1c-aebe-f5fc9d6676dc>", service_name="SERVICE", severity="error")
this is now so long that the service name isn't even visible anymore in a number of places such as chat notifications
in comparison, the default template for opsgenie is just the alert name, but I'd really like to have the service name and only that in there, including if there are multiple
s
It's not something configurable yet. We have a plan to improve it. @Sascha Grossenbacher can you leave a comment here https://github.com/SigNoz/signoz/issues/6779? Here is the EPIC that covers the wide range alert related improvements we are working on https://github.com/SigNoz/signoz/issues/3825.
Thank you!
s
thanks for the feedback. I left a comment on the issue for now. as I wrote there, I suspect what I want is possible, at least with PagerDuty, I just have a hard time figuring out the data structures and templating language
s
Right, it is doable but non-trivial. Let me share the alternative template that might help you
s
Copy code
{{- if gt (len .CommonLabels) (len .GroupLabels) -}}
	  {{" "}}(
	  {{- with .CommonLabels.Remove .GroupLabels.Names }}
		{{- range $index, $label := .SortedPairs -}}
		  {{ if $index }}, {{ end }}
		  {{- $label.Name }}="{{ $label.Value -}}"
		{{- end }}
	  {{- end -}}
	  )
	{{- end }}
this is the bit in PagerDuty that displays the labels and I only partially understand it. it somehow removes the service_name if there's more than one. I guess I could just start with a condition that ignores the $label if $label.Name is ruleSource, ruleID, that would already help a lot
s
correct
Try this
Copy code
{{- if gt (len .CommonLabels) (len .GroupLabels) -}}
  {{" "}}(
  {{- with .CommonLabels.Remove .GroupLabels.Names }}
    {{- range $index, $label := .SortedPairs -}}
      {{- if and (ne $label.Name "ruleSource") (ne $label.Name "ruleID") -}}
        {{ if $index }}, {{ end }}
        {{- $label.Name }}="{{ $label.Value -}}"
      {{- end -}}
    {{- end }}
  {{- end -}}
  )
{{- end }}