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!

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...