# InfluxDB insert data

**URL:** <https://discourse.nodered.org/t/influxdb-insert-data/15564>\
**Category:** General\
**Created:** [15 September 2019 18:24 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564 "2019-09-15T18:24:57Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![rchen](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rchen](https://discourse.nodered.org/u/rchen)\
**Post date:** [15 September 2019 18:24 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/1 "2019-09-15T18:24:57Z")

</div>

Hi all,

I'm working with node red about 5 days ago, so I'm newbie.

Why this flow didn't insert any record in influxdb? What do I need to do to insert records to influxdb?

```auto
[{"id":"857e5728.5e74a8","type":"function","z":"c0a89205.8fc5e","name":"","func":"msg.payload = {\n numValue: 123.0,\n strValue: \"message\",\n}\nreturn msg;","outputs":1,"noerr":0,"x":350,"y":740,"wires":[["46eec075.1724d"]]},{"id":"46eec075.1724d","type":"influxdb out","z":"c0a89205.8fc5e","influxdb":"38e13ac5.ff85f6","name":"cm005","measurement":"cm005","precision":"","retentionPolicy":"rp_casa_oneyear","x":770,"y":740,"wires":[]},{"id":"89c16b41.8dd0e8","type":"inject","z":"c0a89205.8fc5e","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":740,"wires":[["857e5728.5e74a8"]]},{"id":"38e13ac5.ff85f6","type":"influxdb","z":"","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"casa","name":"Influxdb","usetls":false,"tls":""}]

```

The measurement was created, but is it empty.

Thank you very much,  
Rui

PS: I exported and paste here again, in case something is incorrect, in my node red instalation I could import without errors...

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [15 September 2019 18:35 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/2 "2019-09-15T18:35:24Z")

</div>

There are some influxbd flows that you can import available at [flows.nodered.org](http://flows.nodered.org) that might show you where you are going wrong.  
(i’m not infront of a laptop at the mo)

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [15 September 2019 19:17 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/3 "2019-09-15T19:17:38Z")

</div>

@rchen - Rui, Your flow is not importable due to errors in it, so can't really load it up to test.

If you look at the contents of the function node, is there a syntax error displayed - probably ⚠ icons in the margin?  
If so, hover over them and read what the error is.

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [15 September 2019 19:36 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/4 "2019-09-15T19:36:18Z")

</div>

> [@rchen](#):
>
> The measurement was created, but is it empty.

How do you know?  
Did you checked it on the Influx command line?  
Or is just your chart empty....

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [15 September 2019 20:30 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/5 "2019-09-15T20:30:27Z")

</div>

It's strange that it cannot be imported. The flow seems to be erroring around this section of your flow - `strValue: "message",`.

I'm assuming it's because the string quotes are not escaped like this;  
`strValue: \"message\",`

??

![error](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/de3340caf6dbcaa496e3d342fafcd08d9ad4b17f.jpeg)

---

<div class="post-metadata">

**Author:** ![rchen](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rchen](https://discourse.nodered.org/u/rchen)\
**Post date:** [15 September 2019 20:35 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/6 "2019-09-15T20:35:09Z")

</div>

YEs, I check on the command line.

> use casa;  
> select \* from cm005;

Empty result, no error on debug...

---

<div class="post-metadata">

**Author:** ![rchen](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rchen](https://discourse.nodered.org/u/rchen)\
**Post date:** [15 September 2019 20:39 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/7 "2019-09-15T20:39:33Z")

</div>

Thank you for that info, but I already search, but I can't understand how can I create a new object which can be used in influxdb output. What is the structure needed to it?

Rui

---

<div class="post-metadata">

**Author:** ![rchen](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rchen](https://discourse.nodered.org/u/rchen)\
**Post date:** [15 September 2019 20:46 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/8 "2019-09-15T20:46:33Z")

</div>

My function appear like this :

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

In logs I got an error 204 (empty content)

```auto
Sep 15 21:40:51 raspberrypi influxd[10711]: [httpd] 127.0.0.1 - master [15/Sep/2019:21:40:51 +0100] "POST /write?db=casa&p=%5BREDACTED%5D&precision=n&rp=rp_casa_oneyear&u=master HTTP/1.1" 204 0 "-" "-" 1b533658-d7f9-11e9-85da-dca63211e774 17585

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [15 September 2019 21:10 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/9 "2019-09-15T21:10:49Z")

</div>

Try adding a catch node connected to a debug (display complete msg object) to see if anthing shows up.

---

<div class="post-metadata">

**Author:** ![edje11](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/edje11/32/572_2.png) [@edje11](https://discourse.nodered.org/u/edje11)\
**Post date:** [15 September 2019 21:17 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/10 "2019-09-15T21:17:14Z")

</div>

Remove the comma after "message".  
Last value shouldn't have a comma.

```auto
msg.payload = {
    numValue: 123.0,
    strValue: "message"
}
return msg;

```

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [15 September 2019 21:39 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/11 "2019-09-15T21:39:11Z")

</div>

@rchen you keep editing your original flow.  
The first version could not be imported, why is that?

---

<div class="post-metadata">

**Author:** ![rchen](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rchen](https://discourse.nodered.org/u/rchen)\
**Post date:** [15 September 2019 21:57 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/12 "2019-09-15T21:57:40Z")

</div>

I don't know why...

---

<div class="post-metadata">

**Author:** ![rchen](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rchen](https://discourse.nodered.org/u/rchen)\
**Post date:** [15 September 2019 22:15 UTC](https://discourse.nodered.org/t/influxdb-insert-data/15564/13 "2019-09-15T22:15:12Z")

</div>

New info...

I used an example from original influxdb node and compared it. The difference was in advanced query options. After some tests, If I disabled advanced query options, it is inserted without problems, if I select advanced query options, choose any value in time precision and specified an existing policy, I didn't got any error, but I didn't got any value in measurement.

Executed with success :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1554ae2ac4083b517d877a97bea5d8bcadda1b32.png)

Executed without success (but without any error) :  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/a/afd4468e58db3f3b689d1024496e080faae96ad8.png)

Any one can explain why?
