Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 1 | // 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 | |
| 17 | syntax = "proto3"; |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 18 | package metropolis.proto.api; |
Serge Bazanski | 31370b0 | 2021-01-07 16:31:14 +0100 | [diff] [blame] | 19 | option go_package = "source.monogon.dev/metropolis/proto/api"; |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 20 | |
Serge Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 21 | // NodeDebugService exposes debug and testing endpoints that allow introspection into a running Metropolis node. |
Serge Bazanski | 77cb6c5 | 2020-12-19 00:09:22 +0100 | [diff] [blame] | 22 | // It is not authenticated and will be disabled in production. It is currently consumed by metropolis/cli/dbg and |
| 23 | // by tests. |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 24 | service NodeDebugService { |
| 25 | // GetDebugKubeconfig issues kubeconfigs with arbitrary identities and groups for debugging |
| 26 | rpc GetDebugKubeconfig(GetDebugKubeconfigRequest) returns (GetDebugKubeconfigResponse); |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 27 | |
| 28 | // GetLogs Returns historical and/or streaming logs for a given DN with given filters from the system global |
| 29 | // LogTree. |
| 30 | // |
Serge Bazanski | 549b72b | 2021-01-07 14:54:19 +0100 | [diff] [blame] | 31 | // For more information about this API, see //metropolis/pkg/logtree. But, in summary: |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 32 | // - 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 Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 34 | // process) or leveled (emitted by Metropolis code with a source line, timestamp, and severity). |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 35 | // - 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 Bazanski | 662b5b3 | 2020-12-21 13:49:00 +0100 | [diff] [blame] | 38 | // a running Metropolis node, or request all logs (at DN ""). |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 39 | // |
| 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 Brun | 09c275b | 2021-03-30 12:47:09 +0200 | [diff] [blame] | 42 | |
| 43 | // Trace enables tracing of Metropolis using the Linux ftrace infrastructure. |
| 44 | rpc Trace(TraceRequest) returns (stream TraceEvent); |
Lorenz Brun | 9d6c4c7 | 2021-07-20 21:16:27 +0200 | [diff] [blame] | 45 | |
| 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 Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 50 | } |
| 51 | |
Lorenz Brun | 9d6c4c7 | 2021-07-20 21:16:27 +0200 | [diff] [blame] | 52 | message ImagePart { |
| 53 | bytes data_part = 1; |
| 54 | } |
| 55 | |
| 56 | message LoadImageResponse { |
| 57 | } |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 58 | |
| 59 | message GetDebugKubeconfigRequest { |
| 60 | string id = 1; // Kubernetes identity (user) |
| 61 | repeated string groups = 2; // Kubernetes groups |
| 62 | } |
| 63 | |
| 64 | message GetDebugKubeconfigResponse { |
| 65 | string debug_kubeconfig = 1; |
| 66 | } |
| 67 | |
Serge Bazanski | 549b72b | 2021-01-07 14:54:19 +0100 | [diff] [blame] | 68 | // Severity level corresponding to //metropolis/pkg/logtree.Severity. |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 69 | enum LeveledLogSeverity { |
| 70 | INVALID = 0; |
| 71 | INFO = 1; |
| 72 | WARNING = 2; |
| 73 | ERROR = 3; |
| 74 | FATAL = 4; |
Serge Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 75 | } |
| 76 | |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 77 | // 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. |
| 84 | message 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 | |
| 107 | message 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 | |
| 135 | message 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 | |
| 145 | message LogEntry { |
| 146 | message Leveled { |
Serge Bazanski | 12971d6 | 2020-11-17 12:12:58 +0100 | [diff] [blame] | 147 | repeated string lines = 1; |
Serge Bazanski | b027218 | 2020-11-02 18:39:44 +0100 | [diff] [blame] | 148 | 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 Bazanski | efdb6e9 | 2020-07-13 17:19:27 +0200 | [diff] [blame] | 162 | } |
Lorenz Brun | 09c275b | 2021-03-30 12:47:09 +0200 | [diff] [blame] | 163 | |
| 164 | message 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 | |
| 177 | message 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 | } |