I have the below pipeline processor rule that allows me to extract connectionId, ns and type from the mongodb log(json format), but unfortunately the extracted output is displaying as array instead of string.
rule “Extracting ConnectionId”
when
has_field(“message”)
then
let json_msg = parse_json(to_string($message.message));
let json_field = select_jsonpath(json_msg,{ctx: “.ctx”, ns: “.attr.ns”, type: “.attr.type”});
set_field(“ctx”,to_string(json_field.ctx));
set_field(“ns”, to_string(json_field.ns));
set_field(“type”, to_string(json_field.type));
end
@Wine_Merchant After updating the rule with below syntax, i can able to fetch the json output in string format(we missed $ while fetching ctx)
rule “Bureau Search”
when
has_field(“message”)
then
let json_msg = parse_json(to_string($message.message));
let json_field = select_jsonpath(json_msg,{ctx: “$.ctx”, ns: “$.attr.ns”, type: “$.attr.type”});
set_field(“ctx”,to_string(json_field.ctx));
set_field(“ns”, to_string(json_field.ns));
set_field(“type”, to_string(json_field.type));
end