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!

Troubleshooting the OpenTelemetry Collector

  In this tech talk, you’ll learn how to troubleshoot the OpenTelemetry collector - from checking the ...

Adoption of Infrastructure Monitoring at Splunk

  Splunk's Growth Engineering team showcases one of their first Splunk product adoption-Splunk Infrastructure ...

Modern way of developing distributed application using OTel

Recently, I had the opportunity to work on a complex microservice using Spring boot and Quarkus to develop a ...