-
Notifications
You must be signed in to change notification settings - Fork 19
1.6 Forwarding endpoint statistics
Health Monitor provides an ability to forward endpoint statistics to other places than internal database. In case endpoint metrics are required for additional graphs, analytic, statistic or something else, Health Monitor can forward data via plugin based Forwarders system (similar to Monitor plugins).
In this example we will create a Forwarder plugin to forward endpoint metrics to external database. We need to create a class library and install HealthMonitoring.Forwarders package (Health Monitor has this package with a contract which should be installed in order to create a Forwarder plugin). Our Forwarder should has a class which implements interface IEndpointMetricsForwarder, there is only one method which accepts endpoint details (to identify endpoint), and metrics itself as a parameters. So every time Health Monitor will persist endpoint statistic it also will invoke every registered Forwarder instance to forward these statistics.
Sample forwarder's code could look like this:
public class ExternalDbForwarder : IEndpointMetricsForwarder
{
public void ForwardEndpointMetrics(EndpointDetails details, EndpointMetrics metrics)
{
// prepare data here
ExternalDbClient.Send(endpointDetails, endpointMetrics);
}
}When its ready it can be packaged and installed in forwarders directory (or just copy binaries) located in directory where HealthMonitoring.SelfHost.exe is.