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