mblackstock / node-red-contrib-influxdb

Node-RED nodes to save and query data from an influxdb time series database
Other
64 stars 44 forks source link

Specifying retention policy in function node #130

Open pkkrusty opened 1 year ago

pkkrusty commented 1 year ago

I've been browsing for a clear example of a function node that specifies tag, values, retention policy, precision that I can work from, but having no luck. I've tried the following, but not seeing anything show up the database.

temp=msg.payload[0];
msg.payload={
    fields: {
        value:temp.count
    },
    tags: {
        device:"Raspberry Pi"
    }
};
msg.retentionPolicy={
    value:"four_weeks"
    };
msg.measurement={
    value:"dbwrites"
    };
return msg;

and

temp=msg.payload[0];
msg.payload={
//    measurement:"dbwrites",
    fields: {
        value:temp.count
    },
    tags: {
        device:"Raspberry Pi"
    }
};
msg.retentionPolicy="four_weeks";
msg.measurement="dbwrites";
return msg;

and

temp=msg.payload[0];
msg.payload=[
    {
        value:temp.count
    },
    {
        device:"Raspberry Pi"
    }
];
msg.retentionPolicy="four_weeks";
msg.measurement="dbwrites";
return msg;

Should specify that entering the retention policy and measurement in the influxdb write node works just fine, but I was hoping to have a more generic influxdb write node that I could link multiple functions to, where RP and Measurement were passed in via functions.

pkkrusty commented 7 months ago

Any ideas?