第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何從 JAVA 將 JSON 文件發(fā)送到 Splunk Enterprise?

如何從 JAVA 將 JSON 文件發(fā)送到 Splunk Enterprise?

長(zhǎng)風(fēng)秋雁 2023-12-30 16:14:42
我首先說我是初學(xué)者。我正在設(shè)置一個(gè)收集一些 JSON 文件的系統(tǒng),我在 JAVA (Spring 批處理)中解析它們,而我遇到的問題是將這些文件發(fā)送到Splunk enterprise 中的HTTP EVENT COLLECTOR (HEC)。我嘗試在網(wǎng)絡(luò)上爬行以獲取一些適合初學(xué)者的指南,但我找不到任何內(nèi)容。我想將帶有上述文件的 POST 發(fā)送到 Splunk 企業(yè),這樣我就可以在發(fā)送它們后對(duì)它們進(jìn)行索引。到目前為止,我只能像這樣連接到 localhost:8089:HttpService.setSslSecurityProtocol(SSLSecurityProtocol.TLSv1_2);        ServiceArgs connectionArgs = new ServiceArgs();        connectionArgs.setHost("localhost");        connectionArgs.setUsername("AdrianAlter");        connectionArgs.setPassword("mypassword");        connectionArgs.setPort(8089);        connectionArgs.put("scheme","https");        // will login and save the session key which gets put in the HTTP Authorization header        Service splunkService = Service.connect(connectionArgs);        System.out.println("Auth Token : " + splunkService.getToken());        Job info = splunkService.getJobs().create("search index=main");        System.out.println("Info: ");
查看完整描述

1 回答

?
慕尼黑的夜晚無繁華

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超6個(gè)贊

有點(diǎn)不清楚你想做什么。在文中,您說您正在嘗試使用 HTTP 事件收集器 (HEC) 發(fā)送數(shù)據(jù)。但是,示例代碼看起來正在嘗試執(zhí)行搜索。


要將數(shù)據(jù)發(fā)送到 Java 中的 HEC 端點(diǎn),以下代碼片段可能是合適的起點(diǎn)。


 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);


查看完整回答
反對(duì) 回復(fù) 2023-12-30
  • 1 回答
  • 0 關(guān)注
  • 171 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)