Skip to content

Commit

Permalink
Example code for publishing to Graphite
Browse files Browse the repository at this point in the history
Time saver for those wishing to test out easy Graphite integration vs digging through Servo doc and example code
  • Loading branch information
jboyd01 committed Mar 2, 2015
1 parent eccf192 commit 623c4c3
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion hystrix-contrib/hystrix-servo-metrics-publisher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

This is an implementation of [HystrixMetricsPublisher](http://netflix.github.com/Hystrix/javadoc/index.html?com/netflix/hystrix/strategy/metrics/HystrixMetricsPublisher.html) that publishes metrics using [Netflix Servo](https://github.com/Netflix/servo).

Servo enables metrics to be exposed via JMX or published to Graphite or CloudWatch.

See the [Metrics & Monitoring](https://github.com/Netflix/Hystrix/wiki/Metrics-and-Monitoring) Wiki for more information.

# Binaries
Expand All @@ -22,4 +24,25 @@ and for Ivy:

```xml
<dependency org="com.netflix.hystrix" name="hystrix-servo-metrics-publisher" rev="1.1.2" />
```
```

#Example Publishing metrics to Graphite

Some minimal Servo configuration must be done during application startup (ie time of Hystrix plugin registration) to enable Servo to publish Hystrix metrics to Graphite:

```java
// Registry plugin with hystrix
HystrixPlugins.getInstance().registerMetricsPublisher(HystrixServoMetricsPublisher.getInstance());

........

// Minimal Servo configuration for publishing to Graphite
final List<MetricObserver> observers = new ArrayList<MetricObserver>();

observers.add(new GraphiteMetricObserver(getHostName(), "graphite-server.example.com:2003"));
PollScheduler.getInstance().start();
PollRunnable task = new PollRunnable(new MonitorRegistryMetricPoller(), BasicMetricFilter.MATCH_ALL, true, observers);
PollScheduler.getInstance().addPoller(task, 5, TimeUnit.SECONDS);
```

It's that simple. See [Servo wiki](https://github.com/Netflix/servo/wiki/Getting-Started) and [Publishing to Graphite](https://github.com/Netflix/servo/wiki/Publishing-to-Graphite) for full documentation.

0 comments on commit 623c4c3

Please sign in to comment.