Sha256: 793ee73b9f58456ebe42ac70311bc88ab64c31e25bbb2e9dfb80f926f9e175fb

Contents?: true

Size: 717 Bytes

Versions: 4

Compression:

Stored size: 717 Bytes

Contents

module RubyForGrafanaLoki 
  module Request
    include RubyForGrafanaLoki:: Connection

    def post(url, payload)
      respond_with(
        connection.post url, payload
      )
    end

    private
    def respond_with(response)
      if response.success?
        puts 'Log sent successfully to Loki.'
        puts "Response code: #{response.status}, Response body: #{response.body}"
        body = response.body.empty? ? response.body : JSON.parse(response.body)
        puts body
      else
        puts "Failed to send log to Loki. Response code: #{response.status}, Response body: #{response.body}"
      end
    end
    def get(path)
      respond_with(
        connection.get(path)
      )
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_for_grafana_loki-0.0.6 lib/ruby_for_grafana_loki/request.rb
ruby_for_grafana_loki-0.0.5 lib/ruby_for_grafana_loki/request.rb
ruby_for_grafana_loki-0.0.4 lib/ruby_for_grafana_loki/request.rb
ruby_for_grafana_loki-0.0.3 lib/ruby_for_grafana_loki/request.rb