blob: 25e369e37ffa130c5578aac0093b823f2df50f88 [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);
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020042}
43
44
45message GetDebugKubeconfigRequest {
46 string id = 1; // Kubernetes identity (user)
47 repeated string groups = 2; // Kubernetes groups
48}
49
50message GetDebugKubeconfigResponse {
51 string debug_kubeconfig = 1;
52}
53
Serge Bazanski549b72b2021-01-07 14:54:19 +010054// Severity level corresponding to //metropolis/pkg/logtree.Severity.
Serge Bazanskib0272182020-11-02 18:39:44 +010055enum LeveledLogSeverity {
56 INVALID = 0;
57 INFO = 1;
58 WARNING = 2;
59 ERROR = 3;
60 FATAL = 4;
Serge Bazanskiefdb6e92020-07-13 17:19:27 +020061}
62
Serge Bazanskib0272182020-11-02 18:39:44 +010063// Filter set when requesting logs for a given DN. This message is equivalent to the following GADT enum:
64// data LogFilter = WithChildren
65// | OnlyRaw
66// | OnlyLeveled
67// | LeveledWithMinimumSeverity(Severity)
68//
69// Multiple LogFilters can be chained/combined when requesting logs, as long as they do not conflict.
70message LogFilter {
71 // Entries will be returned not only for the given DN, but all child DNs as well. For instance, if the
72 // requested DN is foo, entries logged to foo, foo.bar and foo.bar.baz will all be returned.
73 message WithChildren {
74 }
75 // Only raw logging entries will be returned. Conflicts with OnlyLeveled filters.
76 message OnlyRaw {
77 }
78 // Only leveled logging entries will be returned. Conflicts with OnlyRaw filters.
79 message OnlyLeveled {
80 }
81 // If leveled logs are returned, all entries at severity lower than `minimum` will be discarded.
82 message LeveledWithMinimumSeverity {
83 LeveledLogSeverity minimum = 1;
84 }
85 oneof filter {
86 WithChildren with_children = 1;
87 OnlyRaw only_raw = 3;
88 OnlyLeveled only_leveled = 4;
89 LeveledWithMinimumSeverity leveled_with_minimum_severity = 5;
90 }
91}
92
93message GetLogsRequest {
94 // DN from which to request logs. All supervised runnables live at `root.`, the init code lives at `init.`.
95 string dn = 1;
96 // Filters to apply to returned data.
97 repeated LogFilter filters = 2;
98
99 enum BacklogMode {
100 BACKLOG_INVALID = 0;
101 // No historic data will be returned.
102 BACKLOG_DISABLE = 1;
103 // All available historic data will be returned.
104 BACKLOG_ALL = 2;
105 // At most backlog_count entries will be returned, if available.
106 BACKLOG_COUNT = 3;
107 }
108 BacklogMode backlog_mode = 3;
109 int64 backlog_count = 4;
110
111 enum StreamMode {
112 STREAM_INVALID = 0;
113 // No streaming entries, gRPC stream will be closed as soon as all backlog data is served.
114 STREAM_DISABLE = 1;
115 // Entries will be streamed as early as available right after all backlog data is served.
116 STREAM_UNBUFFERED = 2;
117 }
118 StreamMode stream_mode = 5;
119}
120
121message GetLogsResponse {
122 // Entries from the requested historical entries (via WithBackLog). They will all be served before the first
123 // stream_entries are served (if any).
124 repeated LogEntry backlog_entries = 1;
125 // Entries streamed as they arrive. Currently no server-side buffering is enabled, instead every line is served
126 // as early as it arrives. However, this might change in the future, so this behaviour cannot be depended
127 // upon.
128 repeated LogEntry stream_entries = 2;
129}
130
131message LogEntry {
132 message Leveled {
Serge Bazanski12971d62020-11-17 12:12:58 +0100133 repeated string lines = 1;
Serge Bazanskib0272182020-11-02 18:39:44 +0100134 int64 timestamp = 2;
135 LeveledLogSeverity severity = 3;
136 string location = 4;
137 }
138 message Raw {
139 string data = 1;
140 int64 original_length = 2;
141 }
142
143 string dn = 1;
144 oneof kind {
145 Leveled leveled = 2;
146 Raw raw = 3;
147 }
Serge Bazanskiefdb6e92020-07-13 17:19:27 +0200148}