1
我使用javascript SDK查詢Splunk。在searchParams中,我給出了輸出模式爲「json_rows」。未從Splunk獲取JSON格式的數據Javascript sdk
var searchParams = {
exec_mode: "normal",
output_mode: "json_rows"
};
但仍然當我得到輸出,我不明白它在一個JSON格式。輸出以數組的形式出現。
任何想法是什麼問題?我試過「json_cols」,只有「json」。同樣的結果。
在此先感謝。
編輯:2
一些更多的代碼
var service = new splunkjs.Service({
username:"xxx",
password:"xxxx",
scheme:"https",
host:"xxxxxx.com",
port:"5500",
version:"5.0"
});
var searchQuery = 'search index=sn impact=1 OR impact=2 | eval time = round(strptime(impact_start,"%Y-%m-%d %H:%M:%S"), 0)| where time >= ' + 14334627 + ' AND time<=' + 14568862 + '| bucket time span=1d | stats values(number) as incident_name by time';
var searchParams = {
exec_mode: "normal",
output_mode: "JSON"
};
service.oneshotSearch(
searchQuery,
searchParams,
function(err, results) {
if (results) {
var incidentResp = {};
incidentResp["data"] = results.rows;
incidentResp["error"] = null;
callback(null, incidentResp);
return;
}
else {
var errResp = {};
errResp["data"] = null;
errResp["error"] =err;
callback(null, errResp);
return;
}
}
);
你能展示更多的代碼嗎? – Shakeel