# Define logstash's jdbc-input-plugin json message root object

**URL:** <https://discuss.elastic.co/t/define-logstashs-jdbc-input-plugin-json-message-root-object/115157>\
**Category:** Logstash\
**Created:** [January 11, 2018, 7:04pm UTC](https://discuss.elastic.co/t/define-logstashs-jdbc-input-plugin-json-message-root-object/115157 "2018-01-11T19:04:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![endersonmaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/endersonmaia/32/17308_2.png) [@endersonmaia](https://discuss.elastic.co/u/endersonmaia)\
**Post date:** [January 11, 2018, 7:04pm UTC](https://discuss.elastic.co/t/define-logstashs-jdbc-input-plugin-json-message-root-object/115157/1 "2018-01-11T19:04:36Z")

</div>

I'm using `jdbc-input-plugin` to get some orders data and send it to a `rabbitmq` queue.

To make the json message compatible with the queue consuming system, I need to add a root named `order`.

I'm getting

```auto
{ "id" : 123, "price" : 12.50 }

```

and I need it to be

```auto
{ "order" : { "id" : 123, "price" : 12.50 } }

```

Is there any way I can inform the `jdbc-input` to use `order` as the default root for the message ?

---

<div class="post-metadata">

**Author:** ![endersonmaia](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/endersonmaia/32/17308_2.png) [@endersonmaia](https://discuss.elastic.co/u/endersonmaia)\
**Post date:** [January 12, 2018, 1:28pm UTC](https://discuss.elastic.co/t/define-logstashs-jdbc-input-plugin-json-message-root-object/115157/2 "2018-01-12T13:28:04Z")

</div>

I know I can achieve this with mutate filter like :

```auto
filter {
  mutate {
    add_field => {
      "[order][id]" => "%{[id]}"
      "[order][price]" => "%{[price]}"
    }

    remove_field => ["id", "price"]
  }
}

```

But I hope there's a better way 😉

---

<div class="post-metadata">

**Author:** ![guyboertje](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/guyboertje/32/31592_2.png) [@guyboertje](https://discuss.elastic.co/u/guyboertje)\
**Post date:** [January 16, 2018, 5:16pm UTC](https://discuss.elastic.co/t/define-logstashs-jdbc-input-plugin-json-message-root-object/115157/3 "2018-01-16T17:16:55Z")

</div>

No other way that I know of.

FYI. You can use `add_field` on the jdbc\_input - it will run that function after the event is created.  
If you have any other filter, just add the `remove_field` piece in it before the event hits the output section.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 13, 2018, 5:17pm UTC](https://discuss.elastic.co/t/define-logstashs-jdbc-input-plugin-json-message-root-object/115157/4 "2018-02-13T17:17:26Z")

</div>

Closed on February 13, 2018, 5:17pm UTC

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