k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/mla_rule_group.go (about)

     1  /*
     2  Copyright 2023 The Kubermatic Kubernetes Platform contributors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  )
    22  
    23  // +kubebuilder:validation:Enum=Metrics;Logs
    24  
    25  type MLARuleGroupType string
    26  
    27  const (
    28  	// RuleGroupTypeMetrics means the rule group defines the rules to generate alerts from metrics.
    29  	MLARuleGroupTypeMetrics MLARuleGroupType = "Metrics"
    30  	// RuleGroupTypeLogs means the rule group defines the rules to generate alerts from logs.
    31  	MLARuleGroupTypeLogs MLARuleGroupType = "Logs"
    32  )
    33  
    34  // +genclient
    35  // +kubebuilder:resource:scope=Cluster
    36  // +kubebuilder:object:generate=true
    37  // +kubebuilder:object:root=true
    38  // +kubebuilder:printcolumn:JSONPath=".spec.cluster.name",name="Cluster",type="string"
    39  // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date"
    40  
    41  type MLARuleGroup struct {
    42  	metav1.TypeMeta   `json:",inline"`
    43  	metav1.ObjectMeta `json:"metadata,omitempty"`
    44  
    45  	Spec MLARuleGroupSpec `json:"spec,omitempty"`
    46  }
    47  
    48  type MLARuleGroupSpec struct {
    49  	// Cluster is the reference to the cluster the ruleGroup should be created in.
    50  	Cluster ClusterReference `json:"cluster"`
    51  	// Type is the type of this ruleGroup applies to.
    52  	Type MLARuleGroupType `json:"ruleGroupType"`
    53  	// IsDefault indicates whether the ruleGroup is the default.
    54  	IsDefault bool `json:"isDefault,omitempty"`
    55  	// Data contains the RuleGroup data. Ref: https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/#rule_group
    56  	Data []byte `json:"data"`
    57  }
    58  
    59  // +kubebuilder:object:generate=true
    60  // +kubebuilder:object:root=true
    61  
    62  type MLARuleGroupList struct {
    63  	metav1.TypeMeta `json:",inline"`
    64  	metav1.ListMeta `json:"metadata,omitempty"`
    65  
    66  	Items []MLARuleGroup `json:"items"`
    67  }