metalmatze / alertmanager-bot

[deprecated] Bot for Prometheus' Alertmanager
MIT License
658 stars 148 forks source link

Runing bot #26

Open metaesAJ opened 6 years ago

metaesAJ commented 6 years ago

Hello, when i'm trying to start bot with docker-compose file i see : level=error ts=2018-08-20T15:21:44.274865Z caller=main.go:134 msg="failed to create bot" err="http.Post failed: Post https://api.telegram.org/bot678959762:AAHhfz2K-TSh_Ptij_k21iNFy4vTXQlDoIM/getMe: EOF"

compose file: alertmanager-bot: image: metalmatze/alertmanager-bot:0.2 environment: ALERTMANAGER_URL: alertmanager:9093 BOLT_PATH: /data/bot.db STORE: bolt LISTEN_ADDR: 0.0.0.0:8080 TELEGRAM_ADMIN: '1234567' TELEGRAM_TOKEN: "my token by botfather" volumes:

metaesAJ commented 6 years ago

when i'm trying set admin i see that error : error parsing commandline arguments: strconv.ParseFloat: parsing "my acc": invalid syntax usage: alertmanager-bot --alertmanager.url=ALERTMANAGER.URL --listen.addr=LISTEN.ADDR --store=STORE --telegram.admin=TELEGRAM.ADMIN --telegram.token=TELEGRAM.TOKEN [<flags>]

metalmatze commented 6 years ago

Did you manage to resolve this issue?

tbpoetke commented 5 years ago

Had the same problem, solution is to use the ID Number for TELEGRAM_ADMIN. Its just a numeric value, use userinfobot to get the id

lazysmokier commented 5 years ago

One of the possible reasons may be ISP blocks traffic to telegram. You may use the following command to check if your system have trouble with connectivity to the telegram api:

curl -X POST https://api.telegram.org/bot<TELEGRAM_TOKEN>/getMe

ihtiking commented 5 years ago

This is for CentOS7 system instruction:

  1. Before build Docker image, i'm install 'golang' package: yum install -y golang

  2. Compile file main.go in path: go build ./cmd/alertmanager-bot/main.go ./cmd/alertmanager-bot/main

This is ready Dockerfile, which i'm edited: FROM centos:7 ENV TEMPLATE_PATHS=default.tmpl COPY ./cmd/alertmanager-bot/main /usr/bin/ COPY alpineentrypoint.sh /usr/bin/alertmanager-bot/ COPY default.tmpl /usr/bin/alertmanager-bot/ EXPOSE 8080 ENTRYPOINT ["/usr/bin/alertmanager-bot/alpineentrypoint.sh"]

In file alpineentrypoint.sh i write:

!/bin/sh

/usr/bin/main.

Then we run image: docker start alertmanagerbotimage or we can simple run '/usr/bin/main' in command line.

Done. But, the next hope, run 'main' with key:

./main --alertmanager.url=localhost:9093 --listen.addr=localhost:10443 --store=bolt BOLT_PATH:/tmp/bot.db --telegram.admin=<id number, not text> --telegram.token= --template.paths=/root/alertmanager-bot/default.tmpl

Stay one problem: alertmanager-bot: error: unexpected BOLT_PATH:/tmp/bot.db

Please, help. What binary-script want?

tazhate commented 4 years ago

@ihtiking you should pass BOLT_PATH in another way i think, like option.

isac-seven commented 3 years ago

I'm having the following error using K8s deployment: caller=main.go:215 component=telegram msg="failed to create bot" err="http.Post failed: parse https://api.telegram.org/REDACTED\n/getMe: net/url: invalid control character in URL"

Seems like a '\n' in being appended somewhere to my bot token :thinking:

isac-seven commented 3 years ago

Oh, just found the solution at https://github.com/kubernetes/kubernetes/issues/23404#issuecomment-204835901 !