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!

Index This | Forward, I’m heavy; backward, I’m not. What am I?

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

A Guide To Cloud Migration Success

As enterprises’ rapid expansion to the cloud continues, IT leaders are continuously looking for ways to focus ...

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...