yubiuser / docker-event-monitor Goto Github PK
View Code? Open in Web Editor NEWMonitor docker events and send push notifications
Monitor docker events and send push notifications
As mentioned in #22 (comment), watchtower
has a setting called WATCHTOWER_NOTIFICATION_EMAIL_SUBJECTTAG
that injects a server name into the subject, like:
From: ...
Subject: [server.dl6er.de] Container gitea-db-1 restarted
Content: ...
Having such an option would allow me to use docker-event-monitor
better as I would be using it on three machines running in three different locations/networks.
These are the messages I'm referring to in the remainder of this issue ticket:
The first message I ever received contained a timestamp string, nothing else. The title was helpful:
The following messages did not contain a useful title, but what happened was now in the content of the mail:
My suggestions at this point would be to
Docker event monitor was started at XX-XX-2023 XX:YY:ZZ
Container postgres:14: stop
. For brevity, you could even skip the leading "Container" and use the title/subject postgres:14: stop
and, subsequently, postgres:14: start
I am aware that my suggestion is based on the e-mail reporting where a sender will always be visible allowing to identify the origin immediately. I am not using any of the other notification method your monitor offers, so I cannot speak for them if the same change would be useful over there as well.
One of my containers kept restarting because of a typo in its docker-compose.yml
file. docker-event-monitor
was very useful in figuring this out because my inbox kept filling:
The first one was
Object 'Container' with ID 88085b96 from image containrrr/watchtower reported: stop
All following are:
Object 'Container' with ID 2de67b6b from image containrrr/watchtower reported: start
docker events
told me container die
which was more helpful at pointing me into the right direction. Maybe docker-event-monitor
can be improved in this way.
I heavily use docker compose
to provide individual services on my servers. When docker-event-monitor
sends me a message like
Object 'Container' with ID 2a51bd18 from image postgres:14 reported: stop
it is difficult to know which container was actually affected because years after I have set up my gitea
, I might simply have forgotten that postgres
is used here. Another possibility would be that it could be used more than once, e.g., when using several provided docker-compose.yml
files from various resources on the web.
The structure of my services (all managed using docker compose
) is pretty common, like
/home/<user>/docker
/home/<user>/docker/gittea
/home/<user>/docker/gittea/docker-compose.yml
/home/<user>/docker/proxy
/home/<user>/docker/proxy/docker-compose.yml
/home/<user>/docker/bbb
/home/<user>/docker/bbb/docker-compose.yml
/home/<user>/docker/mailserver
/home/<user>/docker/mailserver/docker-compose.yml
/home/<user>/docker/watchtower
/home/<user>/docker/watchtower/docker-compose.yml
... (several more)
(yes, they are intentionally not running as root
)
Include details about the docker compose
context if applicable. The information should be available through the docker events, e.g.:
2023-09-23T10:29:15.081683269+02:00 container restart 2a51bd189e885381c80d63c8f6d7906a5f220f93412beb9b6eb96e9dfdd2efc4 (com.docker.compose.config-hash=20d8294d54fe37f3c8f4395ba8db4770df004b762180be24af6dcad170c4396c, com.docker.compose.container-number=1, com.docker.compose.depends_on=, com.docker.compose.image=sha256:4d8f13d97fae84ee0f5e9231b89a7957839a8de3ff49b7faab1feac5cab01b6c, com.docker.compose.oneoff=False, com.docker.compose.project=gitea, com.docker.compose.project.config_files=/home/<user>/docker/gitea/docker-compose.yml, com.docker.compose.project.working_dir=/home/<user>/docker/gitea, com.docker.compose.replace=7166e98e5db5339990b54505dd3a62e9b179b53cf0b0a16b0771639aef2ce247, com.docker.compose.service=db, com.docker.compose.version=2.20.2, image=postgres:14, name=gitea-db-1)
Specifically:
name=gitea-db-1
com.docker.compose.project=gitea
com.docker.compose.service=db
com.docker.compose.project.working_dir=/home/<user>/docker/gitea
To a human consuming the messages generated by docker-event-monitor
, name
may also be a more obvious choice than the currently printed container ID.
With docker compose
context:
From: ...
Subject: gitea-db-1 container restart
Content: Container gitea-db-1 (gitea:db defined in /home/<user>/docker/gitea) was restarted
Without docker compose
:
From: ...
Subject: nginx container restart
Content: Container nginx was restarted
Consider switching to https://github.com/rs/zerolog
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.