Module: Zeus::MetricsInterface

Includes:
RestInterface
Included in:
APIClient
Defined in:
lib/zeus/api_client/metrics_interface.rb

Overview

Interface for dealing with metrics api calls

Instance Method Summary collapse

Instance Method Details

#delete_metrics(name) ⇒ Zeus::APIClient::Result

delete metrics

Parameters:

  • name (String)

    a target metrics name

Returns:

  • (Zeus::APIClient::Result)


80
81
82
83
# File 'lib/zeus/api_client/metrics_interface.rb', line 80

def delete_metrics(name)
  response = delete("/metrics/#{@access_token}/#{name}/")
  Result.new(response)
end

#get_metrics(options = {}) ⇒ Zeus::APIClient::Result

Get metrics

Parameters:

  • options (Hash) (defaults to: {})

    can contain: @param [String] regex a factor for filtering by metrics name @param [String] from_date a factor for filtering by start timestamp @param [String] to_date a factor for filtering by end timestamp @param [String] aggregator an aggregation methods @param [String] group_interval grouping values by time interval.

    For example, 1000s, 100m, 10h, 1d , 1w
    

    @param [String] filter_condition filters to be applied to metric values.

    eg: "column1 > 0", "column1 > 50 AND column2 = 10"
    

    @param [Integer] limit a maximum number of returning values

Returns:

  • (Zeus::APIClient::Result)


70
71
72
73
74
75
# File 'lib/zeus/api_client/metrics_interface.rb', line 70

def get_metrics(options = {})
  response = get("/metrics/#{@access_token}/_values/", options)
  Result.new(response)
rescue => e
  Result.new(e.response)
end

#list_metrics(options = {}) ⇒ Zeus::APIClient::Result

Get metrics list

Parameters:

  • options (Hash) (defaults to: {})

    can contain: @param [String] regex a factor for filtering by metrics name.

    eg: metric.name, metric.name*, metric.name.* etc.
    

    @param [String] from_date a factor for filtering by start timestamp @param [String] to_date a factor for filtering by end timestamp @param [String] aggregator an aggregation methods @param [String] group_interval grouping values by time interval.

    For example, 1000s, 100m, 10h, 1d , 1w
    

    @param [String] filter_condition a factor for filtering by metrics name @param [String] limit a maximum number of returning values

Returns:

  • (Zeus::APIClient::Result)


36
37
38
39
40
41
# File 'lib/zeus/api_client/metrics_interface.rb', line 36

def list_metrics(options = {})
  response = get("/metrics/#{@access_token}/_names/", options)
  Result.new(response)
rescue => e
  Result.new(e.response)
end

#send_metrics(name, metrics) ⇒ Zeus::APIClient::Result

Send metrics list

Parameters:

  • name (String)

    a name of metrics. For example, metric.name, metric.name*, metric.name.* etc.

  • metrics (Array)

    a list of hash objects

Returns:

  • (Zeus::APIClient::Result)


48
49
50
51
52
53
54
55
56
# File 'lib/zeus/api_client/metrics_interface.rb', line 48

def send_metrics(name, metrics)
  params = { metrics: metrics }
  begin
    response = post("/metrics/#{@access_token}/#{name}/", params)
    Result.new(response)
  rescue => e
    Result.new(e.response)
  end
end