Git Product home page Git Product logo

Comments (7)

satterly avatar satterly commented on May 30, 2024

It seems the alertname variable is only available as a groupLabel in a notification template, and you can't template webhooks. 😕

Any suggestions?

from prometheus-config.

freeseacher avatar freeseacher commented on May 30, 2024

currently i moved from annotations in alert rules to alerta telegram template
mine now is

{% if customer %}Customer: `{{customer}}` {% endif %}

*[{{ status.capitalize() }}] {{ environment }} {{ severity.capitalize() }}*
{{ event | replace("_","\_") }} {{ resource.capitalize() }}

\`\`\`
{{ text }}
\`\`\`

{% if status == 'open' %}[Runbook](https://XXXX/display/NOCRUN/{{ event | replace("_","") }}){% endif %}

It works but that is not what i'm expected to see.

Btw that issue not for solving but probably about fixing doc to bee less frustrating

from prometheus-config.

satterly avatar satterly commented on May 30, 2024

That's very interesting. How is that template picked up? Can you paste an example Prometheus and Alertmanager config file so that I can understand how it all hangs together? Thanks.

from prometheus-config.

satterly avatar satterly commented on May 30, 2024

I've updated the README (by deleting all references to runbook) and the example config (by adding a note) to reflect that alertname is not supported in annotation.

from prometheus-config.

satterly avatar satterly commented on May 30, 2024

@freeseacher your opinion on alerta/alerta#732 would be appreciated. Thanks.

from prometheus-config.

freeseacher avatar freeseacher commented on May 30, 2024

That's very interesting. How is that template picked up? Can you paste an example Prometheus and Alertmanager config file so that I can understand how it all hangs together? Thanks.

alertmanager.yaml

global:
  http_config:
    proxy_url: 'http://proxy:3128'
  smtp_smarthost: mysmtp
  smtp_from: mymail
  smtp_require_tls: false
  smtp_hello: prom
  smtp_auth_username: yyy
  smtp_auth_password: xxx

inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    # Apply inhibition if the alertname is the same.
    equal: ['alertname']

route:
  group_wait: 30s
  group_interval: 1m
  receiver: 'alerta'
  routes: 
    - receiver: 'alerta'
      continue: true
    - receiver: "infra-alert"
      match: 
        scope: infra
    - receiver: "system-alert"
      match: 
        scope: system

receivers:
  - name: "alerta"
    webhook_configs:
    - url: 'https://alerta.XXX/api/webhooks/prometheus?api-key=XXXX'
      send_resolved: true
  - name: "system-alert"
    email_configs:
      - to:  system-alert@XXX
        send_resolved: true 
  - name: "infra-alert"
    email_configs:
      - to:  infra-alert@XXX
        send_resolved: true 

prometheus.yaml

....
rule_files:
  - rules/*.rules.yml
alerting:
  alert_relabel_configs:
    - target_label: environment
      source_labels: ['env']
  alertmanagers:
    - static_configs:
      - targets:
        - alertmanager:9093

tg.tmpl loaded as usual on docker container starts and telegram plugin installed.

from prometheus-config.

satterly avatar satterly commented on May 30, 2024

Thanks for that. I don't quite understand how tg.tmpl is used by the alerta webhook though. Or am I misunderstanding what is happening there?

Either way, I've added support for python templating in the webhook so {{ $labels.alertname }} can simply be replaced with {alertname} now.

from prometheus-config.

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.