Dashboards & Visualizations

HttpEventCollectorException error C# library

gamification
Explorer

Hello everybody,

I want to use the Splunk C# library to log directly into my Splunk by Http.

But the HttpTraceEvent library just doesn't work. I have am getting an HttpEventCollectorException error.

Here is my code:

TraceSource traceSource = new TraceSource(this.sourcename);
traceSource.Switch.Level = SourceLevels.All;
traceSource.Listeners.Clear();

traceListener = new HttpEventCollectorTraceListener(uri: new Uri(target), token: token);            

traceListener.AddLoggingFailureHandler((HttpEventCollectorException e) => {
        Console.WriteLine("{0}",e);
});
traceSource.Listeners.Add(traceListener);
traceSource.TraceEvent(TraceEventType.Information, 1, "Test Message");

My variable target is "https://localhost:8088"

The example above is the same as the one in the documentation here: http://dev.splunk.com/view/splunk-loglib-dotnet/SP-CAAAEX9

So, I tried to use curl to check if it was not my token or my address that was wrong:

curl -k https://localhost:8088/services/collector/event/1.0 -H "Authorization: Splunk 35D1638E-75CB-4A6F-B314-21C959DAF466" -d "{\"event\": \"hello world\"}"

This one works as I can see my log in Splunk.

Could someone help me? Possibly a good alternative using http in C#? Thanks

0 Karma

gblock_splunk
Splunk Employee
Splunk Employee
  1. Can you show the exception message?
  2. Did you disable cert validation in your code? If not, then this is very likely the issue.
0 Karma
Get Updates on the Splunk Community!

Webinar Recap | Revolutionizing IT Operations: The Transformative Power of AI and ML ...

The Transformative Power of AI and ML in Enhancing Observability   In the realm of IT operations, the ...

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...