From 8b9ed2c19e1b3d20a9dc21e9a61cddf5ca91f204 Mon Sep 17 00:00:00 2001 From: Sylvia van Os Date: Sun, 2 Jan 2022 14:27:40 +0100 Subject: [PATCH] Document global options docker labels Fixes #169 --- README.md | 51 ++++++++++++++++++++++++++++----------------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 205d4b26..87e11b3b 100644 --- a/README.md +++ b/README.md @@ -31,11 +31,36 @@ you can configure four different kind of jobs: See [Jobs reference documentation](docs/jobs.md) for all available parameters. +### Logging +**Ofelia** comes with three different logging drivers that can be configured in the `[global]` section or as top-level Docker labels: +- `mail` to send mails +- `save` to save structured execution reports to a directory +- `slack` to send messages via a slack webhook + +#### Options +- `smtp-host` - address of the SMTP server. +- `smtp-port` - port number of the SMTP server. +- `smtp-user` - user name used to connect to the SMTP server. +- `smtp-password` - password used to connect to the SMTP server. +- `email-to` - mail address of the receiver of the mail. +- `email-from` - mail address of the sender of the mail. +- `mail-only-on-error` - only send a mail if the execution was not successful. + +- `save-folder` - directory in which the reports shall be written. +- `save-only-on-error` - only save a report if the execution was not successful. + +- `slack-webhook` - URL of the slack webhook. +- `slack-only-on-error` - only send a slack message if the execution was not successful. + #### INI-style config Run with `ofelia daemon --config=/path/to/config.ini` ```ini +[global] +save-folder = /var/log/ofelia_reports +save-only-on-error = true + [job-exec "job-executed-on-running-container"] schedule = @hourly container = my-container @@ -50,7 +75,6 @@ command = touch /tmp/example schedule = @hourly command = touch /tmp/example - [job-service-run "service-executed-on-new-container"] schedule = 0,20,40 * * * * image = ubuntu @@ -65,13 +89,15 @@ In order to use this type of configurations, ofelia need access to docker socket ```sh docker run -it --rm \ -v /var/run/docker.sock:/var/run/docker.sock:ro \ + --label ofelia.save-folder="/var/log/ofelia_reports" \ + --label ofelia.save-only-on-error="true" \ --label ofelia.job-local.my-test-job.schedule="@every 5s" \ --label ofelia.job-local.my-test-job.command="date" \ mcuadros/ofelia:latest daemon --docker ``` Labels format: `ofelia...=. -This type of configuration supports all the capabilities provided by INI files. +This type of configuration supports all the capabilities provided by INI files, including the global logging options. Also, it is possible to configure `job-exec` by setting labels configurations on the target container. To do that, additional label `ofelia.enabled=true` need to be present on the target container. @@ -115,27 +141,6 @@ services: ofelia.job-exec.datecron.command: "uname -a" ``` -### Logging -**Ofelia** comes with three different logging drivers that can be configured in the `[global]` section: -- `mail` to send mails -- `save` to save structured execution reports to a directory -- `slack` to send messages via a slack webhook - -#### Options -- `smtp-host` - address of the SMTP server. -- `smtp-port` - port number of the SMTP server. -- `smtp-user` - user name used to connect to the SMTP server. -- `smtp-password` - password used to connect to the SMTP server. -- `email-to` - mail address of the receiver of the mail. -- `email-from` - mail address of the sender of the mail. -- `mail-only-on-error` - only send a mail if the execution was not successful. - -- `save-folder` - directory in which the reports shall be written. -- `save-only-on-error` - only save a report if the execution was not successful. - -- `slack-webhook` - URL of the slack webhook. -- `slack-only-on-error` - only send a slack message if the execution was not successful. - ### Overlap **Ofelia** can prevent that a job is run twice in parallel (e.g. if the first execution didn't complete before a second execution was scheduled. If a job has the option `no-overlap` set, it will not be run concurrently.