Git Product home page Git Product logo

Comments (4)

TBurda avatar TBurda commented on June 12, 2024 1

Hi @zhan9san

After migrating to Alertmanager, there is an issue with the inability to use the card.tmpl template. For example, the counter function is not defined in Alertmanager. It is necessary to modify the templates, and I would like to inquire if there are any template examples that are compatible with the latest version of Alertmanager.

{{ define "teams.card" }}
{
  "@type": "MessageCard",
  "@context": "http://schema.org/extensions",
  "themeColor": "{{- if eq .Status "resolved" -}}2DC72D
                 {{- else if eq .Status "firing" -}}
                    {{- if eq .CommonLabels.severity "critical" -}}8C1A1A
                    {{- else if eq .CommonLabels.severity "warning" -}}FFA500
                    {{- else -}}808080{{- end -}}
                 {{- else -}}808080{{- end -}}",
  "summary": "{{- if eq .CommonAnnotations.summary "" -}}
                  {{- if eq .CommonAnnotations.message "" -}}
                    {{- if eq .CommonLabels.alertname "" -}}
                      Prometheus Alert
                    {{- else -}}
                      {{- .CommonLabels.alertname -}}
                    {{- end -}}
                  {{- else -}}
                    {{- .CommonAnnotations.message -}}
                  {{- end -}}
              {{- else -}}
                  {{- .CommonAnnotations.summary -}}
              {{- end -}}",
  "title": "Prometheus Alert ({{ .Status | title }})",
  "sections": [ {{$externalUrl := .ExternalURL}}
  {{- range $index, $alert := .Alerts }}{{- if $index }},{{- end }}
    {
      "activityTitle": "[{{ $alert.Annotations.description }}]({{ $externalUrl }})",
      "facts": [
        {{- range $key, $value := $alert.Annotations }}
        {
          {{- if ne $key "description" -}}
            "name": "{{ $key }}",
            "value": "{{ $value }}"
          {{- end -}}
        },
        {{- end -}}
        {{$c := counter}}{{ range $key, $value := $alert.Labels }}{{if call $c}},{{ end }}
        {
          "name": "{{ $key }}",
          "value": "{{ $value }}"
        }
        {{- end }}
      ],
      "markdown": true
    }
    {{- end }}
  ]
}
{{ end }}

from prometheus-msteams.

jemag avatar jemag commented on June 12, 2024 1

Until alert-manager supports adaptative cards it would be nice to keep getting releases with updated dependencies

from prometheus-msteams.

zhan9san avatar zhan9san commented on June 12, 2024

@vibin18

Thanks for your attention. As MSTeams has been integrated in Alertmanager directly. There is no need to forward the messages
through prometheus-msteams. Here is the Alertmanager doc.

Try Alertmanager plz.

from prometheus-msteams.

pchang388 avatar pchang388 commented on June 12, 2024

Getting a bit frustrated with the templating to make it look "nice" in teams - trying to set up a similar alert visual layout as we have see in prometheus-msteams.

For those that already moved to the native Alertmanager msteams integration, happen to have a template that could achieve a similar layout to what we have in prometheus-msteams?

from prometheus-msteams.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.