logs: allow disabling log collection in jobspec (#16962)

Some Nomad users ship application logs out-of-band via syslog. For these users
having `logmon` (and `docker_logger`) running is unnecessary overhead. Allow
disabling the logmon and pointing the task's stdout/stderr to /dev/null.

This changeset is the first of several incremental improvements to log
collection short of full-on logging plugins. The next step will likely be to
extend the internal-only task driver configuration so that cluster
administrators can turn off log collection for the entire driver.

---

Fixes: #11175

Co-authored-by: Thomas Weber <towe75@googlemail.com>
This commit is contained in:
Tim Gross
2023-04-24 10:00:27 -04:00
committed by GitHub
parent b4e6a70fe6
commit 30bc456f03
22 changed files with 262 additions and 28 deletions

View File

@@ -603,7 +603,8 @@ fields:
## Stream Logs
This endpoint streams a task's stderr/stdout logs.
This endpoint streams a task's stderr/stdout logs. Note that if logging is set
to [enabled=false][] for the task, this endpoint will return a 404 error.
| Method | Path | Produces |
| ------ | ------------------------------ | ------------ |
@@ -832,3 +833,4 @@ $ nomad operator api /v1/client/gc
```
[api-node-read]: /nomad/api-docs/nodes
[enabled=false]: /nomad/docs/job-specification/logs#enabled

View File

@@ -491,6 +491,7 @@ $ curl \
},
"KillTimeout": 5000000000,
"LogConfig": {
"Enabled": true,
"MaxFiles": 10,
"MaxFileSizeMB": 10
},
@@ -762,6 +763,7 @@ $ curl \
"Leader": false,
"Lifecycle": null,
"LogConfig": {
"Enabled": true,
"MaxFileSizeMB": 10,
"MaxFiles": 10
},
@@ -979,6 +981,7 @@ $ curl \
"Leader": false,
"Lifecycle": null,
"LogConfig": {
"Enabled": true,
"MaxFileSizeMB": 10,
"MaxFiles": 10
},
@@ -1145,6 +1148,7 @@ $ curl \
"Leader": false,
"Lifecycle": null,
"LogConfig": {
"Enabled": true,
"MaxFileSizeMB": 10,
"MaxFiles": 10
},

View File

@@ -927,6 +927,8 @@ The `Affinity` object supports the following keys:
The `LogConfig` object configures the log rotation policy for a task's `stdout` and
`stderr`. The `LogConfig` object supports the following attributes:
- `Enabled` - Enables log collection.
- `MaxFiles` - The maximum number of rotated files Nomad will retain for
`stdout` and `stderr`, each tracked individually.
@@ -940,6 +942,7 @@ a validation error when a job is submitted.
```json
{
"LogConfig": {
"Enabled": true,
"MaxFiles": 3,
"MaxFileSizeMB": 10
}