-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from yubiuser/development
v2.2.0
- Loading branch information
Showing
9 changed files
with
177 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG alpine_version=3.19 | ||
ARG golang_version=1.21 | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -97,7 +97,7 @@ jobs: | |
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/[email protected].0 | ||
uses: actions/[email protected].1 | ||
with: | ||
name: digests-${{ env.PLATFORM_PAIR }} | ||
path: /tmp/digests/* | ||
|
@@ -116,7 +116,7 @@ jobs: | |
packages: write | ||
steps: | ||
- name: Download digests | ||
uses: actions/[email protected].1 | ||
uses: actions/[email protected].2 | ||
with: | ||
path: /tmp/digests | ||
pattern: digests-* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# syntax=docker/dockerfile:1 | ||
ARG alpine_version=3.19 | ||
ARG golang_version=1.21 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,7 +60,8 @@ services: | |
MAIL_PASSWORD: 'PASSWORD' | ||
MAIL_PORT: 587 | ||
MAIL_HOST: '[email protected]' | ||
FILTER: 'event=start,event=stop,type=container' | ||
FILTER: 'type=container' | ||
EXCLUDE: 'Action=exec_start,Action=exec_die,Action=exec_create' | ||
DELAY: '500ms' | ||
LOG_LEVEL: 'info' | ||
SERVER_TAG: '' | ||
|
@@ -100,5 +101,20 @@ Configurations can use the CLI flags or environment variables. The table below o | |
| `--mailport` | `MAIL_PORT` | `587` | | | ||
| `--mailhost` | `MAIL_HOST` | `""` | `[email protected]` | | ||
| `--filter` | `FILTER` | `""` | Filter events. Uses the same filters as `docker events` (see [here](https://docs.docker.com/engine/reference/commandline/events/#filter)) | | ||
| `--exclude` | `EXCLUDE` | `""` | Exclude events from being reported | | ||
| `--loglevel` | `LOG_LEVEL` | `"info"`| Use `debug` for more verbose logging | | ||
| `--servertag` | `SERVER_TAG` | `""` | Prefix to include in the title of notifications. Useful when running docker-event-monitors on multiple machines | | ||
|
||
### Filter and exclude events | ||
|
||
Docker Event Monitor offers two options that sound alike, but aren't: `Filter` and `Exclude`. | ||
By default, the docker system event stream will contain **all** events. The `filter` option is a docker built-in function that allows filtering certain events from the stream. It's a **positive** filter only, meaning it defines which events will pass the filter. The possible filters and syntax are described [here](https://docs.docker.com/engine/reference/commandline/events/#filter). | ||
|
||
However, docker has no native support for **negative** filter (let all events pass, except those defined) - so I added it. To distingush it from postive filters, this option is named `exclude`. | ||
Based on how it is implemented, **exclusion happens after filtering**. Together you can create configurations like filtering events of type container, but exclude reporting for a specific container or certain actions. | ||
|
||
The syntax for exclusion is also `key=value`. But as the exclusion happens on the data contained in the reported event, the `key`s are different from those used for `filtering`. E.g. instead of `event`, `Action` is used. To figure out which keys to use, it's best to enable debug logging and carefully inspect the event's data structure. A typical container event looks like | ||
|
||
``` | ||
{Status:"start", ID:"b4a2a54c4487ddc0bbae006e48ae970d4b2fa4b9fd2bef390d8875cb6158c888", From:"squidfunk/mkdocs-material", Type:"container", Action:"start", Actor:events.Actor{ID:"b4a2a54c4487ddc0bbae006e48ae970d4b2fa4b9fd2bef390d8875cb6158c888", Attributes:map[string]string{"com.docker.compose.config-hash":"cd464ac038ddc9ee7a53599aaa9db6a85a01683a9a08a749582d0c0b8c0a595d", "com.docker.compose.container-number":"1", "com.docker.compose.depends_on":"", "com.docker.compose.image":"sha256:feb8ba83cb7272046551c69a58ec03ecda2306410a07844d22c166e810034aa6", "com.docker.compose.oneoff":"False", "com.docker.compose.project":"mkdocs-material", "com.docker.compose.project.config_files":"/home/pi/docker/mkdocs-material/docker-compose.yml", "com.docker.compose.project.working_dir":"/home/pi/docker/mkdocs-material", "com.docker.compose.service":"mkdocs-material", "com.docker.compose.version":"2.24.5", "image":"squidfunk/mkdocs-material", "name":"mkdocs-material", "org.opencontainers.image.created":"2024-02-10T06:18:18.743Z", "org.opencontainers.image.description":"Documentation that simply works", "org.opencontainers.image.licenses":"MIT", "org.opencontainers.image.revision":"a6286ef3ac3407e8b6c985cf0571fc0e2caa6f5b", "org.opencontainers.image.source":"https://github.com/squidfunk/mkdocs-material", "org.opencontainers.image.title":"mkdocs-material", "org.opencontainers.image.url":"https://github.com/squidfunk/mkdocs-material", "org.opencontainers.image.version":"9.5.9"}}, Scope:"local", Time:1708201602, TimeNano:1708201602805856956} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,32 @@ | ||
BINARY_NAME := docker-event-monitor | ||
BINARY_NAME = docker-event-monitor | ||
|
||
# using the ?= assignment operator: Assign only if variable is not set (e.g. via environment) yet | ||
# this allows overwriting via CI | ||
GIT_COMMIT ?= $(shell git --no-pager describe --always --abbrev=8 --dirty) | ||
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD) | ||
GIT_VERSION ?= $(shell git --no-pager describe --tags --always --abbrev=8 --dirty) | ||
GIT_DATE ?= $(shell git --no-pager show --date=short --format=%at --name-only | head -n 1) | ||
|
||
# GIT_TAG is only set when a CI build is trigged via release tag | ||
ifdef GIT_TAG | ||
override GIT_VERSION = ${GIT_TAG} | ||
endif | ||
DATE := $(shell date +%s) | ||
|
||
# in case 'git' or the repo is not available, GIT_XXX is set empty via the assignment above | ||
# so we set them explicitly | ||
ifeq ($(GIT_DATE),) | ||
GIT_DATE = 0 | ||
endif | ||
ifeq ($(GIT_COMMIT),) | ||
GIT_COMMIT = "n/a" | ||
endif | ||
ifeq ($(GIT_BRANCH),) | ||
GIT_BRANCH = "n/a" | ||
endif | ||
ifeq ($(GIT_VERSION),) | ||
GIT_VERSION = "n/a" | ||
endif | ||
|
||
DATE = $(shell date +%s) | ||
build: | ||
CGO_ENABLED=0 go build -ldflags "-s -w -X 'main.version=${GIT_VERSION}' -X 'main.gitdate=${GIT_DATE}' -X 'main.date=${DATE}' -X 'main.commit=${GIT_COMMIT}' -X 'main.branch=${GIT_BRANCH}'" -o=${BINARY_NAME} docker-event-monitor.go |