Module: Mackerel::REST::Metric
- Included in:
- Client
- Defined in:
- lib/mackerel/metric.rb
Instance Method Summary collapse
- #define_graphs(graph_defs) ⇒ Object
- #get_host_metrics(host_id, name, from, to) ⇒ Object
- #get_latest_metrics(host_id, name) ⇒ Object
- #get_service_metrics(service_name, name, from, to) ⇒ Object
- #post_metrics(metrics) ⇒ Object
- #post_service_metrics(service_name, metrics) ⇒ Object
Instance Method Details
#define_graphs(graph_defs) ⇒ Object
42 43 44 45 46 |
# File 'lib/mackerel/metric.rb', line 42 def define_graphs(graph_defs) command = ApiCommand.new(:post, '/api/v0/graph-defs/create', @api_key) command.body = graph_defs.to_json data = command.execute(client) end |
#get_host_metrics(host_id, name, from, to) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/mackerel/metric.rb', line 10 def get_host_metrics(host_id, name, from, to) command = ApiCommand.new(:get, "/api/v0/hosts/#{host_id}/metrics", @api_key) command.params['name'] = name command.params['from'] = from command.params['to'] = to data = command.execute(client) data["metrics"] end |
#get_latest_metrics(host_id, name) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/mackerel/metric.rb', line 19 def get_latest_metrics(host_id, name) command = ApiCommand.new(:get, "/api/v0/tsdb/latest", @api_key) command.params['hostId'] = host_id command.params['name'] = name data = command.execute(client) data["tsdbLatest"] end |
#get_service_metrics(service_name, name, from, to) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/mackerel/metric.rb', line 33 def get_service_metrics(service_name, name, from, to) command = ApiCommand.new(:get, "/api/v0/services/#{service_name}/metrics", @api_key) command.params['name'] = name command.params['from'] = from command.params['to'] = to data = command.execute(client) data["metrics"] end |
#post_metrics(metrics) ⇒ Object
4 5 6 7 8 |
# File 'lib/mackerel/metric.rb', line 4 def post_metrics(metrics) command = ApiCommand.new(:post, '/api/v0/tsdb', @api_key) command.body = metrics.to_json data = command.execute(client) end |
#post_service_metrics(service_name, metrics) ⇒ Object
27 28 29 30 31 |
# File 'lib/mackerel/metric.rb', line 27 def post_service_metrics(service_name, metrics) command = ApiCommand.new(:post, "/api/v0/services/#{service_name}/tsdb", @api_key) command.body = metrics.to_json data = command.execute(client) end |