如何将json数据发送到splunk HEC或splunk企业

问题描述 投票:0回答:1

我需要将Jenkins管道中的JSON数据发送到Splunk。我能够制作JSON数据。我指的是How do I send JSON files to Splunk Enterprise from JAVA?此链接。行号时出现错误。 5:已调用httppost.setEntity(new StringEntity(eventStr);)。请帮助...

 DefaultHttpClient httpclient = new DefaultHttpClient();
 HttpPost httppost = new HttpPost("https://<SERVER>:8088/services/collector/event");
 httppost.addHeader("Authorization", " Splunk <token id>");
 String eventStr = "{sourcetype=_json, index=main, event={ <JSON> }}"
 httppost.setEntity(new StringEntity(eventStr);
 HttpResponse response = httpclient.execute(httppost);
 HttpEntity entity = response.getEntity();
 System.out.println("response: " + entity);
java groovy splunk
1个回答
0
投票

我要下注您的错误消息说像“ unexpected token at <character count> on <line number>

[您在第5行上缺少分号(在分号之前),并且似乎在第2和4行上需要一些分号

© www.soinside.com 2019 - 2024. All rights reserved.