gpt4 book ai didi

java - 如何将json数据发送到splunk HEC或splunk enterprise

转载 作者:行者123 更新时间:2023-12-01 16:55:39 26 4
gpt4 key购买 nike

我需要将 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com