Skip to content

Instantly share code, notes, and snippets.

@craigeddy
Created June 18, 2021 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigeddy/fc9301bc85d7137239409105ad4bad96 to your computer and use it in GitHub Desktop.
Save craigeddy/fc9301bc85d7137239409105ad4bad96 to your computer and use it in GitHub Desktop.
Attempt To Verify Splunk Http Event Collector Connectivity
// 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