# JSON fields pretty-printing

**URL:** <https://community.graylog.org/t/json-fields-pretty-printing/8727>\
**Category:** Graylog Central (peer support)\
**Created:** [February 6, 2019, 4:15pm UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727 "2019-02-06T16:15:18Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![maximvl](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@maximvl](https://community.graylog.org/u/maximvl)\
**Post date:** [February 6, 2019, 4:15pm UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/1 "2019-02-06T16:15:18Z")

</div>

Hello,

I would like to dump some unstructured JSON information into logs (requests / replies from REST services) and I intentionally don’t want to parse them. I did some tests with a Graylog 2.5 docker image and it everything is great, except in the interface, those fields appear as plain text strings.

Does Graylog have some pretty printing to make it possible to navigate in this kind of data? I couldn’t find anything like this in the interface. To me it just looks like an obvious thing to have, or is there anything else I’m not aware of?

Thanks!

---

<div class="post-metadata">

**Author:** ![jan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jan/32/11_2.png) [@jan](https://community.graylog.org/u/jan)\
**Post date:** [February 7, 2019, 6:38am UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/2 "2019-02-07T06:38:52Z")

</div>

how did you ingest the data into Graylog? Did you parse the json or did you look at it as a string?

---

<div class="post-metadata">

**Author:** ![maximvl](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@maximvl](https://community.graylog.org/u/maximvl)\
**Post date:** [February 7, 2019, 8:12am UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/3 "2019-02-07T08:12:29Z")

</div>

Hey Jan, in Graylog I tried both just a string and JSON extractor. I think the second one only extracts top level fields.

---

<div class="post-metadata">

**Author:** ![jan](https://sea2.discourse-cdn.com/flex016/user_avatar/community.graylog.org/jan/32/11_2.png) [@jan](https://community.graylog.org/u/jan)\
**Post date:** [February 7, 2019, 8:52am UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/4 "2019-02-07T08:52:53Z")

</div>

the processing pipelines with `parse_json` together with the `set_fields` function is what you want to try …

---

<div class="post-metadata">

**Author:** ![maximvl](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@maximvl](https://community.graylog.org/u/maximvl)\
**Post date:** [February 7, 2019, 9:09am UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/5 "2019-02-07T09:09:48Z")

</div>

Ok, I’m looking into it. What I see currently - `parse_json` returns a JSON Tree, which I can not put directly into the `set_fields`, correct? If this is correct - have to do `select_jsonpath` which implies knowing the structure of JSON, which I want to avoid.

Another option would be to iterate over JSON tree, but I don’t see any iteration tools in pipeline functions, are there any?

---

<div class="post-metadata">

**Author:** ![maximvl](https://avatars.discourse-cdn.com/v4/letter/m/bbe5ce/32.png) [@maximvl](https://community.graylog.org/u/maximvl)\
**Post date:** [February 7, 2019, 9:29am UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/6 "2019-02-07T09:29:11Z")

</div>

Ok, I found these discussions, seems like I should try Graylog 3.0

> [@Parsing JSON in a pipeline](https://community.graylog.org/t/parsing-json-in-a-pipeline/6739):
>
> I’m trying to parse some JSON. The fields are not known. The solution mentioned [Parse unknown JSON with pipelines](https://community.graylog.org/t/parse-unknown-json-with-pipelines/3293) appears to not be possible. Is there a way to currently handle in 2.4.6? [https://github.com/Graylog2/graylog-plugin-pipeline-processor/pull/228](https://github.com/Graylog2/graylog-plugin-pipeline-processor/pull/228)

> <https://github.com/Graylog2/graylog-plugin-pipeline-processor/pull/228>
>
> Sometimes users might want to parse and merge the JSON payload of a message
> wit…h the Graylog message without knowing the complete structure of the payload
> or without having a fixed structure which could be selectively merged by using
> the \`json\_path()\` method.
> 
> This commit essentially adds the possiblity to create a pipeline rule emulating
> the existing JSON extractor:
> 
> rule "json"
> when
> // some condition
> then
> let json = parse\_json(to\_string($message.some\_field));
> set\_fields(json);
> end
> 
> Refs: https://community.graylog.org/t/parse-unknown-json-with-pipelines/3293/7

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/graylog/original/3X/c/7/c7c09c6b5099570133d6502b83f50ba4430de5b6.png) [@system](https://community.graylog.org/u/system)\
**Post date:** [February 21, 2019, 9:29am UTC](https://community.graylog.org/t/json-fields-pretty-printing/8727/7 "2019-02-21T09:29:11Z")

</div>

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