How to Query Info From Influx DB in Node-RED

@dj13990 - You inspired this.

First go to add pallet node-red-contrib-influxdb and load it in Node-RED
It’ll take a bit to load

Open CodeIDE and connect to your CORE as you’ll need to obtain your password to InfluxDB that is unique to your CORE.

run the following command

cat /home/oh-la/data/influxdb/influxdb-telegraf-passwd

image

After it’s loaded, drag in an “influxdb in” node.

Configure your configuration node to the following

image

Password is the password you queried.

Here is the flow to query RAM, CPU Temp, CPU usage.

[{"id":"b546ce0f1e30315a","type":"influxdb in","z":"b2a52421545daaaa","influxdb":"caa025e3ad6b2faa","name":"","query":"","rawOutput":false,"precision":"","retentionPolicy":"","org":"organisation","x":530,"y":2520,"wires":[["6044659f79aaf1ce"]]},{"id":"c4c03484dc503999","type":"inject","z":"b2a52421545daaaa","name":"Get RAM %","props":[{"p":"query","v":"SELECT last(\"used_percent\") FROM \"mem\" ORDER BY time DESC LIMIT 1","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"influxdb/ram_percent","x":270,"y":2480,"wires":[["b546ce0f1e30315a"]]},{"id":"d2887e6d4bcea197","type":"inject","z":"b2a52421545daaaa","name":"Get CPU Temp in C","props":[{"p":"query","v":"SELECT \"temp_input\" FROM \"sensors\" WHERE \"chip\" = 'cpu_thermal-virtual-0' GROUP BY \"chip\" ORDER BY time DESC LIMIT 1","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"influxdb/cpu_temp_c","x":250,"y":2520,"wires":[["b546ce0f1e30315a"]]},{"id":"df49d0733ed59ab7","type":"inject","z":"b2a52421545daaaa","name":"Get CPU Usage %","props":[{"p":"query","v":"SELECT last(\"usage_idle\") * -1 + 100 FROM \"cpu\" WHERE \"cpu\" = 'cpu-total' ORDER BY time DESC LIMIT 1","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"influxdb/cpu_usage_percent","x":250,"y":2560,"wires":[["b546ce0f1e30315a"]]},{"id":"6044659f79aaf1ce","type":"change","z":"b2a52421545daaaa","name":"First array item","rules":[{"t":"set","p":"payload_raw","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":2520,"wires":[["c958932c4947fb37"]]},{"id":"c958932c4947fb37","type":"debug","z":"b2a52421545daaaa","name":"InfluxDB Debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":980,"y":2520,"wires":[]},{"id":"caa025e3ad6b2faa","type":"influxdb","hostname":"10.10.2.1","port":"8086","protocol":"http","database":"telegraf","name":"Telegraf DB","usetls":false,"tls":"4592f87ea5e07b61","influxdbVersion":"1.x","url":"http://localhost:8086","rejectUnauthorized":true,"credentials":{"username":"telegraf","password":"2RUelu3P0ICyxV8P","token":""}},{"id":"4592f87ea5e07b61","type":"tls-config","name":"Default TLS","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false,"alpnprotocol":""}]
2 Likes