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!

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...

Application management with Targeted Application Install for Victoria Experience

Experience a new era of flexibility in managing your Splunk Cloud Platform apps! With Targeted Application ...