syntax = "proto3";

package silencepb;

option go_package = "github.com/prometheus/alertmanager/silence/silencepb";

import "google/protobuf/timestamp.proto";

// Matcher specifies a rule, which can match or set of labels or not.
message Matcher {
  // Type specifies how the given name and pattern are matched
  // against a label set.
  enum Type {
    EQUAL = 0;
    REGEXP = 1;
    NOT_EQUAL = 2;
    NOT_REGEXP = 3;
  };
  Type type = 1;

  // The label name in a label set to against which the matcher
  // checks the pattern.
  string name = 2;
  // The pattern being checked according to the matcher's type.
  string pattern = 3;
}

// DEPRECATED: A comment can be attached to a silence.
message Comment {
  string author = 1;
  string comment = 2;
  google.protobuf.Timestamp timestamp = 3;
}

// MatcherSet is a set of matchers all of which have to be true
// for a silence to affect a given label set.
message MatcherSet {
  repeated Matcher matchers = 1;
}

// Silence specifies an object that ignores alerts based
// on a set of matchers during a given time frame.
message Silence {
  // A globally unique identifier.
  string id = 1;

  // A set of matchers all of which have to be true for a silence
  // to affect a given label set. For silences with matcher_sets,
  // this is expected to be equal to the first entry in matcher_sets
  repeated Matcher matchers = 2;

  // The time range during which the silence is active.
  google.protobuf.Timestamp starts_at = 3;
  google.protobuf.Timestamp ends_at = 4;

  // The last notification made to the silence.
  google.protobuf.Timestamp updated_at = 5;

  // DEPRECATED: A set of comments made on the silence.
  repeated Comment comments = 7;
  // Comment for the silence.
  string created_by = 8;
  string comment = 9;
  
  // Additional structured information about the silence
  map<string, string> annotations = 10;

  // Multiple matcher sets with OR logic between them.
  // At least one matcher set must match for the silence to apply.
  repeated MatcherSet matcher_sets = 11;
}

// MeshSilence wraps a regular silence with an expiration timestamp
// after which the silence may be garbage collected.
message MeshSilence {
  Silence silence = 1;
  google.protobuf.Timestamp expires_at = 2;
}
