---
version: "3"
services:
docker-events-notifier-config:
image: hairyhenderson/gomplate:v3.10.0-alpine
container_name: docker-events-notifier-config
entrypoint: ["/bin/sh","-c"]
environment:
CONFIG: |
notifiers:
slack:
url: "https://hooks.slack.com/services/XXXX"
template: /etc/docker-events-notifier/templates/slack.json
email:
url: "smtp://user:pass@some.mail.host:587?from=sender@example.net&to=recipient1@example.net&to=recipient2@example.net"
template: /etc/docker-events-notifier/templates/email.txt
filters:
event: ["stop", "die", "destroy"]
notifications:
- title: "Alert me when tianon/.* based container dies with exitCode 1"
when_regex:
status: ["(die|destroy)"]
"Actor.Attributes.image": ["tianon/.*"]
when:
"Actor.Attributes.exitCode": ["1"]
notify:
- email
- slack
- title: "Alert only on slack when container dies with exitCode 0"
when_regex:
status: ["(die|destroy)"]
"Actor.Attributes.image": ["hasnat/.*"]
when:
"Actor.Attributes.exitCode": ["0"]
notify:
- slack
- title: "Alert me on anything happening to images by hasnat"
when_regex:
"Actor.Attributes.image": ["hasnat/.*"]
notify:
- email
- slack
command:
- gomplate -i '{{ tmpl.Inline .Env.CONFIG }}' -o /etc/docker-events-notifier/config.yml
volumes:
- docker-events-notifier-config:/etc/docker-events-notifier/
restart: on-failure:5
docker-events-notifier:
image: hasnat/docker-events-notifier:0.0.2
container_name: docker-events-notifier
depends_on:
- docker-events-notifier-config
environment:
HOST_TAG: foo
RLOG_LOG_LEVEL: DEBUG
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- docker-events-notifier-config:/etc/docker-events-notifier/
restart: unless-stopped
networks:
production-network:
name: production-network
volumes:
docker-events-notifier-config:
driver: local
but getting:
2022-04-01T11:24:06Z DEBUG : Event: HTTP/1.0 404 Not Found
2022-04-01T11:24:06Z DEBUG : Not valid json event
2022-04-01T11:24:06Z DEBUG : invalid character 'H' looking for beginning of value
2022-04-01T11:24:06Z DEBUG : Event: Content-Type: application/json
2022-04-01T11:24:06Z DEBUG : Not valid json event
2022-04-01T11:24:06Z DEBUG : invalid character 'C' looking for beginning of value
2022-04-01T11:24:06Z DEBUG : Event: Date: Fri, 01 Apr 2022 11:24:06 GMT
2022-04-01T11:24:06Z DEBUG : Not valid json event
2022-04-01T11:24:06Z DEBUG : invalid character 'D' looking for beginning of value
2022-04-01T11:24:06Z DEBUG : Event: Content-Length: 29
2022-04-01T11:24:06Z DEBUG : Not valid json event
2022-04-01T11:24:06Z DEBUG : invalid character 'C' looking for beginning of value
2022-04-01T11:24:06Z DEBUG : Event:
2022-04-01T11:24:06Z DEBUG : Not valid json event
2022-04-01T11:24:06Z DEBUG : EOF
2022-04-01T11:24:06Z DEBUG : Event: {"message":"page not found"}
2022-04-01T11:24:06Z DEBUG : Checking "Alert me when tianon/.* based container dies with exitCode 1"
2022-04-01T11:24:06Z DEBUG : Checking "Alert only on slack when container dies with exitCode 0"
2022-04-01T11:24:06Z DEBUG : Checking "Alert me on anything happening to images by hasnat"
2022-04-01T11:24:06Z CRITICAL : EOF
panic: EOF
goroutine 1 [running]:
main.MustNoErr(0x86e460, 0xc000010050, 0x0, 0x0, 0x0)
/go/src/github.com/hasnat/docker-events-notifier/main.go:36 +0x194
main.MustByteArray(...)
/go/src/github.com/hasnat/docker-events-notifier/main.go:62
main.main()
/go/src/github.com/hasnat/docker-events-notifier/main.go:236 +0x3b7
Code has no nice message on this scenario, top of that it crashes when it recognises a json line and trying to compute docker event json object off it.
Hey, I am using config:
but getting:
Docker version:
20.10.14
Any ideas?
Thanks