THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
Following are some main class of eagle metric framework
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
/** * It's just a workaround to extends Gauge instead of Metric interface * For MetricRegistry's notifyListenerOfRemovedMetric method will throw exception on unknown metric type */ public interface IEagleMetric extends Gauge<Double> { void registerListener(EagleMetricListener listener); /** * return true if the metric need to be flushed, otherwise return false * @param value * @param userTimeClock * @return */ boolean update(double value, long userTimeClock); } |
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public interface EagleMetricListener { /** * The method should be called in thread-safe mode * @param metrics */ void onMetricFlushed(List<EagleMetric> metrics); } |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
public class EagleServiceReporterMetricListener implements EagleMetricListener{ private EagleServiceClientImpl client; private static final Logger LOG = LoggerFactory.getLogger(EagleServiceReporterMetricListener.class); public EagleServiceReporterMetricListener(String host, int port, String username, String password) { client = new EagleServiceClientImpl(host, port, username, password); } public EagleServiceReporterMetricListener(String host, int port) { client = new EagleServiceClientImpl(host, port, null, null); } public void onMetricFlushed(List<EagleMetric> metrics) { List<GenericMetricEntity> entities = new ArrayList<>(); for (EagleMetric metric : metrics) { String metricName = metric.name; entities.add(MetricEntityAdaptor.convert(metricName, metric)); } try { int total = entities.size(); GenericServiceAPIResponseEntity<String> response = client.create(entities, GenericMetricEntity.GENERIC_METRIC_SERVICE); if(response.isSuccess()) { LOG.info("Wrote " + total + " entities to service"); }else{ LOG.error("Failed to write " + total + " entities to service, due to server exception: "+ response.getException()); } } catch (Exception ex) { LOG.error("Got exception while writing entities: ", ex); } } } |
Eagle Metric List
- eagle.event.count: #event went into alert executor
- eagle.policy.eval.count: #policy evaluated times, which equals #policy * #event
- eagle.policy.eval.fail.count #event failed during evaluation
- eagle.alert.count: #alert generated
- eagle.alert.fail.count: #alert not successfully generated
- eagle.kafka.message.consumer.lag: lag between total kafka offset & comsuer's offset
- eagle.kafka.message.count: kafka message count on a specific key, like user=hadoop