Security

Send JSON objects to HTTP Event Collector using .NET

johnchen0213
New Member

I am having a hard time trying to send data to splunk. Here is the snippet of the code found online (official as well) for Http Event Collector:

var middleware = new HttpEventCollectorResendMiddleware(100);
var ecSender = new HttpEventCollectorSender(new Uri(“https://localhost:8088”), //I believe the port should be on the "token" page.
    “3E712E99-63C5-4C5A-841D-592DD070DA51”, //token from splunk "token"page.
    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();

Nothing would show up in Splunk searches. I've tried to switch .NET Framework version from 4.6.1 to 4.5.2 (I am on visual studio 2017) but no luck.
I am wondering what are the most common problem dealing with this problem. I was guessing maybe the "Uri" or "token" was incorrect, but i've tried all possible port on the Uri. Maybe someone can clarify what I'm missing here. Is there a different sending this to cloud or enterprise?

0 Karma

p_gurav
Champion

Did you download splunk extension for visual studio? Also check with prerequisite:
http://dev.splunk.com/view/splunk-loglib-dotnet/SP-CAAAEYB

Also take a look at troubleshoot steps:
http://dev.splunk.com/view/splunk-loglib-dotnet/SP-CAAAE6S

0 Karma

deepashri_123
Motivator

Hey@johnchen0213,

Refer this link:
http://docs.splunk.com/Documentation/Splunk/7.0.3/Data/UsetheHTTPEventCollector
Let me know if this helps!!

0 Karma
Get Updates on the Splunk Community!

Get the T-shirt to Prove You Survived Splunk University Bootcamp

As if Splunk University, in Las Vegas, in-person, with three days of bootcamps and labs weren’t enough, now ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...