I have created a post curl to add data in Splunk, internally my api hits Splunk api and in that api I send data in body & that data would get created in my splunk table. I want to add dynamic value in search query of splunk api. How can i achieve that, please help here
method: "POST",
path: "/api/addSplunk",
handler: async (request, h) => {
const ccmData = getServerConfig(request);
const url = ccmData["splunkApiUrl"];
const ChannelName= request.payload.channel_name; // I want to use this value in search query
const Channel= request.payload.channel_type;
function xmlTranslate(resp) {
return resp.text()
}
const httpsAgent = new https.Agent({
rejectUnauthorized: false
});
const options = {
method: "POST",
headers: {
"Authorization": "dr356654fy6,
"Content-Type": "application/x-www-form-urlencoded"
},
agent: httpsAgent,
translate: xmlTranslate,
body: 'search=| makeresults | eval Channel ="372864u31564719" | eval ChannelName = "4P customer" | table Channel,ChannelName | outputlookup channel.csv append=true'
};
const res = await fetch(url, options, xmlTranslate);
Right now I have hardcoded like this eval Channel ="372864u31564719" | eval ChannelName = "4P customer", I want to add dynamic value for diff use case in channel and channelName of search query (i.e coming from request payload)
... View more