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!

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...

New in Observability Cloud - Explicit Bucket Histograms

Splunk introduces native support for histograms as a metric data type within Observability Cloud with Explicit ...