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

Question <Connector1> in Configuring Prometheus #62

Closed
Alexvianet opened this issue Apr 10, 2018 · 21 comments
Closed

Question <Connector1> in Configuring Prometheus #62

Alexvianet opened this issue Apr 10, 2018 · 21 comments

Comments

@Alexvianet
Copy link

can U provide some example of this url:
in prom2teams i have:
Host: localhost
Port: 8089
Connector:
https://outlook.office.com/webhook/XXXXXXXXXXXXX@XXXXXXXXX/IncomingWebhook/XXXXXXXX

So in Prometheus Configuration i have to add:
url: 0.0.0.0:8089/v2/https://outlook.office.com/webhook/XXXXXXXXXXXXX@XXXXXXXXX/IncomingWebhook/XXXXXXXX

or
0.0.0.0:8089/v2/webhook/XXXXXXXXXXXXX@XXXXXXXXX/IncomingWebhook/XXXXXXXX

@Gkrlo
Copy link
Collaborator

Gkrlo commented Apr 10, 2018

Hi @Alexvianet :)
'Connector' is the connector's name you have. So the endpoint to send the HTTP POST requests is:
'0.0.0.0:8089/v2/Connector'.
Just for letting you know also, using the '/v2' allows you to change 'Connector' for something more specific (e.g 'Team1' , sending to '0.0.0.0:8089/v2/Team1')
Hope this helps. If you need more help don't hesitate to ask us.
Regards.

@Alexvianet
Copy link
Author

thanks i got it

@Alexvianet
Copy link
Author

Alexvianet commented Apr 10, 2018

@Gkrlo I Got
2018-04-10 10:55:37,832 - werkzeug - INFO - 10.233.170.15 - - [10/Apr/2018 10:55:37] "POST /v2/Connector HTTP/1.1" 404 -

[Microsoft Teams]
Connector: "https://outlook.office.com/webhook/XXXXXXXXXXXXX@XXXXXXXXX/IncomingWebhook/XXXXXXXX

[HTTP Server]
Host: 0.0.0.0

@dortegau dortegau reopened this Apr 10, 2018
@jnogol
Copy link
Collaborator

jnogol commented Apr 10, 2018

Hi @Alexvianet,

We're working on this issue, that is related to #61. Stay tuned :)

@jnogol
Copy link
Collaborator

jnogol commented Apr 11, 2018

Hi @Alexvianet,

Prom2teams v2.0.3 was just released. Please check if it solves this issue and if not so, provide us with feedback.

Regards,
Jose

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018 via email

@jnogol
Copy link
Collaborator

jnogol commented Apr 11, 2018

Hmmm... Just tried again and works perfectly for me. How are you setting up Prom2teams? Did you update your Prom2teams version?

Here's my testing docker-compose.yml, in case you're using Docker:

version: '3'
services:
 prom2teams:
   image: idealista/prom2teams
   hostname: prom2teams
   ports:
   - "8089:8089"
   environment:
     - PROM2TEAMS_CONNECTOR=myconnectorurlwithoutquotes

And then:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{"status":"Resolved","alerts":[{"annotations":{"summary":"Disk usage alert on CS30.evilcorp","description":"disk usage 93% on rootfs device"},"endsAt":"2017-05-09T07:01:37.803Z","generatorURL":"my.prometheusserver.url","startsAt":"2017-05-09T07:01:37.803Z","status":"Resolved","labels":{"fstype":"rootfs","mounterpoint":"/","instance":"cs30.evilcorp","device":"rootfs","job":"fsociety","alertname":"DiskSpace","severity":"severe"}}],"receiver":"test_webhook","externalURL":"my.prometheusalertmanager.url","version":"4"}' 'http://localhost:8089/v2/Connector'

and got:
imagen

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018

I use it in prometheus VM i have unzip 2.0.3.zip and run prom2teams with

#!/bin/bash

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

RUN_DIR=/var/vcap/sys/run/prom2teams
LOG_DIR=/var/vcap/sys/log/prom2teams
mkdir -p ${RUN_DIR} ${LOG_DIR}

PIDFILE=${RUN_DIR}/prom2teams.pid

source /var/vcap/packages/prom2teams/common/utils.sh
exec 1>> ${LOG_DIR}/$(basename "$0").stdout.log
exec 2>> ${LOG_DIR}/$(basename "$0").stderr.log

export PATH=/var/vcap/packages/prom2teams/prom2teams/bin:${PATH}

case $1 in
  start)
    pid_guard ${PIDFILE} "prom2teams"
    echo $$ > ${PIDFILE}

    ulimit -n 65536

    exec prom2teams --configpath /var/vcap/jobs/prom2teams/config/prom2teams-config.ini \
      >>  ${LOG_DIR}/prom2teams.stdout.log \
      2>> ${LOG_DIR}/prom2teams.stderr.log
    ;;

  stop)
    kill_and_wait ${PIDFILE}
    ;;

  *)
    echo "Usage: $0 {start|stop}"
    exit 1
  ;;

esac
exit 0

and my config/prom2teams-config.ini

[Microsoft Teams]
# At least one connector is required here
Connector: "https://outlook.office.com/webhook/-417e-4424-ae7f-@c45b48f3-13bb-448b-9356/IncomingWebhook/1081496a9339355914cbd79f/bf23d3c7-02ca-479f-9578-"
# AnotherConnector: <webhook url>
# ...
#
[HTTP Server]
Host: 0.0.0.0

#
# [Log]
# Level: <loglevel (DEBUG|INFO|WARNING|ERROR|CRITICAL)> # default: DEBUG
# Path: <log file path>  # default: /var/log/prom2teams/prom2teams.log

# [Template]
# Path: <Jinja2 template path> # default: app resources template

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018

when i run Tour Curl, I got:

<title>404 Not Found</title>

Not Found

The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.

and
2018-04-11 12:38:23,651 - werkzeug - INFO - 127.0.0.1 - - [11/Apr/2018 12:38:23] "POST /v2/Connector HTTP/1.1" 404 -
in logs

@Alexvianet
Copy link
Author

I am on 99% sure that i fuckuped some where)

@jnogol
Copy link
Collaborator

jnogol commented Apr 11, 2018

Try removing the quotes from the connector and restart Prom2teams. Plus, it looks like that your webhook url is incomplete. I don't know if that was on purpose (if so, well done :) )

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018

i have cut it in insecure stuff =)
works now for some reason there was another prom2teams 2.0.1 that was installed with pip3, was removed now it works fine.

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018

what config U have on Prometheus side ?
i have alermanager config:

route:
  receiver: slack-receiver
receivers: [{"name":"slack-receiver","webhook_configs":[{"send_resolved":true,"url":"http://localhost:8089/v2/Connector"}]}]

without any templates

@jnogol
Copy link
Collaborator

jnogol commented Apr 11, 2018

There seems to be a misunderstanding here. Prom2teams is meant to be used with webhook_config:

https://github.com/idealista/prom2teams#configuring-prometheus
https://prometheus.io/docs/alerting/configuration/#%3Creceiver%3E
https://prometheus.io/docs/alerting/configuration/#%3Cwebhook_config%3E

For instance:

receivers:

- name: 'My Prom2Teams server'
  webhook_configs:
  - url: http://prom2teams:8089/v2/connector
    send_resolved: true

Try it this way and let us know if it works

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018 via email

@jnogol
Copy link
Collaborator

jnogol commented Apr 11, 2018

Ooops, sorry. Not enough caffeine in my system yet 😆

So I read in a previous message that it is working now?

@Alexvianet
Copy link
Author

Alexvianet commented Apr 11, 2018 via email

@Alexvianet
Copy link
Author

can U send me your alertmanager template, ill be very grateful

@Alexvianet
Copy link
Author

Finally works now thanks a lot

@jayraviteja
Copy link

Finally works now thanks a lot

How it worked, could you pls confirm?

@Maleware
Copy link

Maleware commented Jan 17, 2023

Hey to this issue, I want to use prom2teams and my config.ini looks like this:
`[HTTP Server]
Host: 0.0.0.0
Port: 8089

[Microsoft Teams]
Connector: My-Webhook
[Group Alerts]
Field:

[Log]
Level: DEBUG/opt/prom2teams`

My alertmanager bit looks like this:

receivers: # 'null' is a workaround for a bug in alertmanager. Won't work without this additional receiver name. - name: 'null' - name: 'prometheus-msteams' webhook_configs: - url: 0.0.0.0:8089/v2/Connector send_resolved: true #- '/etc/alertmanager/config/*.tmpl' route: receiver: 'prometheus-msteams' group_by: [alertname]

For this bit, I get a error with alertmanager, stating it cannot parse the url. That's fine I guess.

Changing to: - url: http://0.0.0.0:8089/v2/Connector gives me a connection refused. Using https:// gives me the exact same error.

Can somebody help me?

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

6 participants