Created
June 18, 2021 16:18
-
-
Save craigeddy/fc9301bc85d7137239409105ad4bad96 to your computer and use it in GitHub Desktop.
Attempt To Verify Splunk Http Event Collector Connectivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this always succeeds :{ | |
try | |
{ | |
var ec = GetHttpEventCollector(); | |
var errorHappened = false; | |
ec.OnError += ex => | |
{ | |
errorHappened = true; | |
health.AddChildItem( | |
new BasicHealthInfo("Splunk Server Connectivity") | |
{ | |
IsOperational = false, | |
OperationalStatus = $"Exception calling LogEvent: {ex.Message}" | |
}); | |
}; | |
ec.Send(DateTime.Now, severity: "HealthCheck", | |
message: $"Health check from {nameof(SplunkEventLogger)}.{nameof(FetchHealthInfo)}", | |
data: new | |
{ | |
machineName = Environment.MachineName, | |
}); | |
if (!errorHappened) | |
{ | |
health.AddChildItem(new BasicHealthInfo("Splunk Server Connectivity")); | |
} | |
} | |
catch (Exception ex) | |
{ | |
health.AddChildItem( | |
new BasicHealthInfo("Splunk Server") | |
{ | |
IsOperational = false, | |
OperationalStatus = $"Exception calling LogEvent: {ex.Message}" | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment