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!

Earn a $35 Gift Card for Answering our Splunk Admins & App Developer Survey

Survey for Splunk Admins and App Developers is open now! | Earn a $35 gift card!      Hello there,  Splunk ...

Continuing Innovation & New Integrations Unlock Full Stack Observability For Your ...

You’ve probably heard the latest about AppDynamics joining the Splunk Observability portfolio, deepening our ...

Monitoring Amazon Elastic Kubernetes Service (EKS)

As we’ve seen, integrating Kubernetes environments with Splunk Observability Cloud is a quick and easy way to ...