Sha256: 5513aff16e23db1d539308c3213f80e6febc32a8cdac8c639262bb4d36e68f54

Contents?: true

Size: 651 Bytes

Versions: 1

Compression:

Stored size: 651 Bytes

Contents

# frozen_string_literal: true

module Fluent
  module Plugin
    module PrometheusPull
      class LabeledUrl
        LABELED_URL_RE = /^(?:@(?<label>[^@]*)@)?(?<url>.*)$/.freeze

        attr_reader :url, :label

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

        def to_s
          url
        end

        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
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fluent-plugin-prometheus-pull-0.4.0 lib/fluent/plugin/prometheus_pull/labeled_url.rb