Quantcast
Channel: Questions in topic: "splunk-enterprise"
Viewing all articles
Browse latest Browse all 47296

c# logging to HTTP Event Collector not working

$
0
0
I am trying to send events from my Windows server .NET app to Splunk index via HTTP Event Collector. I was able to setup the collector and verified it from localhost and from another linux machine by using simple curl commands as documented, so the collector is listening and is adding data to the index as supposed to do. However when trying to send events from .NET c# app I face the impossible. I tried all sample code Splunk made available, from simple to complex with no good results. Now, since the curl is working I am trying to do the very basic curl emulation in c# via a webrequest object. I am stuck now with the authentication. I tried various authentication headers but it seems none wants to work. The ones with encryption generates 400 Bad Request. The simple one from the code sample below generates 401 Unauthorized. I need some help to solve this issue. `WebRequest request = WebRequest.Create("https://splunkserver:8088/services/collector/event");` `request.Method = "POST";` `request.Headers.Add("Authorization", "splunk 1EDC2170-023A-468A-9ADD-8A879755DC74");` `ASCIIEncoding encoding = new ASCIIEncoding();` `byte[] byte1 = encoding.GetBytes("this is a raw event line");` `request.ContentLength = byte1.Length;` `Stream newStream = request.GetRequestStream();` `newStream.Write(byte1, 0, byte1.Length);` `WebResponse response = request.GetResponse();` `Stream dataStream = response.GetResponseStream();` `StreamReader reader = new StreamReader(dataStream);` `string serverResponse = reader.ReadToEnd();`

Viewing all articles
Browse latest Browse all 47296

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>