Engine Yard

image0

The Metrics Engine Yard service allows you to easily create a Metrics account for your Engine Yard application. This will provision an account, link it to your app, and provide instant dashboard access to any metrics you push up. The add-on is currently being tested, if you would like an invite please contact metrics@librato.com. Users who already have a Metrics account (by creating one through our site) can use those credentials instead.

Username and Token

Using the add-on populates the Engine Yard configuration with a username and API token for instant access to your account. First require 'ey_config'. Then, access your credentials via

EY::Config.get('librato-metrics','LIBRATO_METRICS_USER')

and

EY::Config.get('librato-metrics','LIBRATO_METRICS_TOKEN')

If you do not have the service enabled but would like to use a standard Metrics account, you will need to obtain your API token.

Submitting Data

Once you have access credentials, uploading data points to the Metrics API is very simple. First choose a metric: either a gauge or counter. Gauges are realtime indicators which may go up or down and are a ‘snapshot’ of a reading. Examples of gauges are user logins per hour or the temperature outside. Counters are continually increasing and wrap around to zero on overflow. Examples of counters are total bytes sent or miles driven. After choosing, you can POST data to it via our RESTful API. An example (in Ruby) is provided below:

require 'rest-client'
require 'ey_config'

# these are automatically set by the EY service
# if you already have a username and token, place them here

user = EY::Config.get('librato-metrics','LIBRATO_METRICS_USER')
token = EY::Config.get('librato-metrics','LIBRATO_METRICS_TOKEN')
metrics_api = RestClient::Resource.new 'https://metrics-api.librato.com', user, token

# place gauges (instead of counters) in a :gauges hash
metrics_api['/v1/metrics'].post :counters => {"my_sample_counter" => { :value => 12345 }}

When data is submitted, you can view the results by visiting Metrics through your EY dashboard.

More information

A more full-fledged Engine Yard application can be found here: https://github.com/librato/sinatratest.

A full description of the Metrics API can be found on our developer site.