Creating a CLI buffer for http writing InfluxDB

Hi,

I want to write to my data to InfluxDB through http (has to be in CLI code example: measurement, Tagkey=Tagvalue FieldKey=FieldValue Timestamp). The connection works and i can send the data to InfluxDB.

But i'm using the Siemens PLC 'plcindustry' S7 nodes. And i want to read all my variables at once and make in a function node from this data the CLI code. In the picture below you can see that it works but the msg.payload is transmitted as a string.

Now my questions:

  1. Can i unstringify my msg.payload? Is the easiest way!
    2.Can i write from in a function node every line to a txt.file like i can do with the file nodes? (but i can't leave the function node to call the file node, or can i?)
    3.A better way to approach this problem?

I know there are the InfluxDB Nodes but later i want to use Telegraf and i want to use the telegraf http listener input plugin.

Thanks at advance!
Kind Regards,
Ward

What do you mean by CLI code?

Is that debug coming out of your function node or what you are feeding into it?

Edit - if that is what is coming out then what do you want to see there and what is going in?
To answer point 2, yes, if you send the lines one at a time you can send that to a file out node, or you could build up the complete text and send that in one message to the file node.

With CLI i mean influx line protocol. Thought they called it that. (I could be wrong :grimacing:)

The debug come out of the function node. What i want is what you see in the debug, but like you can see the /n (for new line)is written and not executed. And i think that's the problem the http can't send it to influx. I can give you the error log from the http node (forgot to send that one) tomorrow.

Sorry, don't understand what you mean by that.

Are you using the http POST method for writing to the db?
Yes, show us the error. Is the debug o output you showed going straight into the http node? How have you configured it?

@Colin i finally get it working, but thanks for the reply.

The correct code is:

for (i=0; i !== entrieslength; i++) {
    msg.payload = msg.payload+'Vaten_1_'+msg.entries[i][0]+','+TagKey_1+'='+TagValue_1+' value='+msg.entries[i][1]+' '+StartUnix +'\n';
}

I've made a couple of mistakes!

  1. The syntax for a new line is \n and not /n
  2. And the syntax \n has to put between ' '
  3. My TagValue_1 contained a space (Geen Selectie), so the Influx Line Protocol can't handle that. You have to put a \ before every space.

For the people interested https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/#string

Kind regards,
Ward

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