160 lines
3.5 KiB
Protocol Buffer
160 lines
3.5 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package monitoring;
|
|
|
|
option go_package = "github.com/your-org/sysmonstm/proto";
|
|
|
|
// MetricsService handles streaming metrics from collectors to aggregator
|
|
service MetricsService {
|
|
// Client-side streaming: collector streams metrics to aggregator
|
|
rpc StreamMetrics(stream Metric) returns (StreamAck) {}
|
|
|
|
// Get current state of a machine
|
|
rpc GetCurrentState(StateRequest) returns (MachineState) {}
|
|
|
|
// Get current state of all machines
|
|
rpc GetAllStates(Empty) returns (AllMachinesState) {}
|
|
}
|
|
|
|
// ControlService handles bidirectional control commands
|
|
service ControlService {
|
|
// Bidirectional streaming for commands and responses
|
|
rpc Control(stream ControlCommand) returns (stream ControlResponse) {}
|
|
}
|
|
|
|
// ConfigService handles dynamic configuration
|
|
service ConfigService {
|
|
// Get current configuration for a collector
|
|
rpc GetConfig(ConfigRequest) returns (CollectorConfig) {}
|
|
|
|
// Stream configuration updates
|
|
rpc WatchConfig(ConfigRequest) returns (stream CollectorConfig) {}
|
|
}
|
|
|
|
// Empty message for requests with no parameters
|
|
message Empty {}
|
|
|
|
// Basic metric message
|
|
message Metric {
|
|
string machine_id = 1;
|
|
string hostname = 2;
|
|
int64 timestamp_ms = 3;
|
|
MetricType type = 4;
|
|
double value = 5;
|
|
map<string, string> labels = 6;
|
|
}
|
|
|
|
// Batch of metrics for efficient transmission
|
|
message MetricBatch {
|
|
string machine_id = 1;
|
|
string hostname = 2;
|
|
int64 timestamp_ms = 3;
|
|
repeated MetricPoint metrics = 4;
|
|
}
|
|
|
|
message MetricPoint {
|
|
MetricType type = 1;
|
|
double value = 2;
|
|
map<string, string> labels = 3;
|
|
}
|
|
|
|
enum MetricType {
|
|
METRIC_TYPE_UNSPECIFIED = 0;
|
|
CPU_PERCENT = 1;
|
|
CPU_PERCENT_PER_CORE = 2;
|
|
MEMORY_PERCENT = 3;
|
|
MEMORY_USED_BYTES = 4;
|
|
MEMORY_AVAILABLE_BYTES = 5;
|
|
DISK_PERCENT = 6;
|
|
DISK_USED_BYTES = 7;
|
|
DISK_READ_BYTES_SEC = 8;
|
|
DISK_WRITE_BYTES_SEC = 9;
|
|
NETWORK_SENT_BYTES_SEC = 10;
|
|
NETWORK_RECV_BYTES_SEC = 11;
|
|
NETWORK_CONNECTIONS = 12;
|
|
PROCESS_COUNT = 13;
|
|
LOAD_AVG_1M = 14;
|
|
LOAD_AVG_5M = 15;
|
|
LOAD_AVG_15M = 16;
|
|
}
|
|
|
|
// Acknowledgment for streamed metrics
|
|
message StreamAck {
|
|
bool success = 1;
|
|
int64 metrics_received = 2;
|
|
string message = 3;
|
|
}
|
|
|
|
// Request for machine state
|
|
message StateRequest {
|
|
string machine_id = 1;
|
|
}
|
|
|
|
// Current state of a single machine
|
|
message MachineState {
|
|
string machine_id = 1;
|
|
string hostname = 2;
|
|
int64 last_seen_ms = 3;
|
|
repeated Metric current_metrics = 4;
|
|
HealthStatus health = 5;
|
|
map<string, string> metadata = 6;
|
|
}
|
|
|
|
// State of all machines
|
|
message AllMachinesState {
|
|
repeated MachineState machines = 1;
|
|
}
|
|
|
|
enum HealthStatus {
|
|
HEALTH_STATUS_UNSPECIFIED = 0;
|
|
HEALTHY = 1;
|
|
WARNING = 2;
|
|
CRITICAL = 3;
|
|
UNKNOWN = 4;
|
|
OFFLINE = 5;
|
|
}
|
|
|
|
// Control commands for collectors
|
|
message ControlCommand {
|
|
string command_id = 1;
|
|
oneof command {
|
|
UpdateIntervalCommand update_interval = 2;
|
|
RestartCollectionCommand restart = 3;
|
|
ShutdownCommand shutdown = 4;
|
|
}
|
|
}
|
|
|
|
message UpdateIntervalCommand {
|
|
int32 interval_seconds = 1;
|
|
}
|
|
|
|
message RestartCollectionCommand {}
|
|
|
|
message ShutdownCommand {
|
|
bool graceful = 1;
|
|
}
|
|
|
|
message ControlResponse {
|
|
string command_id = 1;
|
|
bool success = 2;
|
|
string message = 3;
|
|
}
|
|
|
|
// Configuration messages
|
|
message ConfigRequest {
|
|
string machine_id = 1;
|
|
}
|
|
|
|
message CollectorConfig {
|
|
int32 collection_interval_seconds = 1;
|
|
repeated MetricType enabled_metrics = 2;
|
|
map<string, string> labels = 3;
|
|
repeated ThresholdConfig thresholds = 4;
|
|
}
|
|
|
|
message ThresholdConfig {
|
|
MetricType metric_type = 1;
|
|
double warning_threshold = 2;
|
|
double critical_threshold = 3;
|
|
}
|