syntax = "proto2";

option java_multiple_files = true;
option java_package = "alluxio.grpc";
option java_outer_classname = "MetricMasterProto";

package alluxio.grpc.metric;

import "grpc/common.proto";

message ClearMetricsPRequest {}

message ClearMetricsPResponse {}

message MetricsHeartbeatPOptions {
  repeated ClientMetrics clientMetrics = 1;
}

message ClientMetrics {
  optional string source = 1;
  repeated grpc.Metric metrics = 2;
}

message MetricsHeartbeatPRequest {
  optional MetricsHeartbeatPOptions options = 1;
}

message MetricsHeartbeatPResponse {}

// This type is used as a union, only one of doubleValue or stringValue should be set
message MetricValue {
  optional double doubleValue = 1;
  optional string stringValue = 2;
  optional grpc.MetricType metricType = 6;
}

message GetMetricsPOptions {}
message GetMetricsPResponse {
  map<string,MetricValue> metrics = 1;
}

/**
 * This interface contains metrics master service endpoints for Alluxio clients.
 */
service MetricsMasterClientService {

  /**
   * Clears the metrics in the cluster.
   */
  rpc  ClearMetrics(ClearMetricsPRequest) returns (ClearMetricsPResponse);

  /**
   * Periodic metrics master client heartbeat.
   */
  rpc  MetricsHeartbeat(MetricsHeartbeatPRequest) returns (MetricsHeartbeatPResponse);

  /**
   * Returns a map of metrics property names and their values from Alluxio metrics system.
   */
  rpc GetMetrics(GetMetricsPOptions) returns (GetMetricsPResponse);
}
