We recently had cause to create a simple service to monitor another service, then send the status of the monitored service to application insights. In this article, I will highlight the steps required to get this installed and running on one a machine.
Download
You can download the code for the service monitor from GitHub here: https://github.com/deanobrien/service-listener-for-solr
In order to get it working:
- Clone the repo and rebuild
- Copy output from bin directoy
- Paste to location on target machine
- Install DotNet runtime on the target machine
- Open command prompt and navigate to “C:\Windows\Microsoft.NET\Framework\v4.0.30319“
- Install service by entering command:
installutil "<enter path to output>/ServiceListener.exe"
- Add the following environment variables
- ServiceMonitorInstrumentationKey - instrumentation key for the app insights resource
- ServiceMonitorServiceName - needs to exactly match the service name being monitored
- ServiceMonitorInstanceName - display name (i.e. SOLR on UAT1)
- ServiceMonitorIntervalInSecs - delay between logging
- Start the service ServiceListener
Once the above is setup and running, you can then setup alerting to check for the presence of these custom events (i.e. SOLR on UAT2: Running).