blob: c8deb73265a2dfd25e8bf72962805007427bb2f8 [file] [log] [blame]
Serge Bazanskiefdb6e92020-07-13 17:19:27 +02001// Copyright 2020 The Monogon Project Authors.
2//
3// SPDX-License-Identifier: Apache-2.0
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17syntax = "proto3";
Serge Bazanski662b5b32020-12-21 13:49:00 +010018package metropolis.proto.api;
Serge Bazanski31370b02021-01-07 16:31:14 +010019option go_package = "source.monogon.dev/metropolis/proto/api";
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020020
Mateusz Zalegacf92f402022-07-08 15:08:48 +020021import "google/protobuf/timestamp.proto";
22
Serge Bazanski662b5b32020-12-21 13:49:00 +010023// NodeDebugService exposes debug and testing endpoints that allow introspection into a running Metropolis node.
Serge Bazanski77cb6c52020-12-19 00:09:22 +010024// It is not authenticated and will be disabled in production. It is currently consumed by metropolis/cli/dbg and
25// by tests.
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020026service NodeDebugService {
27 // GetDebugKubeconfig issues kubeconfigs with arbitrary identities and groups for debugging
28 rpc GetDebugKubeconfig(GetDebugKubeconfigRequest) returns (GetDebugKubeconfigResponse);
Serge Bazanskib0272182020-11-02 18:39:44 +010029
30 // GetLogs Returns historical and/or streaming logs for a given DN with given filters from the system global
31 // LogTree.
32 //
Serge Bazanski549b72b2021-01-07 14:54:19 +010033 // For more information about this API, see //metropolis/pkg/logtree. But, in summary:
Serge Bazanskib0272182020-11-02 18:39:44 +010034 // - All logging is performed to a DN (distinguished name), which is a dot-delimited string like foo.bar.baz.
35 // - Log entries can be either raw (coming from unstructured logging from an external service, like a running
Serge Bazanski662b5b32020-12-21 13:49:00 +010036 // process) or leveled (emitted by Metropolis code with a source line, timestamp, and severity).
Serge Bazanskib0272182020-11-02 18:39:44 +010037 // - The DNs form a tree of logging nodes - and when requesting logs, a given subtree of DNs can be requested,
38 // instead of just a given DN.
39 // - All supervised processes live at `root.<supervisor DN>`. For more example paths, see the console logs of
Serge Bazanski662b5b32020-12-21 13:49:00 +010040 // a running Metropolis node, or request all logs (at DN "").
Serge Bazanskib0272182020-11-02 18:39:44 +010041 //
42 // TODO(q3k): move method and its related messages to the non-debug node endpoint once we have one.
43 rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse);
Lorenz Brun09c275b2021-03-30 12:47:09 +020044
45 // Trace enables tracing of Metropolis using the Linux ftrace infrastructure.
46 rpc Trace(TraceRequest) returns (stream TraceEvent);
Lorenz Brun9d6c4c72021-07-20 21:16:27 +020047
48 // LoadImage loads an uncompressed tarball containing a Docker v1.1, v1.2 or OCI v1 image into the local
49 // containerd image store. The client streams the tarball in arbitrary-sized chunks and closes the sending side
50 // once it has sent the entire image. The server then either returns an empty response if successful or a gRPC error.
51 rpc LoadImage(stream ImagePart) returns (LoadImageResponse);
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020052}
53
Lorenz Brun9d6c4c72021-07-20 21:16:27 +020054message ImagePart {
55 bytes data_part = 1;
56}
57
58message LoadImageResponse {
59}
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020060
61message GetDebugKubeconfigRequest {
62 string id = 1; // Kubernetes identity (user)
63 repeated string groups = 2; // Kubernetes groups
64}
65
66message GetDebugKubeconfigResponse {
67 string debug_kubeconfig = 1;
68}
69
Serge Bazanski549b72b2021-01-07 14:54:19 +010070// Severity level corresponding to //metropolis/pkg/logtree.Severity.
Serge Bazanskib0272182020-11-02 18:39:44 +010071enum LeveledLogSeverity {
72 INVALID = 0;
73 INFO = 1;
74 WARNING = 2;
75 ERROR = 3;
76 FATAL = 4;
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020077}
78
Serge Bazanskib0272182020-11-02 18:39:44 +010079// Filter set when requesting logs for a given DN. This message is equivalent to the following GADT enum:
80// data LogFilter = WithChildren
81// | OnlyRaw
82// | OnlyLeveled
83// | LeveledWithMinimumSeverity(Severity)
84//
85// Multiple LogFilters can be chained/combined when requesting logs, as long as they do not conflict.
86message LogFilter {
87 // Entries will be returned not only for the given DN, but all child DNs as well. For instance, if the
88 // requested DN is foo, entries logged to foo, foo.bar and foo.bar.baz will all be returned.
89 message WithChildren {
90 }
91 // Only raw logging entries will be returned. Conflicts with OnlyLeveled filters.
92 message OnlyRaw {
93 }
94 // Only leveled logging entries will be returned. Conflicts with OnlyRaw filters.
95 message OnlyLeveled {
96 }
97 // If leveled logs are returned, all entries at severity lower than `minimum` will be discarded.
98 message LeveledWithMinimumSeverity {
99 LeveledLogSeverity minimum = 1;
100 }
101 oneof filter {
102 WithChildren with_children = 1;
103 OnlyRaw only_raw = 3;
104 OnlyLeveled only_leveled = 4;
105 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
106 }
107}
108
109message GetLogsRequest {
110 // DN from which to request logs. All supervised runnables live at `root.`, the init code lives at `init.`.
111 string dn = 1;
112 // Filters to apply to returned data.
113 repeated LogFilter filters = 2;
114
115 enum BacklogMode {
116 BACKLOG_INVALID = 0;
117 // No historic data will be returned.
118 BACKLOG_DISABLE = 1;
119 // All available historic data will be returned.
120 BACKLOG_ALL = 2;
121 // At most backlog_count entries will be returned, if available.
122 BACKLOG_COUNT = 3;
123 }
124 BacklogMode backlog_mode = 3;
125 int64 backlog_count = 4;
126
127 enum StreamMode {
128 STREAM_INVALID = 0;
129 // No streaming entries, gRPC stream will be closed as soon as all backlog data is served.
130 STREAM_DISABLE = 1;
131 // Entries will be streamed as early as available right after all backlog data is served.
132 STREAM_UNBUFFERED = 2;
133 }
134 StreamMode stream_mode = 5;
135}
136
137message GetLogsResponse {
138 // Entries from the requested historical entries (via WithBackLog). They will all be served before the first
139 // stream_entries are served (if any).
140 repeated LogEntry backlog_entries = 1;
141 // Entries streamed as they arrive. Currently no server-side buffering is enabled, instead every line is served
142 // as early as it arrives. However, this might change in the future, so this behaviour cannot be depended
143 // upon.
144 repeated LogEntry stream_entries = 2;
145}
146
147message LogEntry {
148 message Leveled {
Serge Bazanski12971d62020-11-17 12:12:58 +0100149 repeated string lines = 1;
Mateusz Zalegacf92f402022-07-08 15:08:48 +0200150 google.protobuf.Timestamp timestamp = 2;
Serge Bazanskib0272182020-11-02 18:39:44 +0100151 LeveledLogSeverity severity = 3;
152 string location = 4;
153 }
154 message Raw {
155 string data = 1;
156 int64 original_length = 2;
157 }
158
159 string dn = 1;
160 oneof kind {
161 Leveled leveled = 2;
162 Raw raw = 3;
163 }
Serge Bazanskiefdb6e92020-07-13 17:19:27 +0200164}
Lorenz Brun09c275b2021-03-30 12:47:09 +0200165
166message TraceRequest {
167 // Name of the tracer to use. Defined in https://www.kernel.org/doc/html/latest/trace/ftrace.html#the-tracers.
168 // Useful ones enabled in Metropolis: function_graph, function.
169 // Gets reset to nop automatically after the stream is terminated.
170 string tracer = 1;
171
172 // List of functions to trace. Accepts wildcards using the '*' character. If left empty traces all functions.
173 repeated string function_filter = 2;
174
175 // List of functions and their descendants to trace with the function_graph tracer.
176 repeated string graph_function_filter = 3;
177}
178
179message TraceEvent {
180 // Currently we do not parse the event data and just return what the kernel outputs, line-by-line.
181 string raw_line = 1;
Mateusz Zalegacf92f402022-07-08 15:08:48 +0200182}