Log
The entries of the systemd journal. osapi dsl behavior get --name log and
osapi dsl behavior method get show the same.
Behavior
| Name | log |
| Description | The entries of the systemd journal |
| Placement | node |
| Area | logs |
| Internal | no |
| API | yes |
| CLI | yes |
| Next | no |
| Platforms | linux |
| Sudo | none |
| Runs | none |
| Writes | none |
| Keeps state | no |
| Uses | none |
| Used by | none |
Methods (1)
| NAME | VERB | HTTP | ROUTE | PERMISSION | DESCRIPTION |
|---|---|---|---|---|---|
| list | read | GET | /api/node/{hostname}/log | log:read | List the entries of the journal |
Types (1)
| NAME | INPUT | OUTPUT |
|---|---|---|
| list | ListInput { unit, lines, since, priority } | []Entry { timestamp, unit, priority, message, pid } |
Settings (0)
None. Declare them with behavior.Config.
Telemetry
| Span | behavior.log.<method> |
| Child spans | exec journalctl |
| Metrics | osapi_behavior_calls_total, osapi_behavior_duration_seconds, osapi_behavior_changes_total |
| Attributes | osapi.behavior.name, osapi.behavior.method, osapi.behavior.verb, osapi.behavior.outcome, osapi.behavior.changed |
| Recorded inputs | none |
Method list
| Name | list |
| Verb | read |
| Description | List the entries of the journal |
| Detail | Runs journalctl --output=json, the newest entries last: the last 100 unless lines says, of one unit when unit says, since a time when since says, and at a priority or above when priority says. A priority is its name, such as err or info. The hand-written log domain read the Debian family only; this reads each Linux host that has journald. |
| HTTP | GET |
| Route | /api/node/{hostname}/log |
| Permission | log:read |
| Command | osapi client node log list |
| Input type | ListInput |
| Output type | []Entry |
Input (4)
| FIELD | TYPE | REQUIRED | CONSTRAINTS | DESCRIPTION |
|---|---|---|---|---|
| unit | string | no | pattern ^[a-zA-Z0-9:_.@-]+$ | Only the entries of this systemd unit, such as nginx.service |
| lines | integer | no | min 1, max 10000 | How many of the newest entries; 100 when it is not set |
| since | string | no | Only the entries since this time, in any form that journalctl --since takes, such as 1 hour ago | |
| priority | string | no | one of emerg alert crit err warning notice info debug | Only the entries at this priority or above |
Output (5)
| FIELD | TYPE | DESCRIPTION |
|---|---|---|
| timestamp | string | When journald recorded it, in RFC 3339 |
| unit | string | The syslog identifier that wrote it |
| priority | string | Its priority, by name. An entry that journald has no priority for has none |
| message | string | The message |
| pid | integer | The process that wrote it |
Examples (2)
| EXAMPLE | INPUT | OUTPUT |
|---|---|---|
| The newest entries | (none) | [message=Started nginx, pid=1234, priority=info, timestamp=2024-03-31T23:50:45.123456Z, unit=nginx] [message=Accepted key, pid=5678, priority=notice, timestamp=2024-03-31T23:50:46Z, unit=sshd] |
| The last entry of one unit at info or above | unit=nginx.service, lines=1, since=1 hour ago, priority=info | [message=Started nginx, pid=1234, priority=info, timestamp=2024-03-31T23:50:45.123456Z, unit=nginx] |