-
Notifications
You must be signed in to change notification settings - Fork 283
Track your own metrics
Stagemonitor supports the annotations defined in metrics-annotation by instrumenting your code.
Annotating a method with @Timed will create a timer for that method, that is automatically updated every time, the method is executed.
Annotating a method with @Metered will create a meter for that method, that will keep track of the execution rate (or throughput) and execution count of the method.
Annotating a method with @ExceptionMetered will create a meter for that method, that will keep track of the rate (or throughput) and execution count of thrown exceptions by the method.
You can mark no-arg methods that have a return type with the @Gauge annotation. A gauge will be created which uses the annotated method's return value as its value. For that to work, you need to annotate the class with @MonitorGauges.
Example:
@MonitorGauges
public class Queue {
@Gauge(name = "queueSize")
public int getQueueSize() {
return queue.size;
}
}
Use the following snippet to get a reference to the MetricRegistry
Metric2Registry registry = Stagemonitor.getMetric2Registry();
registry.timer(name("api_request_duration").tag("stage", "transform").build()).update(duration, NANOSECONDS)Refer to the metrics documentation on how to add Gauges, Counters, Histograms, Meters, and Timers.
Stagemonitor already contains a preconfigured "Custom Metrics" dashboard that contains all metrics created by the annotations. This dashboard can also be customized or you could create a completely custom one.
The Prometheus documentation includes useful best practices about what to measure and how to name metrics.
Copyright (c) 2018 iSYS Software GmbH
- Home
- Installation
- Troubleshooting
- Blogs/Articles
- Time Series Database Support
- FAQs
- How to...
- End User Monitoring
- Alerting
- Configuration
- Dashboards