作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要将 JSON 数据从 Jenkins 管道发送到 Splunk。我能够制作 JSON 数据。我指的是 How do I send JSON files to Splunk Enterprise from JAVA?这个链接。当第 1 行时,我收到错误。 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);
最佳答案
我敢打赌你的错误消息会显示类似“unexpected token at <character count> on <line number>
”的内容
第 5 行缺少一些右括号(分号之前),并且第 2 行和第 4 行似乎需要一些分号
关于java - 如何将json数据发送到splunk HEC或splunk enterprise,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61596340/
我是一名优秀的程序员,十分优秀!