Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can I use the alertmanager templates? #70

Open
mulderx opened this issue Sep 23, 2021 · 5 comments
Open

can I use the alertmanager templates? #70

mulderx opened this issue Sep 23, 2021 · 5 comments

Comments

@mulderx
Copy link

mulderx commented Sep 23, 2021

hello Thanks for prometheus_bot.

can I use the alertmanager templates for the telegram templates?

thank you~

@mulderx
Copy link
Author

mulderx commented Nov 4, 2021

I use the production_example.tmpl but

Alert: <a href="{{ $val.GeneratorURL }}">{{ index $val.Annotations "name" }}</a>

didn't show anything

how can I fix it?

out put

~~~ Alerting ~~~
alertname = service_down

Status: FIRING 🔥

Active Alert List:
  Alert:  **<--- didn't show anything**
  Current value:Severity: critical
  Active from: 11/04/2021 16:30:20
  
  description: The service blackbox_http instance xxx is Down
  summary: instance xxx can't work!!!

@hryamzik
Copy link
Collaborator

hryamzik commented Nov 5, 2021

You can try to ask @AndreaGreco about that template. Generally you can always sniff traffic between the bot and alert manager and add also log messages in go code.

@mulderx
Copy link
Author

mulderx commented Nov 8, 2021

You can try to ask @AndreaGreco about that template. Generally you can always sniff traffic between the bot and alert manager and add also log messages in go code.

ok! thank you

@AndreaGreco
Copy link
Contributor

AndreaGreco commented Nov 8, 2021

You can try to ask @AndreaGreco about that template. Generally you can always sniff traffic between the bot and alert manager and add also log messages in go code.

ok! thank you

Hi, pass too many years i don't remember for.
Read source code in main.go, if found solution right.
if problem persist write here again and i will try help you by reading source

@woloss
Copy link

woloss commented Mar 15, 2022

Alert: <a href="{{ $val.GeneratorURL }}">{{ index $val.Annotations "name" }}</a>

didn't show anything

how can I fix it?

Well, kinda late answer.
Config with alerts, which configured on Prometheus side, contains annotations section. This is pure json (key/value).
If you want to get value here - Alert: {{ index $val.Annotations "name" }} Current value - {{ $val.Annotations "value" }}
You must add one more annotation, something like:

    annotations:
      title: '{{ $labels.instance }}'
      name: 'Instance Alert'
      value: 'Some Value'

Also, you should exclude those keys from loop (based on production_example.tmpl)

  Active from: {{ $val.StartsAt | str_FormatDate }}
  {{ range $key, $value := $val.Annotations -}}
  {{ if and (and (ne $key "name") (ne $key "value")) (ne $key "measureUnit") }}  -<<<< There
  {{$key}}: {{$value}}
  {{- end -}}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants