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!

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 ...