webhook is not working

417 views
Skip to first unread message

surendra matta

unread,
Jun 24, 2022, 12:25:34 AM6/24/22
to Prometheus Users
Hi Team,

i am sending  multiple alerts one is email alert and another is to msteam channel using webhook.

My configuration in alertmanger .yml

route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'ms_teams'
  routes:
      - receiver: "ms_teams"
        group_wait: 10s
        match_re:
          severity: critical|warning
        continue: true

      - receiver: "send_email"
        group_wait: 10s
        match_re:
          severity: critical
        continue: true

receivers:
  - name: "ms_teams"
    webhook_configs:
      - url: 'https://<mycmp>/webhookb2/094e8920-b8d3-49ee-a7d4-8576b636ecbb@44b79a67-d972-49ba-9167-8eb05f754a1a/IncomingWebhook/76c301af46724afcb5d27366adc7e31e/71493bd4-0176-499c-bc34-1064b9e3e72e'
        send_resolved: true
           
  - name: "send_email"
    email_configs:
      - to: <my cmp email id>
        from : <sample email id>
        smarthost: <my smtp config>
        require_tls: false
        send_resolved: true

if  i test the email individual i am getting email alert but when i include with the   webhook is not working and i am getting 400 status code for webhook and it is impacting the email alert too.

 FYI.. i tested this webhook from Grafana notification channel, it's working and able to get the alerts to  msteams.

Please check the above config and let me know if i miss any thing.

Regards,
Venkat

Brian Candler

unread,
Jun 24, 2022, 3:23:37 AM6/24/22
to Prometheus Users
> i am getting 400 status code for webhook

That means you are invoking the webhook wrongly - 400 means bad request sent by client. The body of the 400 message probably tells you what you're doing wrong.

The JSON body that Alertmanager POSTs is fixed, and defined here:

I am guessing that the webhook receiver that you're sending to needs its data in a different format.

If you google for "alertmanager teams" then the first hit is this:

They are using a third-party package called "prom2teams"  to convert an alertmanager webhook into a form that Teams will accept.

surendra matta

unread,
Jun 25, 2022, 11:12:59 AM6/25/22
to Prometheus Users
i tried to install the prom2teams in windows 2016 , it's throwing below error

Collecting uwsgi==2.0.20
  Using cached uwsgi-2.0.20.tar.gz (804 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [8 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "C:\Users\vsm754\AppData\Local\Temp\pip-install-g0rnnpoc\uwsgi_a3f780df2bae4b2c9c94a3749a636e98\setup.py", line 3, in <module>
          import uwsgiconfig as uc
        File "C:\Users\vsm754\AppData\Local\Temp\pip-install-g0rnnpoc\uwsgi_a3f780df2bae4b2c9c94a3749a636e98\uwsgiconfig.py", line 8, in <module>
          uwsgi_os = os.uname()[0]
      AttributeError: module 'os' has no attribute 'uname'. Did you mean: 'name'?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.


did we have any other alternative, if yes- could you please provide me an example because it's really important to our POC.

Brian Candler

unread,
Jun 25, 2022, 12:00:10 PM6/25/22
to Prometheus Users
os.uname() definitely exists in Linux, but you appear to be trying to run it under Windows.

If you need this urgently for your POC, then the easiest approach will be to run prom2teams under Linux, or under docker.  See http://www.catb.org/~esr/faqs/smart-questions.html#idm585

Maybe you can find a local Python programmer who can modify it to work under Windows.  Then you can submit your enhancement to the prom2teams project.  

If none of those suggestions are any good to you, then please use Google to find other examples of people who have interfaced Alertmanager to Teams, and how they did it.

surendra matta

unread,
Jun 27, 2022, 2:25:56 PM6/27/22
to Prometheus Users
 - name: "ms_teams"
    webhook_configs:
       - url: <mywebnook>
        basic_auth:
          username: <userid>
          password: <pwd>
      send_resolved: true 

can I pass user and pwd like this? Please correct me if I am wrong.

surendra matta

unread,
Jun 27, 2022, 4:10:16 PM6/27/22
to Prometheus Users
it's working I tweaked the http_config

- url: '<webhook>'
      send_resolved: true
      http_config:
        basic_auth:
          username: <username>
          password:  <pwd>

Reply all
Reply to author
Forward
0 new messages