Skip to content

Publishing to Graphite

copperlight edited this page Dec 17, 2014 · 4 revisions

Introduction

In this configuration, Servo fulfills a feature set similar to StatsD.

Initial Graphite Setup

Follow the steps outlined on the Graphite Installation page.

Configuring the Observer

Creating an observer you just to select the prefix and specify the address for the graphite server:

String prefix = "servo";
String addr = "localhost:2003";
MetricObserver observer = new GraphiteMetricObserver(prefix, addr);

All metrics reported will have the same prefix as the first part of the name. See the Graphite naming scheme documentation for more information. The default naming convention is just to use the prefix and the metric name, all other tags will be ignored. You can customize the names by implementing the naming convention interface and passing it to the observer.

Running Example

There is an example app that runs a basic web server and records a few metrics about requests. To run the example:

$ ./gradlew servo-example:run

By default it will log metrics to local files in the /tmp directory. You can configure it to send to graphite by setting the system properties:

servo.example.isGraphiteObserverEnabled=true
servo.example.graphiteObserverAddress=<your_server_name>:<port>