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!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...