gen

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Group = endpoint.Define(
	"log",
	"The entries of the systemd journal",
	endpoint.Area(area.Logs),
	endpoint.Prefix("node/{hostname}"),
	endpoint.Uses[dispatch.Deps](),
	endpoint.Tag("log_operations", "Log", "The entries of the systemd journal"),
	endpoint.CommandNotes("The [log behavior](../../../../../reference/behaviors/logs/log/log.md) page tells where the behavior runs, what it is built on and its settings."),
	endpoint.Doc[types.RowStatus](dispatch.RowStatusDoc),
	endpoint.Get[ListRequest, LogCollectionResponse]("list").
		Handle(HandleList).
		ID("GetNodeLog").
		Describe("List the entries of the journal").
		Permission("log:read").
		Returns("Each target host's result.").
		Explain("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.").
		Example("--target web-01", "The newest entries").
		Example("--target web-01 --unit nginx.service --lines 1 --since \"1 hour ago\" --priority info", "The last entry of one unit at info or above").
		Result("The newest entries, on one host:\n\n```ansi\n$ osapi client node log list --target web-01\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mTIMESTAMP                    \x1b[0m\x1b[38;2;10;143;176mUNIT   \x1b[0m\x1b[38;2;10;143;176mPRIORITY  \x1b[0m\x1b[38;2;10;143;176mMESSAGE        \x1b[0m\x1b[38;2;10;143;176mPID\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:45.123456Z\x1b[0m  nginx  info      Started nginx  1234\n  \x1b[38;2;138;138;138mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:46Z\x1b[0m         sshd   notice    Accepted key   5678\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node log list --target _all\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mTIMESTAMP                    \x1b[0m\x1b[38;2;10;143;176mUNIT   \x1b[0m\x1b[38;2;10;143;176mPRIORITY  \x1b[0m\x1b[38;2;10;143;176mMESSAGE        \x1b[0m\x1b[38;2;10;143;176mPID\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:45.123456Z\x1b[0m  nginx  info      Started nginx  1234\n  \x1b[38;2;138;138;138mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:46Z\x1b[0m         sshd   notice    Accepted key   5678\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:45.123456Z\x1b[0m  nginx  info      Started nginx  1234\n  \x1b[38;2;138;138;138mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:46Z\x1b[0m         sshd   notice    Accepted key   5678\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"hostname\": \"web-01\",\n      \"message\": \"Started nginx\",\n      \"pid\": 1234,\n      \"priority\": \"info\",\n      \"status\": \"ok\",\n      \"timestamp\": \"2024-03-31T23:50:45.123456Z\",\n      \"unit\": \"nginx\"\n    },\n    {\n      \"hostname\": \"web-01\",\n      \"message\": \"Accepted key\",\n      \"pid\": 5678,\n      \"priority\": \"notice\",\n      \"status\": \"ok\",\n      \"timestamp\": \"2024-03-31T23:50:46Z\",\n      \"unit\": \"sshd\"\n    }\n  ]\n}\n```\n\nThe last entry of one unit at info or above, on one host:\n\n```ansi\n$ osapi client node log list --target web-01 --unit nginx.service --lines 1 --since \"1 hour ago\" --priority info\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mTIMESTAMP                    \x1b[0m\x1b[38;2;10;143;176mUNIT   \x1b[0m\x1b[38;2;10;143;176mPRIORITY  \x1b[0m\x1b[38;2;10;143;176mMESSAGE        \x1b[0m\x1b[38;2;10;143;176mPID\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:45.123456Z\x1b[0m  nginx  info      Started nginx  1234\n\n  1 host: \x1b[38;2;103;234;147m1 ok\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n```\n\nOn each host, where one cannot run it:\n\n```ansi\n$ osapi client node log list --target _all --unit nginx.service --lines 1 --since \"1 hour ago\" --priority info\n\x1b[1;38;2;0;213;255mResults:\x1b[0m\n  \x1b[38;2;10;143;176mHOSTNAME  \x1b[0m\x1b[38;2;10;143;176mSTATUS  \x1b[0m\x1b[38;2;10;143;176mTIMESTAMP                    \x1b[0m\x1b[38;2;10;143;176mUNIT   \x1b[0m\x1b[38;2;10;143;176mPRIORITY  \x1b[0m\x1b[38;2;10;143;176mMESSAGE        \x1b[0m\x1b[38;2;10;143;176mPID\x1b[0m\n  \x1b[1mweb-01\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:45.123456Z\x1b[0m  nginx  info      Started nginx  1234\n  \x1b[1mweb-02\x1b[0m    \x1b[38;2;103;234;147mok\x1b[0m      \x1b[38;2;138;138;138m2024-03-31T23:50:45.123456Z\x1b[0m  nginx  info      Started nginx  1234\n\n  3 hosts: \x1b[38;2;103;234;147m2 ok\x1b[0m, \x1b[38;5;222m1 skipped\x1b[0m   \x1b[38;2;138;138;138mjob 550e8400-e29b-41d4-a716-446655440000\x1b[0m   \x1b[38;2;138;138;138mtrace 26e448c9dbe1c4a8d216a98c675079c9\x1b[0m\n\n\x1b[1;38;2;255;0;255mDetails:\x1b[0m\n  \x1b[1mmac-01\x1b[0m  \x1b[38;5;222mskipped\x1b[0m  operation not supported on this OS family\n```\n\nWith `--json`, the API's response:\n\n```json\n{\n  \"job_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n  \"results\": [\n    {\n      \"hostname\": \"web-01\",\n      \"message\": \"Started nginx\",\n      \"pid\": 1234,\n      \"priority\": \"info\",\n      \"status\": \"ok\",\n      \"timestamp\": \"2024-03-31T23:50:45.123456Z\",\n      \"unit\": \"nginx\"\n    }\n  ]\n}\n```\n\nThe command fails in these cases:\n\n| Call | Flags | Fails with |\n| --- | --- | --- |\n| Lines below one | `--lines -1` | min |\n| More than 10000 lines | `--lines 10001` | max |\n| A priority that journald does not have | `--priority loud` | enum |\n| A unit with a space in it | `--unit \"nginx service\"` | unit_name |").
		Errors(endpoint.NotFound(behavior.ErrNotFound, "The host does not have what the request names, such as the object of a deploy."), endpoint.Conflict(behavior.ErrNotManaged, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotManaged), endpoint.Conflict(behavior.ErrNotInstalled, "osapi did not deploy the item, so it does not change it, or the host does not have a program that the method needs.").Because(types.ReasonNotInstalled), endpoint.Invalid(dispatch.ErrInvalid, "The request is not valid, or the host refuses the input, such as a path that is a directory.")),
)

Group is log as an endpoint group, which its spec comes from.

Functions

func Routes

func Routes(
	s *server.Server,
) []server.Route

Routes are the log group's endpoints, as its definition declares them.

Types

type ListRequest

type ListRequest struct {
	Hostname string         `` /* 182-byte string literal not displayed */
	Unit     string         `` /* 130-byte string literal not displayed */
	Lines    int            `` /* 131-byte string literal not displayed */
	Since    string         `` /* 156-byte string literal not displayed */
	Priority entry.Priority `doc:"Only the entries at this priority or above" in:"query" json:"priority,omitempty" validate:"omitempty,enum"`
}

ListRequest is the request of log list: its target and its input.

type LogCollectionResponse

type LogCollectionResponse struct {
	JobID   string     `` /* 133-byte string literal not displayed */
	Results []LogEntry `json:"results"`
}

LogCollectionResponse is each target host's result.

func HandleList

func HandleList(
	ctx context.Context,
	d dispatch.Deps,
	in ListRequest,
) (LogCollectionResponse, error)

HandleList runs log list on the target, for the endpoint server.

type LogEntry

type LogEntry struct {
	Hostname  string          `doc:"Hostname of the agent that produced this result." json:"hostname"`
	Status    types.RowStatus `doc:"The status of the operation for this host." json:"status"`
	Timestamp *string         `doc:"When journald recorded it, in RFC 3339" json:"timestamp,omitempty"`
	Unit      *string         `doc:"The syslog identifier that wrote it" json:"unit,omitempty"`
	Priority  *entry.Priority `doc:"Its priority, by name. An entry that journald has no priority for has none" json:"priority,omitempty"`
	Message   *string         `doc:"The message" json:"message,omitempty"`
	PID       *int            `doc:"The process that wrote it" json:"pid,omitempty"`
	Error     *string         `doc:"Error message if the agent failed." json:"error,omitempty"`
}

LogEntry is the result of log on one host.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL