Hi Rajesh,

The Alertmanager's webhook integration sends a generic JSON payload (see
https://prometheus.io/docs/alerting/latest/configuration/#webhook_config)
that will not formatted in a way that MS Teams' own specific webhook
receivers expect. You will have to run some kind of adapter process in
between the Alertmanager and MS Teams. It looks like
https://github.com/idealista/prom2teams might be doing what you are looking
for.

Regards,
Julius

On Fri, Jun 2, 2023 at 12:22 AM Rajesh Singh <[email protected]>
wrote:

> I have following alert-rules.yaml
>
>     groups:
>     - name: alert.rules
>       rules:
>       - alert: HostOutOfMemory
>         expr: ((node_memory_MemAvailable_bytes /
> node_memory_MemTotal_bytes) * 100) < 25
>         for: 5m
>         labels:
>           severity: warning
>         annotations:
>           summary: "Host out of memory (instance {{ $labels.instance }})"
>           description: "Node memory is filling up (< 25% left)\n  VALUE =
> {{ $value }}\n  LABELS: {{ $labels }}"
>
>       - alert: HostOutOfDiskSpace
>         expr: (sum(node_filesystem_free_bytes) /
> sum(node_filesystem_size_bytes) * 100) < 30
>         # expr: (node_filesystem_avail{mountpoint="/"}  * 100) /
> node_filesystem_size{mountpoint="/"} < 50
>         for: 1s
>         labels:
>           severity: warning
>         annotations:
>           summary: "Host out of disk space (instance {{ $labels.instance
> }})"
>           description: "Disk is almost full (< 30% left)\n  VALUE = {{
> $value }}\n  LABELS: {{ $labels }}"
>
>       - alert: HostHighCpuLoad
>         expr: ((sum by(instance)
> (irate(node_cpu_seconds_total{mode!="idle"}[5m])) / on(instance) group_left
> sum by (instance)((irate(node_cpu_seconds_total{}[5m])))) * 100) > 80
>         # expr: (sum by (instance)
> (irate(node_cpu{job="node_exporter_metrics",mode="idle"}[5m]))) > 80
>         for: 5m
>         labels:
>           severity: warning
>         annotations:
>           summary: "Host high CPU load (instance {{ $labels.instance }})"
>           description: "CPU load is > 80%\n  VALUE = {{ $value }}\n
>  LABELS: {{ $labels }}"
>
> I have following alertmanager.yaml:
>
>     route:
>       receiver: 'teams'
>       group_wait: 30s
>       group_interval: 5m
>
>     receivers:
>     - name: 'teams'
>       webhook_configs:
>       - send_resolved: true
>         url: '<my-msteams-webhook-url>'
>
> My alertmanager does receives the alerts fired by prometheus:
>
> [image: r/movies - How to pass extra text or summary field to promentehus
> alertmanager webhook for ms teams]
>
> But it does not fire them back to MS teams.
>
> I checked alertmanagers log. It has following message:
>
>     ts=2023-06-01T21:57:43.396Z caller=dispatch.go:352 level=error
> component=dispatcher msg="Notify for alerts failed" num_alerts=1
> err="teams/webhook[0]: notify retry canceled due to unrecoverable error
> after 1 attempts: unexpected status code 400: <my-msteams-webhook-url>:
> Summary or Text is required."
>
> Notice that it says "Summary or Text is required.". I tried adding summary:
>
>     receivers:
>     - name: 'teams'
>       webhook_configs:
>       - send_resolved: true
>         url: 'my-msteams-webhook-url'
>         http_config:
>           summary: {{ .CommonAnnotations.summary }}
>
> But now alertsmanager logs says:
>
>     Loading configuration file failed. field summary not found in type
> config.plain
>
> I tried adding `params`:
>
>         http_config:
>           params:
>               summary: {{ .CommonAnnotations.summary }}
>
> But, now it gives me error
>
>     field params not found in type config.plain
>
> How can I pass summary and/or text to MS Teams?
>   [1]: https://i.stack.imgur.com/j5UBO.png
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/39abdbf1-3348-4613-a807-7691352ed091n%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/39abdbf1-3348-4613-a807-7691352ed091n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>


-- 
Julius Volz
PromLabs - promlabs.com

-- 
You received this message because you are subscribed to the Google Groups 
"Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/prometheus-users/CAObpH5wHVK1LkELz2H5bwutOhXi%3DpGD7dqSOhu5rcwjV3Xmq%3DA%40mail.gmail.com.

Reply via email to