Run InfluxDB query and display in debug

Hi. I need help from you guys who can help me. I'm not good in node red but I'm trying to.

I want to run a InfluxDB query syntax from node-red and display the result in debug. I noted that @Colin had been replied to similar process with mine at Read data from InfluxDB and from that @Colin suggested to see this post How to share code or flow json.

The concept is I'm trying to view my single result in debug node red function like shown in the flow below:

My query is about to read the last entry value from my measurements InfluxDB like:

I don't know how to setup my InjectNode, Influxdb In Node and my DebugNode in a proper way. Is it possible I can get a single output result from debug console? Is there any complete tutorial how to do that?

While not an "influxdb for node-red" tutorial, based on your questions, you really should spend a little time learning since many of the principles apply to all nodes.

So I recommend watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

yup... i know about this but how to i want to read data from influxdb using node red debug node? the essential video didn't explain about the influxdb in at all..

No, it doesnt, but you asked...

these are very much covered.

Did you read the built in help...

and the tip on the setup form?...

So set your inject to send the query in msg.query....

then the output (as the built in docs say) will come in msg.payload

So add a debug - it defaults to outputting msg.payload

1 Like

Sorry @Steve-Mcl for my rudeness in my last reply.
I did try with your way but it seem like the output getting error like below.

and this is my setting for my influxdb

actually the setting for my database worked whenever i try to insert a data into influxdb.

Did I missed anything? It seem like your version of influxdb is different with mine. Could it be a problem with the version?

... or do i need to create a function like below because in my database only appear timestamp (time) and the value (volt1):

You have specified that you want to use flux as the query language, but the query you showed us influxql. Select the 1.x type in the influx node.


wow... it's work!! thanks @Colin and @Steve-Mcl

so the Raw Output will be like this:

and the non-Raw Output will be like this:

Is there any post that can show me how to extract the value from the non-Raw Output? Because I'm thinking to get the value of "volt1" only... such as "402". After this I'm thinking to process the value and do some analysis.

You said you had watched the Essentials Guide videos, but I am sure there would be help with that question there. Also see this page from the docs. Working with messages : Node-RED

I notice that your query appears to have returned a string for volt1. Does that mean that you are writing string values to database for something that is actually a number. If so then that is a bad idea. Make sure you provide it to influx as a Number not as a String. Unfortunately I think that means you will have to DROP the measurement and start again as it is not possible to change the field type once the field has been created.

Yup I watched the videos so many times, and I make a lot of note about it. What I'm trying to say is I'm trying to extract the value using external Python Script for process it. Sorry for the incomplete question I asked just now. I hope you @Colin and @Steve-Mcl don't blame me.

Do you mean you want to extract the value from a message in node-red using a Python script to extract it? If so then that doesn't make any sense.

If you mean you want to extract the value in node red (which is described in the link I posted) and pass it to a python script then that is a different question. You can call a Python script using an Exec node and pass it whatever you like.

However, if that is what you mean, what are you doing in the script that cannot be done in node-red?

1 Like

Because I'm facing the node red consume my CPU usage (about 96%) when I try to process everything inside it... FYI, I have about 23 pcs of different sensors which are been located far from each other.... and each sensor having 3 topics to send through MQTT.... all raw data will be display in grafana.... As I just try just now, it seem like grafana also had a problem with streaming/refresh....

I'm still figuring it out how to solve the problem which is I don't know what it's going on when I deploy my extraction processes inside node red...

This is what happen if I try to run my extraction process inside node red

How often are the data arriving from each sensor? What hardware are you running on? Are you running node red, mosquito, influx and grafana all on the same computer? Where are you running the browser?

Each node need to send all the data every 100ms for 2 minutes. After the 2 minutes, the node will be in deep sleep mode for 58 minutes. I'm using TTGO T-Call board (ESP32+GSM SIM800L) and the sensors is ADS1115 (Sensing the voltage), soil pH sensor and DHT22 (but i'm using humidity value only).

And yes, I'm running mosquitto (as MQTT broker), node red (as client and as input via dashboard), influxdb (for database) and grafana (as graph display including data that I try to perform externally). I'm running everything on cloud server (Alibaba Elastic Server) with Ubuntu 20 installed. I'm running the browser remotely using chrome.

Can you explain what you mean by that? What is a node? How much data is it sending every 100ms?

Also what are you doing in the python code?

[Edit] Also, are all the nodes doing this at the same time or is it one after the other?

Node a.k.a the device which is the microcontroller with sensors. For each node, I'm not sure how much data been sending but what can I know is 3 data (voltage, ph value, humidity).

In python i'm trying to detect any kind of anomaly created. It just like graph pattern recognition. The value of voltage difference will be then plotted in grafana. I'm using influxdb data insertion for plotting.

Initially, I'm thinking to make the nodes send the data at the same time according to the time that has been sync with the gsm clock.

Ok, in that case, you can run the python command from an exec node. Or you could run it separately from node red picking up the data directly from mqtt. Or you could run it from a Daemon node, numerous possibilities.

1 Like

WOW... you are really helpful @Colin. I didn't expect so much brilliant ideas I can get from around the world. But you are AWESOME!!!... Really appreciate it. I will try every suggestion you gave me. Thanks a lot.

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