Class: Fluent::Plugin::PrometheusPull::LabeledUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/fluent/plugin/prometheus_pull/labeled_url.rb

Constant Summary collapse

LABELED_URL_RE =
/^(?:@(?<label>[^@]*)@)?(?<url>.*)$/.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, label: nil) ⇒ LabeledUrl



11
12
13
14
# File 'lib/fluent/plugin/prometheus_pull/labeled_url.rb', line 11

def initialize(url:, label: nil)
  @url = url
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



9
10
11
# File 'lib/fluent/plugin/prometheus_pull/labeled_url.rb', line 9

def label
  @label
end

#urlObject (readonly)

Returns the value of attribute url.



9
10
11
# File 'lib/fluent/plugin/prometheus_pull/labeled_url.rb', line 9

def url
  @url
end

Class Method Details

.parse_labeled_url(url) ⇒ Object

Raises:

  • (Fluent::ConfigError)


20
21
22
23
24
25
26
27
# File 'lib/fluent/plugin/prometheus_pull/labeled_url.rb', line 20

def self.parse_labeled_url(url)
  match_data = LABELED_URL_RE.match(url)

  raise Fluent::ConfigError, "unable to use url '#{url}'" unless match_data

  new(url: match_data[:url],
      label: match_data[:label])
end

Instance Method Details

#to_sObject



16
17
18
# File 'lib/fluent/plugin/prometheus_pull/labeled_url.rb', line 16

def to_s
  url
end