Skip to content

Instantly share code, notes, and snippets.

@benarent
Last active March 22, 2017 16:53
Show Gist options
  • Save benarent/d6b7532a3ec33c97e29e1fd0a07dc9ef to your computer and use it in GitHub Desktop.
Save benarent/d6b7532a3ec33c97e29e1fd0a07dc9ef to your computer and use it in GitHub Desktop.
StatsD Instructions

Java Install Instructions

These instructions are for Java language bindings. If you are looking to monitor the JVM, we recommend using our JVM integration.

If use the Dropwizard framework please use our Dropwizard Plugin.

  1. Using Maven.
<dependency>
    <groupId>com.librato.metrics</groupId>
    <artifactId>librato-java</artifactId>
    <version>2.0.5</version>
</dependency>
  1. Initialize the client:
LibratoClient client = LibratoClient.builder(customer-email@example.com, CUSTOMER_API_KEY)
    // these are optional
    .setConnectTimeout(new Duration(5, SECONDS))
    .setReadTimeout(new Duration(5, SECONDS))
    .setAgentIdentifier("my app name")
    // and finally build
    .build();
  1. Quick Start for sending metrics.
PostMeasuresResult result = client.postMeasures(new Measures()
    .add(new TaggedMeasure(name, value, tag, tag))
    .add(new TaggedMeasure(name, sum, count, min, max, tag, tag ,tag)));

for (PostResult postResult : result.results) {
    if (result.isError()) {
        log.error(result.toString);
    }
}
{
"event": "librato_",
"url": "https://metrics-api.librato.com/v1/measurements",
"requestType": "POST",
"auth": {
"username": "YOUR_LIBRATO_USERNAME",
"password": "YOUR_LIBRATO_API_TOKEN"
},
"json": {
"tags": {
"device": "{{PARTICLE_DEVICE_ID}}"
},
"measurements": [{
"name": "{{PARTICLE_EVENT_NAME}}",
"value": "{{PARTICLE_EVENT_VALUE}}"
}]
},
"noDefaults": true
}

Particle Install Instructions

Full Instructions availble at docs.particle.io

  1. Download librato.json
  2. Using the Particle CLI. Create a new webhook.
$particle webhook create librato.json
  1. Restart your application.

Python Install Instructions

Full Instructions availble at the Librato StatsD Github Readme.

  1. Install via pip

$ pip install librato-metrics or from your application or script: import librato

  1. Setup Authentication

api = librato.connect('customer-email@example.com"', 'CUSTOMER_API_KEY')

  1. Quick Start for sending metrics.

api.submit("temperature", 22, tags={'city': 'austin', 'station': '27'})

Ruby Install Instructions

Full Instructions availble at the Librato Metrics Github Readme.

  1. Install Librato Metrics into your application. $gem install librato-metrics

  2. Include Librato into your application. require 'librato/metrics'

  3. Quick Start for sending metrics.

Librato::Metrics.authenticate 'customer-email@example.com', 'CUSTOMER_API_KEY'
Librato::Metrics.submit my_metric: 42, my_other_metric: 1002

StatsD Install Instructions

Full Instructions availble at the Librato StatsD Github Readme.

  1. Install StatsD into your application.
$ cd /path/to/statsd
$ npm install statsd-librato-backend
  1. Add the following to your StatsD config file.
librato:{ 
  email: "customer-email@example.com",
  token: "CUSTOMER_API_KEY"
}
  1. Restart your application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment