metalmatze / alertmanager-bot

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

runtime error: invalid memory address or nil pointer dereference #125

Open vyalovvldmr opened 4 years ago

vyalovvldmr commented 4 years ago

I've just run alertmanager-bot in docker swarm cluster + traefik and have got this error:

2020/08/28 20:21:14 http: panic serving 10.0.1.135:36598: runtime error: invalid memory address or nil pointer dereference
goroutine 248 [running]:
net/http.(*conn).serve.func1(0xc0003723c0)
        /usr/local/go/src/net/http/server.go:1767 +0x139
panic(0xa4d780, 0x1024220)
        /usr/local/go/src/runtime/panic.go:679 +0x1b2
github.com/metalmatze/alertmanager-bot/pkg/alertmanager.HandleWebhook.func1(0xbf6400, 0xc0003da1c0, 0xc0000d1100)
        /go/src/github.com/metalmatze/alertmanager-bot/pkg/alertmanager/webhook.go:41 +0x422
net/http.HandlerFunc.ServeHTTP(0xc000320b70, 0xbf6400, 0xc0003da1c0, 0xc0000d1100)
        /usr/local/go/src/net/http/server.go:2007 +0x44
net/http.(*ServeMux).ServeHTTP(0xc0000e9b00, 0xbf6400, 0xc0003da1c0, 0xc0000d1100)
        /usr/local/go/src/net/http/server.go:2387 +0x1bd
net/http.serverHandler.ServeHTTP(0xc00025ae00, 0xbf6400, 0xc0003da1c0, 0xc0000d1100)
        /usr/local/go/src/net/http/server.go:2802 +0xa4
net/http.(*conn).serve(0xc0003723c0, 0xbf8b00, 0xc000194600)
        /usr/local/go/src/net/http/server.go:1890 +0x875
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2928 +0x384

My docker-stack configuration was:

  alertmanager-bot:
    image: metalmatze/alertmanager-bot:0.4.2
    networks:
      - network
    environment:
      - TELEGRAM_ADMIN=<ID>
      - TELEGRAM_TOKEN=<TOKEN>
      - LISTEN_ADDR=0.0.0.0:5054
      - ALERTMANAGER_URL=http://alertmanager:9093
    command:
      - --log.level=info
      - --store=bolt
      - --bolt.path=/data/bot.db
    volumes:
      - alertmanager-bot:/data
    deploy:
      mode: replicated
      replicas: 1
      placement:
        constraints:
          - node.hostname == ${CONSTRAINT}
      resources:
        limits:
          memory: 128M
        reservations:
          memory: 64M
      labels:
        - traefik.enable=true
        - traefik.http.routers.alertmanager-bot-https.rule=Host(`<HOSTNAME>`)
        - traefik.http.routers.alertmanager-bot-https.entrypoints=websecure
        - traefik.http.routers.alertmanager-bot-https.tls=true
        - traefik.http.routers.alertmanager-bot-https.tls.certresolver=hurma
        - traefik.http.services.alertmanager-bot.loadbalancer.server.port=5054
metalmatze commented 3 years ago

Sorry for the late answer. Not sure if this problem still persists.