Hello everyone! Currently I am integrating Splunk into our project, working with a local installation of Splunk Enterprise to test the waters and find my way around with Splunk itself. I am using the HttpEventCollectorSender class from the Splunk Package. My issue is the following: No matter in which format I send a message with the HEC Sender, I will always get the following exception:
Web Exception:
Server Reply: {"text":"Error in handling indexed fields","code":15,"invalid-event-number":0}
Response: StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
Date: Mon, 02 May 2022 10:39:30 GMT
X-Content-Type-Options: nosniff
Vary: Authorization
Connection: close
X-Frame-Options: SAMEORIGIN
Server: Splunkd
Content-Type: application/json; charset=utf-8
Content-Length: 78
}
HResult: -2146233088
The code that I use for sending is almost line by line from the HEC Tutorial from Splunk (Added some more Send-commands at the bottom to try out different formats)
var middleware = new HttpEventCollectorResendMiddleware(0);
var ecSender = new HttpEventCollectorSender(
new Uri("https://splunkserverdefaultcert:8088/"),
<token>,
null,
HttpEventCollectorSender.SendMode.Sequential,
0,
0,
0,
middleware.Plugin
);
ecSender.Send(Guid.NewGuid().ToString(), "INFO", null, <message>);
ecSender.Send(Guid.NewGuid().ToString(), "INFO", <message>);
ecSender.Send(data: <message>);
ecSender.Send(message: <message>);
ecSender.Send(Guid.NewGuid().ToString(), "INFO", null, data: new { testProperty = "testing" });
ecSender.Send(data: new { testProperty = "testing" });
ecSender.FlushAsync().Start();
No matter how I format the message that I send, I will get the error that I mentioned above. Since the error seems to indicate a formatting issue, I already tried different formats of sending the message. Looking into the errors that are getting logged I can see how the actual message that is getting sent looks, so I can confirm that the following formats do not work:
{"time":"1651492587,089","event":{"data":"This is an event"}}
{"time":"1651492587,089","event":{"message":"This is an event"}}
{"time":"1651494076,162","event":{"id":"00588efd-f403-4cf7-95ce-4ef2a28b0f93","severity":"INFO","data":"This is an event"}}
{"time":"1651494076,162","event":{"id":"00588efd-f403-4cf7-95ce-4ef2a28b0f93","severity":"INFO","message":"This is an event"}}
However, if I just do it with curl as follows, everything seems to work perfectly fine!
https://splunkserverdefaultcert:8088/services/collector/event/1.0 -k -H "Authorization: Splunk <token>" -d "{\"time\":\"1651492587\",\"event\":{\"data\":\"This_is_an_event\"}}"
Do you know what could be causing this error, and what I am doing wrong? Edit: I can now say that this happens also with other Splunk servers, not only with my local one. Curl works, but the HEC Service Implementation always throws the error mentioned above. If you have any ideas, I would be really thankful for some input! 🙂
... View more