I was looking for a tool that met the following requirements:
- View and monitor server statistics (CPU usage, disk usage etc.)
- Publish custom metrics from server-side apps.
- Present metrics in user-friendly dashboards.
After some googling I came across DataDog, "Cloud Monitoring as a Service". So far I'm impressed. Setup is incredibly fast; I installed the datadog agent on a Linux VM by pasting one line into a terminal: https://app.datadoghq.com/account/settings#agent/ubuntu. This automatically enables all the infrastructure monitoring I need for that VM:
It's really easy to view infrastructure graphs, set up monitoring alerts and dashboards.
Now that was done, I wanted to log custom metrics from my Java app. Datadog provides a simple Java library for logging metrics. The metrics are sent via UDP to the datadog agent, which collates and publishes them to the datadog service. The nice thing is that the metrics are then automatically available, no config required!
I'm using the Spring framework so I exposed the Java client as a bean like so:
@Bean(name = "dataDogMetrics")
public StatsDClient dataDogMetrics() throws StatsDClientException {
return new NonBlockingStatsDClient();
}
Now I could easily inject the bean anywhere and log stats:
@Autowired
private StatsDClient dataDogMetrics;
.....
dataDogMetrics.incrementCounter("test");
I could then immediately see the stats in the datadog service, and produce pretty graphs like this:
...nice!
No comments:
Post a Comment