github.com/cilium/cilium@v1.16.2/api/v1/recorder/recorder.proto (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright Authors of Hubble 3 4 syntax = "proto3"; 5 6 import "google/protobuf/timestamp.proto"; 7 import "google/protobuf/duration.proto"; 8 9 package recorder; 10 11 option go_package = "github.com/cilium/cilium/api/v1/recorder"; 12 13 // Recorder implements the Hubble module for capturing network packets 14 service Recorder { 15 // Record can start and stop a single recording. The recording is 16 // automatically stopped if the client aborts this rpc call. 17 rpc Record (stream RecordRequest) returns (stream RecordResponse); 18 } 19 20 message RecordRequest { 21 oneof request_type { 22 // start starts a new recording with the given parameters. 23 StartRecording start = 1; 24 // stop stops the running recording. 25 StopRecording stop = 2; 26 } 27 } 28 29 message StartRecording { 30 // filesink configures the outfile of this recording 31 // Future alternative sink configurations may be added as a 32 // backwards-compatible change by moving this field into a oneof. 33 FileSinkConfiguration filesink = 1; 34 35 // include list for this recording. Packets matching any of the provided 36 // filters will be recorded. 37 repeated Filter include = 2; 38 39 // max_capture_length specifies the maximum packet length. 40 // Full packet length will be captured if absent/zero. 41 uint32 max_capture_length = 3; 42 43 // stop_condition defines conditions which will cause the recording to 44 // stop early after any of the stop conditions has been hit 45 StopCondition stop_condition = 4; 46 } 47 48 // StopCondition defines one or more conditions which cause the recording to 49 // stop after they have been hit. Stop conditions are ignored if they are 50 // absent or zero-valued. If multiple conditions are defined, the recording 51 // stops after the first one is hit. 52 message StopCondition { 53 // bytes_captured_count stops the recording after at least this many bytes 54 // have been captured. Note: The resulting file might be slightly larger due 55 // to added pcap headers. 56 uint64 bytes_captured_count = 1; 57 // packets_captured_count stops the recording after at least this many packets have 58 // been captured. 59 uint64 packets_captured_count = 2; 60 // time_elapsed stops the recording after this duration has elapsed. 61 google.protobuf.Duration time_elapsed = 3; 62 } 63 64 // FileSinkConfiguration configures the file output. Possible future additions 65 // might be the selection of the output volume. The initial implementation will 66 // only support a single volume which is configured as a cilium-agent CLI flag. 67 message FileSinkConfiguration { 68 // file_prefix is an optional prefix for the file name. 69 // Defaults to `hubble` if empty. Must match the following regex if not 70 // empty: ^[a-z][a-z0-9]{0,19}$ 71 // The generated filename will be of format 72 // <file_prefix>_<unixtime>_<unique_random>_<node_name>.pcap 73 string file_prefix = 1; 74 } 75 76 message Filter { 77 // source_cidr. Must not be empty. 78 // Set to 0.0.0.0/0 to match any IPv4 source address (::/0 for IPv6). 79 string source_cidr = 1; 80 // source_port. Matches any source port if empty. 81 uint32 source_port = 2; 82 // destination_cidr. Must not be empty. 83 // Set to 0.0.0.0/0 to match any IPv4 destination address (::/0 for IPv6). 84 string destination_cidr = 3; 85 // destination_port. Matches any destination port if empty. 86 uint32 destination_port = 4; 87 // protocol. Matches any protocol if empty. 88 Protocol protocol = 5; 89 } 90 91 92 // Protocol is a one of the supported protocols for packet capture 93 enum Protocol { 94 PROTOCOL_ANY = 0; 95 PROTOCOL_TCP = 6; 96 PROTOCOL_UDP = 17; 97 PROTOCOL_SCTP = 132; 98 } 99 100 message StopRecording {} 101 102 message RecordResponse { 103 // name of the node where this recording is happening 104 string node_name = 1; 105 // time at which this event was observed on the above node 106 google.protobuf.Timestamp time = 2; 107 108 // Note: In this initial design, any fatal error will be returned as 109 // gRPC errors and are not part of the regular response type. 110 // It is a forward-compatible change to introduce additional more 111 // granular or structured error responses here. 112 oneof response_type { 113 // running means that the recording is capturing packets. This is 114 // emitted in regular intervals 115 RecordingRunningResponse running = 3; 116 // stopped means the recording has stopped 117 RecordingStoppedResponse stopped = 4; 118 } 119 } 120 121 message RecordingStatistics { 122 // bytes_captured is the total amount of bytes captured in the recording 123 uint64 bytes_captured = 1; 124 // packets_captured is the total amount of packets captured the recording 125 uint64 packets_captured = 2; 126 // packets_lost is the total amount of packets matching the filter during 127 // the recording, but never written to the sink because it was overloaded. 128 uint64 packets_lost = 3; 129 // bytes_lost is the total amount of bytes matching the filter during 130 // the recording, but never written to the sink because it was overloaded. 131 uint64 bytes_lost = 4; 132 } 133 134 message RecordingRunningResponse { 135 // stats for the running recording 136 RecordingStatistics stats = 1; 137 } 138 139 message RecordingStoppedResponse { 140 // stats for the recording 141 RecordingStatistics stats = 1; 142 // filesink contains the path to the captured file 143 FileSinkResult filesink = 2; 144 } 145 146 message FileSinkResult { 147 // file_path is the absolute path to the captured pcap file 148 string file_path = 1; 149 }