blob: eabc766fef2a715bc3120b2ab4a80888ecfac46e [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
Serge Bazanski662b5b32020-12-21 13:49:00 +010021// NodeDebugService exposes debug and testing endpoints that allow introspection into a running Metropolis node.
Serge Bazanski77cb6c52020-12-19 00:09:22 +010022// It is not authenticated and will be disabled in production. It is currently consumed by metropolis/cli/dbg and
23// by tests.
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020024service NodeDebugService {
25 // GetDebugKubeconfig issues kubeconfigs with arbitrary identities and groups for debugging
26 rpc GetDebugKubeconfig(GetDebugKubeconfigRequest) returns (GetDebugKubeconfigResponse);
Serge Bazanskib0272182020-11-02 18:39:44 +010027
28 // GetLogs Returns historical and/or streaming logs for a given DN with given filters from the system global
29 // LogTree.
30 //
Serge Bazanski549b72b2021-01-07 14:54:19 +010031 // For more information about this API, see //metropolis/pkg/logtree. But, in summary:
Serge Bazanskib0272182020-11-02 18:39:44 +010032 // - All logging is performed to a DN (distinguished name), which is a dot-delimited string like foo.bar.baz.
33 // - Log entries can be either raw (coming from unstructured logging from an external service, like a running
Serge Bazanski662b5b32020-12-21 13:49:00 +010034 // process) or leveled (emitted by Metropolis code with a source line, timestamp, and severity).
Serge Bazanskib0272182020-11-02 18:39:44 +010035 // - The DNs form a tree of logging nodes - and when requesting logs, a given subtree of DNs can be requested,
36 // instead of just a given DN.
37 // - All supervised processes live at `root.<supervisor DN>`. For more example paths, see the console logs of
Serge Bazanski662b5b32020-12-21 13:49:00 +010038 // a running Metropolis node, or request all logs (at DN "").
Serge Bazanskib0272182020-11-02 18:39:44 +010039 //
40 // TODO(q3k): move method and its related messages to the non-debug node endpoint once we have one.
41 rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse);
Lorenz Brun09c275b2021-03-30 12:47:09 +020042
43 // Trace enables tracing of Metropolis using the Linux ftrace infrastructure.
44 rpc Trace(TraceRequest) returns (stream TraceEvent);
Lorenz Brun9d6c4c72021-07-20 21:16:27 +020045
46 // LoadImage loads an uncompressed tarball containing a Docker v1.1, v1.2 or OCI v1 image into the local
47 // containerd image store. The client streams the tarball in arbitrary-sized chunks and closes the sending side
48 // once it has sent the entire image. The server then either returns an empty response if successful or a gRPC error.
49 rpc LoadImage(stream ImagePart) returns (LoadImageResponse);
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020050}
51
Lorenz Brun9d6c4c72021-07-20 21:16:27 +020052message ImagePart {
53 bytes data_part = 1;
54}
55
56message LoadImageResponse {
57}
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020058
59message GetDebugKubeconfigRequest {
60 string id = 1; // Kubernetes identity (user)
61 repeated string groups = 2; // Kubernetes groups
62}
63
64message GetDebugKubeconfigResponse {
65 string debug_kubeconfig = 1;
66}
67
Serge Bazanski549b72b2021-01-07 14:54:19 +010068// Severity level corresponding to //metropolis/pkg/logtree.Severity.
Serge Bazanskib0272182020-11-02 18:39:44 +010069enum LeveledLogSeverity {
70 INVALID = 0;
71 INFO = 1;
72 WARNING = 2;
73 ERROR = 3;
74 FATAL = 4;
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020075}
76
Serge Bazanskib0272182020-11-02 18:39:44 +010077// Filter set when requesting logs for a given DN. This message is equivalent to the following GADT enum:
78// data LogFilter = WithChildren
79// | OnlyRaw
80// | OnlyLeveled
81// | LeveledWithMinimumSeverity(Severity)
82//
83// Multiple LogFilters can be chained/combined when requesting logs, as long as they do not conflict.
84message LogFilter {
85 // Entries will be returned not only for the given DN, but all child DNs as well. For instance, if the
86 // requested DN is foo, entries logged to foo, foo.bar and foo.bar.baz will all be returned.
87 message WithChildren {
88 }
89 // Only raw logging entries will be returned. Conflicts with OnlyLeveled filters.
90 message OnlyRaw {
91 }
92 // Only leveled logging entries will be returned. Conflicts with OnlyRaw filters.
93 message OnlyLeveled {
94 }
95 // If leveled logs are returned, all entries at severity lower than `minimum` will be discarded.
96 message LeveledWithMinimumSeverity {
97 LeveledLogSeverity minimum = 1;
98 }
99 oneof filter {
100 WithChildren with_children = 1;
101 OnlyRaw only_raw = 3;
102 OnlyLeveled only_leveled = 4;
103 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
104 }
105}
106
107message GetLogsRequest {
108 // DN from which to request logs. All supervised runnables live at `root.`, the init code lives at `init.`.
109 string dn = 1;
110 // Filters to apply to returned data.
111 repeated LogFilter filters = 2;
112
113 enum BacklogMode {
114 BACKLOG_INVALID = 0;
115 // No historic data will be returned.
116 BACKLOG_DISABLE = 1;
117 // All available historic data will be returned.
118 BACKLOG_ALL = 2;
119 // At most backlog_count entries will be returned, if available.
120 BACKLOG_COUNT = 3;
121 }
122 BacklogMode backlog_mode = 3;
123 int64 backlog_count = 4;
124
125 enum StreamMode {
126 STREAM_INVALID = 0;
127 // No streaming entries, gRPC stream will be closed as soon as all backlog data is served.
128 STREAM_DISABLE = 1;
129 // Entries will be streamed as early as available right after all backlog data is served.
130 STREAM_UNBUFFERED = 2;
131 }
132 StreamMode stream_mode = 5;
133}
134
135message GetLogsResponse {
136 // Entries from the requested historical entries (via WithBackLog). They will all be served before the first
137 // stream_entries are served (if any).
138 repeated LogEntry backlog_entries = 1;
139 // Entries streamed as they arrive. Currently no server-side buffering is enabled, instead every line is served
140 // as early as it arrives. However, this might change in the future, so this behaviour cannot be depended
141 // upon.
142 repeated LogEntry stream_entries = 2;
143}
144
145message LogEntry {
146 message Leveled {
Serge Bazanski12971d62020-11-17 12:12:58 +0100147 repeated string lines = 1;
Serge Bazanskib0272182020-11-02 18:39:44 +0100148 int64 timestamp = 2;
149 LeveledLogSeverity severity = 3;
150 string location = 4;
151 }
152 message Raw {
153 string data = 1;
154 int64 original_length = 2;
155 }
156
157 string dn = 1;
158 oneof kind {
159 Leveled leveled = 2;
160 Raw raw = 3;
161 }
Serge Bazanskiefdb6e92020-07-13 17:19:27 +0200162}
Lorenz Brun09c275b2021-03-30 12:47:09 +0200163
164message TraceRequest {
165 // Name of the tracer to use. Defined in https://www.kernel.org/doc/html/latest/trace/ftrace.html#the-tracers.
166 // Useful ones enabled in Metropolis: function_graph, function.
167 // Gets reset to nop automatically after the stream is terminated.
168 string tracer = 1;
169
170 // List of functions to trace. Accepts wildcards using the '*' character. If left empty traces all functions.
171 repeated string function_filter = 2;
172
173 // List of functions and their descendants to trace with the function_graph tracer.
174 repeated string graph_function_filter = 3;
175}
176
177message TraceEvent {
178 // Currently we do not parse the event data and just return what the kernel outputs, line-by-line.
179 string raw_line = 1;
180}