// SPDX-License-Identifier: AGPL-3.0-only
// Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/ruler/rulespb/rules.proto
// Provenance-includes-license: Apache-2.0
// Provenance-includes-copyright: The Cortex Authors.

syntax = "proto3";

package rules;

import "github.com/grafana/mimir/pkg/mimirpb/mimir.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/any.proto";
import "google/protobuf/duration.proto";

option go_package = "rulespb";
option (gogoproto.marshaler_all) = true;
option (gogoproto.unmarshaler_all) = true;

// RuleGroupDesc is a proto representation of a mimir rule group.
message RuleGroupDesc {
  reserved 5, 7, 8;
  string name = 1;
  string namespace = 2;
  google.protobuf.Duration interval = 3 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true
  ];
  repeated RuleDesc rules = 4;
  string user = 6;
  // The options field can be used to extend Mimir Ruler functionality without
  // having to repeatedly redefine the proto description. It can also be leveraged
  // to create custom `ManagerOpts` based on rule configs which can then be passed
  // to the Prometheus Manager.
  repeated google.protobuf.Any options = 9;
  repeated string sourceTenants = 10;

  // Deprecated: use queryOffset instead.
  google.protobuf.Duration evaluationDelay = 11 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true
  ];
  google.protobuf.Duration queryOffset = 13 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true
  ];

  bool align_evaluation_time_on_interval = 12;

  repeated cortexpb.LabelPair labels = 14 [
    (gogoproto.nullable) = false,
    (gogoproto.customtype) = "github.com/grafana/mimir/pkg/mimirpb.LabelAdapter"
  ];

  // The limit is enforced in Mimir per-user.
  int32 limit = 15;
}

// RuleDesc is a proto representation of a Prometheus Rule
message RuleDesc {
  reserved 7 to 12;
  string expr = 1;
  string record = 2;
  string alert = 3;
  google.protobuf.Duration for = 4 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true
  ];
  google.protobuf.Duration keep_firing_for = 13 [
    (gogoproto.nullable) = false,
    (gogoproto.stdduration) = true
  ];
  repeated cortexpb.LabelPair labels = 5 [
    (gogoproto.nullable) = false,
    (gogoproto.customtype) = "github.com/grafana/mimir/pkg/mimirpb.LabelAdapter"
  ];
  repeated cortexpb.LabelPair annotations = 6 [
    (gogoproto.nullable) = false,
    (gogoproto.customtype) = "github.com/grafana/mimir/pkg/mimirpb.LabelAdapter"
  ];
}
