Security

Http Event Collector C# not working

johnchen0213
New Member

There is the sameple snippet found online:

var middleware = new HttpEventCollectorResendMiddleware(100);
var ecSender = new HttpEventCollectorSender(new Uri("https://localhost:8088"),
"3E712E99-63C5-4C5A-841D-592DD070DA51",
null,
HttpEventCollectorSender.SendMode.Sequential,
0,
0,
0,
middleware.Plugin
);
ecSender.OnError += o => Console.WriteLine(o.Message);
ecSender.Send(Guid.NewGuid().ToString(), "INFO", null, new { Foo = "Bar" });
dynamic obj = new JObject();
obj.Bar = "Baz";
ecSender.Send(Guid.NewGuid().ToString(), "INFO", null, (JObject)obj);
await ecSender.FlushAsync();

I have to playing around with different port and uri but I have no luck populating stuff to splunk. I have change the token as well. Those are the only two things I've change. I've also tried to change .NET framework version from 4.6.1 to 4.5.2 but still no luck. Can someone know what are the most common problem in this scenario?

0 Karma

GrahamX
New Member

Hi,
try adding this as the first line of your code:

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

0 Karma

Rohit24c
New Member

Hi All , I am new to Splunk n facing a similar issue,
Added all dlls from nuget n setup an account with Token, 

But I don't see any logs in dash board on search

Need a Help on this
below is the code - 

ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

var middleware = new HttpEventCollectorResendMiddleware(100);
var ecSender = new HttpEventCollectorSender(new Uri("http://localhost:8088/"),
"bacdb24e-ee37-40cc-8d81-9b2f6d95784f", null, HttpEventCollectorSender.SendMode.Sequential, 0, 0, 0, middleware.Plugin);

ecSender.OnError += o => Console.WriteLine(o.Message);

ecSender.Send(DateTime.UtcNow.AddDays(-1), Guid.NewGuid().ToString(), "INFO", null,
new { Foo = "Bar", test2 = "Testit2", time = ConvertToEpoch(DateTime.UtcNow.AddHours(-2)).ToString(), anotherkey="RohitKeyvalue1" });

ecSender.Send(Guid.NewGuid().ToString(), "INFO", null,
new { Foo = "Bar", test2 = "Testit2", time = ConvertToEpoch(DateTime.UtcNow.AddHours(-2)).ToString(), anotherkey = "RohitKeyvalue2" });

await ecSender.FlushAsync();

0 Karma
Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes & Cloud Monitoring with Splunk IM

Ready to master Kubernetes and cloud monitoring like the pros? Join Splunk’s Growth Engineering team on ...

Index This | What did the zero say to the eight?

June 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

Splunk Observability Cloud's AI Assistant in Action Series: Onboarding New Hires & ...

This is the fifth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...