Class: Kube::Cluster::Standard::VictoriaMetrics::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/kube/cluster/standard/victoria_metrics/vm_rule.rb

Overview

A named group of rules. rule/alert build and collect the leaves; the block is instance_eval'd so those helpers read like keywords.

Group.new("node.rules") {
rule "node:node_num_cpu:sum" do
  <<~PROMQL
    count by (cluster, node) (...)
  PROMQL
end
}

Instance Method Summary collapse

Constructor Details

#initialize(name, &block) ⇒ Group

Returns a new instance of Group.



58
59
60
61
62
# File 'lib/kube/cluster/standard/victoria_metrics/vm_rule.rb', line 58

def initialize(name, &block)
  @name  = name
  @rules = []
  instance_eval(&block) if block
end

Instance Method Details

#alert(name, **opts, &block) ⇒ Object



65
# File 'lib/kube/cluster/standard/victoria_metrics/vm_rule.rb', line 65

def alert(name, **opts, &block) = @rules << Alert.new(name, **opts, &block)

#rule(name, **opts, &block) ⇒ Object



64
# File 'lib/kube/cluster/standard/victoria_metrics/vm_rule.rb', line 64

def rule(name, **opts, &block)  = @rules << Rule.new(name, **opts, &block)

#to_hObject



67
# File 'lib/kube/cluster/standard/victoria_metrics/vm_rule.rb', line 67

def to_h = { name: @name, rules: @rules.map(&:to_h) }