I have sensor data from MongoLab to Node-RED and I want visualize this data using Node-Red dashboard in form of a gauge or chart.
Data from the mongoLab collection looks like this:
[{"_id":"5947e34de8fef902920defd8","sensorId":"5947340048225508","value":34,"date":"2017-06-19T14:44:29.000Z"},{"_id":"5947e34e6737e202b54f0a62","sensorId":"13359295204302776","value":25,"date":"2017-06-19T14:44:30.000Z"},{"_id":"5947e352e8fef902920defdc","sensorId":"5947340048225508","value":37,"date":"2017-06-19T14:44:34.000Z"},{"_id":"5947e3536737e202b54f0a66","sensorId":"13359295204302776","value":24,"date":"2017-06-19T14:44:35.000Z"}]
I want to visualize the values based on the sensorId...or is there any way I can be able to visualize this data using Node Red.
The function node is using the following javascript
msg.headers = {"Content-Type":"application/json"};
return msg;
My intention is to visualize the sensor value on the ui_gauge or chart.
Make a gauge/graph for each of the unique data steams you want to reflect in the UI/dashboard,
Then you'll need to double the output lines to another function that passes this information to the msg.payload, and then from that function, tie it to the corresponding dashboard gauges.
A gauge will obviously show the last value sent, while a graph will show you a history. May need to tweak the visual layout of the dashboard gauges/charts to show more data, to your liking.
Flow Chart Example
Your code might look something like this in the new forked function that is then tied to your gauges:
msg.payload = msg.value;
return msg;
or you can use a switch, that then breaks the values to multiple outputs, that then each output goes to a corresponding gauge to reflect the data.
Flow Chart Example Using Switch
I really hope this helps.
Related
Well, let's say that I have the query from my previous question: How to do multi graph time series on Grafana with Kusto
Then I'd like to consume the tiemposCicloBruto variable from one panel to another in order to avoid repeating queries.
I saw: https://grafana.com/blog/2020/10/14/learn-grafana-share-query-results-between-panels-to-reduce-load-time/
But there isn't any way to share variables at all...
I also tried it as a dashboard variable, but it doesn't seem to support tabular expressions at all...
You can share only input variables across dashboard panels. Variables work as primitive text substitution in one direction (from dashboard to query), and do not take into account any context in your query language.
Your link tells about sharing results of the query between different panels. If exact same result set returned to a panel fits your needs, you can reuse it "for free", without putting load on the database. You don't need to save it into any variable, you just set it as a pseudo-datasource and you get the result immediately.
You can factor this feature into design of you panels. Examples could be:
time series plus histogram visualizations of the same data;
time-series chart plus a panel with latest readings (or use other Grafana reduce expressions).
I'm using Grafana v9.1.8.
I created a panel bases on data from influxdb.
The data only sent when application is working, so sometimes there is no data.
And the dashboard will show just 'No Data' in the middile of the panel without any graph.
I'm trying to keep the graph(axis) shown even if there's no data, but I cannot find the solution.
As far as I know, there is no such feature on Grafana at the moment, but I found this solution:
https://community.grafana.com/t/what-to-show-when-the-panel-is-without-data/66524/9
Make a fake union, check if you have any data and if you don't create some random time data without other parameters. As they say in the answer, this may not be scalable, as you need to add extra lines for each query, but it may be a workaround.
It is quite a while since I coded something and it is the first time I am dealing with Influxdb and NodeRED.
I am acquiring four sets of measurements from a sensor connected to a Pi. This is a screenshot taken during the debug, the measurements are coming trough.
I managed to get the data from the sensors into NodeRED:
The problems I am facing are:
how to structure the table (measurements) in InfluxDB and get those
data into the right column;
and how/where to define the sample interval to avoid millions of data
into the db?
I will later on try to connect the DB with Grafana and it is all new for me.
Any help is appreciated.
First, add a function node at the end of each sensor node and save the output as variable. The code will vary greatly depending how you are getting your sensor data, but here is how I do it:
msg.payload = Number(msg.payload);
flow.set("presion_agua_psi",msg.payload);
flow.set("sensor_presion_agua","Wemos D1");
return {payload: msg.payload};
In example below, I am using MQTT to send the sensor data
Then, separately, use an inject node and set it to repeat every xx minutes. This is the timeframe you will use to actually save the data into influxDB.
After the inject node, add a function node that creates a dictionary, using the variable name and its value. This will make sure your columns in influx are stored with a name.
Once again, the code will vary, but here is an example:
msg.payload = {
Timestamp:date,
Device:flow.get("sensor_nivel_agua"),
Nivel_Agua_Tinaco:flow.get("Agua_Tinaco"),
}
return msg;
Finally, add your influxDB credentials and debug to make sure the data is getting stored correctly.
I've got a dashboard with a template variable for our VM instances based on their hostname and the dashboard repeats a row of panels of collectd graphs (CPU, memory, etc) based on the items in that variable.
However when we rotate out VMs the Graphite data hangs around for a while, but the data is empty, so i don't want to show them in the dropdown.
The current query is
platform.collectd.*
I tried something like this to filter out the ones with no current data, but it returns nothing in the list:
aliasByNode(maximumAbove(platform.collectd.*.cpu-0.percent-idle.value,0),2)
It seems it only works with a wildcard at the end.
Is there any way to get around this?
I have Grafana with Bosun connected as OpenTSDB source. Problem is Grafana interprets data in different way than Bosun. To be precise, when I set same query in Bosun and in Grafana, resulting graphs differ. When I turn on gauge downsample, graphs are same. So I guess there is implicit gauging of some sort in Grafana. I would be grateful for some hint how to disable that gauging.
Bosun:
Grafana:
The os.net.bytes metric includes metadata to indicate that it is a rate. When you use the default "auto" in Bosun's graph page it will convert the raw counter data into a rate calculation. Grafana's OpenTSDB data source does not have an auto mode, so things always default to a gauge unless you check the Rate box at the bottom of the metric.
In your example you should just need to check the rate box to get the graphs to match. You can also use the Counter option and provide a max or reset value if you need to deal with counter overflows
You can also use the Bosun data source if you want to use a Bosun query instead of accessing OpenTSDB directly. In this example we combine two queries to generate a Singlestat panel (displays last value and a line graph in the background)
The __ny-nexus01/02 part comes from using tsdbrelay to denormalize the metric and address high tag cardinality issues.