mr-karan / calert

🔔 Send alert notifications to Google Chat via Prometheus Alertmanager
MIT License
158 stars 58 forks source link

executing \"message.tmpl\" at <toUpper>: invalid value; expected string #54

Closed Allaman closed 1 year ago

Allaman commented 2 years ago

Hi,

first of all thanks for this project!

I am trying to set this up in our cluster and get this error for my test alert:

calert-6b5574c764-mzq5z time="2022-11-30T15:25:43Z" level=error msg="Error parsing values in template" error="template: message.tmpl:1:24: executing \"message.tmpl\" at <toUpper>: invalid value; expected string"
calert-6b5574c764-mzq5z time="2022-11-30T15:25:43Z" level=error msg="error preparing message" error="template: message.tmpl:1:24: executing \"message.tmpl\" at <toUpper>: invalid value; expected string"

This is how message.tmpl within the container looks like:

root@calert-6b5574c764-mzq5z:/app# cat static/message.tmpl
*({{ .Labels.severity | toUpper }}) {{ .Labels.alertname | Title }} - {{ .Status | Title }}*
{{ range .Annotations.SortedPairs -}}
{{ .Name | Title }}: {{ .Value}}
{{ end -}}

The configmap :

Data
====
config.toml:
----
[app[]
address = "0.0.0.0:6000"
server_timeout = "60s"
enable_request_logs = true
log = "debug"
[providers.cp[]
type = "google_chat" # Type of provider. Currently supported value is `google_chat`.
endpoint = "<webhook>" # Google Chat Webhook URL
max_idle_conns =  50 # Max idle connections in the HTTP Client.
timeout = "30s" # Timeout for making requests to Provider.
template = "static/message.tmpl" # Path to specify the message template path.
thread_ttl = "12h" # Timeout to keep active alerts in memory. Once this TTL expires, a new thread will be created.
dry_run = true

message.tmpl:
----
*({{ .Labels.severity | toUpper }}) {{ .Labels.alertname | Title }} - {{ .Status | Title }}*
{{ range .Annotations.SortedPairs -}}
{{ .Name | Title }}: {{ .Value}}
{{ end -}}

BinaryData
====

calert v2.0.4

Any hint is appreciated!

mr-karan commented 1 year ago

Do your labels have a severity key ?

Allaman commented 1 year ago

@mr-karan Thanks! That was it. I knew it must be something trivial but that was too trivial ;)