From cdf71671cc161171e7847d945a8cf327ad84448e Mon Sep 17 00:00:00 2001 From: "Jeff Parker, PE" Date: Wed, 5 Jun 2024 14:48:13 -0500 Subject: [PATCH] Fix for #205 allow collector path in host url (#211) * Fix for #205 allow collector path in host url * Remove redundant check --- src/Serilog.Sinks.Splunk/ConfigurationDefaults.cs | 1 + .../Sinks/Splunk/EventCollectorRequest.cs | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Serilog.Sinks.Splunk/ConfigurationDefaults.cs b/src/Serilog.Sinks.Splunk/ConfigurationDefaults.cs index 7a4c402..4a3b019 100644 --- a/src/Serilog.Sinks.Splunk/ConfigurationDefaults.cs +++ b/src/Serilog.Sinks.Splunk/ConfigurationDefaults.cs @@ -14,5 +14,6 @@ internal static class ConfigurationDefaults /// https://docs.splunk.com/Documentation/Splunk/9.1.0/Data/UsetheHTTPEventCollector#Send_data_to_HTTP_Event_Collector_on_Splunk_Enterprise /// internal const string DefaultEventCollectorPath = "services/collector/event"; + internal const string DefaultCollectorPath = "services/collector"; } } diff --git a/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorRequest.cs b/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorRequest.cs index 82a0772..61a10bd 100644 --- a/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorRequest.cs +++ b/src/Serilog.Sinks.Splunk/Sinks/Splunk/EventCollectorRequest.cs @@ -1,4 +1,4 @@ -// Copyright 2016 Serilog Contributors +// Copyright 2016 Serilog Contributors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ internal class EventCollectorRequest : HttpRequestMessage { internal EventCollectorRequest(string splunkHost, string jsonPayLoad, string uri = ConfigurationDefaults.DefaultEventCollectorPath) { - var hostUrl = splunkHost.Contains(ConfigurationDefaults.DefaultEventCollectorPath) + var hostUrl = splunkHost.Contains(ConfigurationDefaults.DefaultCollectorPath) ? splunkHost : $"{splunkHost.TrimEnd('/')}/{uri.TrimStart('/').TrimEnd('/')}"; @@ -32,4 +32,4 @@ internal EventCollectorRequest(string splunkHost, string jsonPayLoad, string uri Method = HttpMethod.Post; } } -} \ No newline at end of file +}