JSON extraction

(Tibin George) #1

I have a JSON in this format {'messages':'17','values':'20'}, want to parse this json and get key and value seperately
what should be my extractor configuration if i want to extract this key,values.
I have tried all posibilities but it is not working.

(Jochen) #2

Please elaborate on what you want to achieve and provide some examples.

Other than that, please refer to http://docs.graylog.org/en/2.4/pages/extractors.html#using-the-json-extractor.

(Tibin George) #3

I get this complete json in message field. I was to extract and make these key and vaues in seperate fields.

(Jochen) #4

Please provide some examples.

FWIW, that’s not valid JSON because of the single quotes.

(Tibin George) #5

I push log using https://github.com/severb/graypy to push log to graylog server.

It will be this format in graylog, the json I send from graypy will be in message filed.
now I want to split that fields into key names of my json.
As per my that image my json is {'data':'2','values':'5'} so I want data as 1 field and values as another filed and those fileds have thieir values respectively, like this







(Jochen) #6

That’s no valid JSON but a text representation of a Python dictionary.

You could try to use the key_value() function to parse that after removing the surrounding brackets, but that will only work for flat dictionaries.

Ideally, you would set custom attributes in graypy when sending that kind of data.

(Tibin George) #7

Will there a option in extactor for key_value() parse ?

I couldnt find in my extractior list.

(Jochen) #8

The key_value() function can be used with Pipeline rules:

(system) #9

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.