Try to use this pipeline rule, it should extract also inner json:
rule "extract-json"
when
starts_with(to_string($message.message), "{") && ends_with(to_string($message.message), "}")
then
let json = parse_json(to_string($message.message));
let map = to_map(json);
set_fields(map);
end
I had tired to use the above example but did not get the correct output.
Can I get the parameter Message, MT and UID as set fields with the above rule you have shared.
Json example:
{“Message”:“124”, “data”:{“MT”:“msgtype”, “UID”:“123abc”}}
I have attached the image for the pipeline and data.
I am getting the same data and fields are not set :
Kindly let me know if I have entered anything incorrectly.
You used non standard quotes “ not ", so pipeline rule doesn’t match at all. Change to normal double quotes, don’t copy and paste from this websites, as it’s changing it to non standard.
I am using the same graylog version.
Using this pipeline I get message and data fields but unable to get the fields data_UID and data_MT as seen in your image.
Can you share your pipeline details and if any modifications done by you in json parsing.
Sorry for error, but i found that actual json inner extraction was done using json extractor, and not pipeline rule at all. I used this extractor on Input for json:
Maybe this could work for you, if you want parse only data {} content:
rule "extract-json2"
when
starts_with(to_string($message.message), "{") && ends_with(to_string($message.message), "}")
then
let ex = regex(pattern: "\"data\":(\\{.*?\\})", value: to_string($message.message));
let json = parse_json(to_string(ex["0"]));
set_fields(to_map(json));
end
I have applied select_jsonpath to set field from json.
I need to use lookup table to get some values like parameter mt value 123 i need to replace from lookup to user1 and IP value to host name.
I want to use select_jsonpath to pipeline json fields.kindly help with the solution to implement lookup along with select_jsonpath.
Can you please help. If you need any other information let me know