stackhero-io / node-red-contrib-stackhero-influxdb-v2

Node-RED node to read and write to an InfluxDB v2 database.
31 stars 7 forks source link

Are String Data Types for Field Values supported ? #3

Closed zoestrong closed 4 years ago

zoestrong commented 4 years ago

Heya thanks for the node, been starting to move some of my data flows in node red to influxdb 2.0 on the cloud for testing, I am not sure if Strings are supported or not currently as a field value data type for this node?

I seem to be getting errors on strings but not numbers when trying to do a write operation

if I set the field set in the payload to something like this: {"message":"WDTMODEMINIT"} I get a 400 error message on the write node, the quotation mark's seem to be being stripped out (see below error msg from the node)

Error: 400 on https://us-west-2-1.aws.cloud2.influxdata.com:443/api/v2/write?org=xxxxxxx&bucket=xxxxxx&precision=s: {"code":"invalid","message":"unable to parse 'errors,customer=xxx,location=weatherstation,errorType=WDT message=WDTMODEMINIT 2009020403': invalid boolean"}

I have tried the exact same payload construct with a numeric value (as per below) and all is good, no errors {"message":100}

Thanks !

zoestrong commented 4 years ago

Solved this simple problem myself.. .. obviously l just had to escape the string in the function where i set the object details

i.e. say you have a field called status and you want it to have a string value of "ok" this is what the object woudl look like in the Node that you set the data for the Write operation

// Data to send to InfluxDB
  // Can be an array of objects or only one object
  data: [
    {
      measurement: 'xxxxxxx',

      tags: {
        customer: msg.customer,
        location: msg.location,

      },

      fields: {
        status: "\"ok\""
      },

      timestamp: msg.statustime
    },

    // More data can be send here, simply re add an object
    // { ... },
  ]
Bacto commented 4 years ago

Hi @zoestrong, Thanks for these informations. The problem has been resolved with the release 1.0.3

Note that you should not escape anymore the string with this update or you will insert the quotes in your database ;)