alertmanager-bot icon indicating copy to clipboard operation
alertmanager-bot copied to clipboard

Runing bot

Open metaesAJ opened this issue 7 years ago • 8 comments

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: - ./srv/monitoring/alertmanager-bot:/data

metaesAJ avatar Aug 20 '18 15:08 metaesAJ

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>]

metaesAJ avatar Aug 20 '18 15:08 metaesAJ

Did you manage to resolve this issue?

metalmatze avatar Aug 31 '18 21:08 metalmatze

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

tbpoetke avatar Dec 25 '18 00:12 tbpoetke

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

lazysmokier avatar Jan 30 '19 10:01 lazysmokier

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?

ihtiking avatar Sep 20 '19 14:09 ihtiking

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

tazhate avatar Jan 18 '20 02:01 tazhate

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 avatar Aug 12 '21 13:08 isac-seven

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

isac-seven avatar Aug 12 '21 13:08 isac-seven