# Extract data from an MQTT payload

**URL:** https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948
**Category:** General
**Created:** [13 March 2019 23:07 UTC](https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948 "2019-03-13T23:07:18Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [21 April 2020 07:48 UTC](https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948/21 "2020-04-21T07:48:56Z")

</div>

I guess you want the fields in payload\_fieds to be in the fields in the database, so the questions that need answering are

1. What (if any) are the tags to go to the db?
2. Is it a fixed measurement or is the measurement in the message somewhere?

---

<div class="post-metadata">

### Author: ![Roberto69](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@Roberto69](https://discourse.nodered.org/u/Roberto69)
#### Post date: [21 April 2020 10:28 UTC](https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948/22 "2020-04-21T10:28:40Z")

</div>

Thank you for your patience. Whole picture is not yet clear to me so sometimes i asking stupid questions.

In db should be:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/2/1210fe0e0cd491afa41e268a23faa56c7beabb60.png)

So I have to extract this data from the payload:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/2/92395e1e0a4c7cf78fd6d7a96cdee01809b68b11.png)

I can inject this data to db. I guess nest or final step is to extract this data from the payload.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [21 April 2020 12:34 UTC](https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948/23 "2020-04-21T12:34:09Z")

</div>

Did you read and understand the guide [https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages) posted earlier in the thread? That should help you to see how to extract the data. The fields you want are currently (think) in msg.payload.payload\_fields and appear to already be in the correct format for influx except that they should be in msg.payload. So to move them into the payload you can use a Change node configured to Move msg.payload.payload\_fields into msg.payload. Before you feed that to the influx node feed it into a debug node and make sure it looks right.

---

<div class="post-metadata">

### Author: ![Roberto69](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@Roberto69](https://discourse.nodered.org/u/Roberto69)
#### Post date: [22 April 2020 14:18 UTC](https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948/24 "2020-04-22T14:18:11Z")

</div>

I've read but i didn't understand well enough, so i've read again. Thank you for your question.

Actually, it is simpler than looks like. I have used "change" node together with adding new property and it is really useful.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/2/026b5825f53a77ce2b2daf6bca8e1518a755bd91.png)

And I have to correct myself: TTN decoder in TTN console is still in use.

Thank You  
Robert

[Previous page](https://discourse.nodered.org/t/extract-data-from-an-mqtt-payload/8948.md?page=1)
