How to send data to Grafana Cloud via Node-red

Hi, Im trying to send simulated data in node-red to grafana cloud.

what do I need to fill in the HTTP Request node to that the data is send to my cloud?
Method POST
and headers I have Content-type: application/json

I got this error:
“{“message”:“Bad request”,“messageId”:“auth.client.notConfigured”,“statusCode”:400,“traceID”:“7f504e2af06a7bfd41db5e1361b6a572”}”

Welcome @alenahakkarainen1

I am not totally clear on what you are doing, but remember that Grafana is a visualization tool that allows one to view data. That data can come from many different sources (and usually databases), but I do not see how Node-RED is a datasource.

I presume you are collecting data using Node-RED and want to view that in Grafana. If that is the case, you need to put the data into a datasource that is compatible with Grafana.

Also, since you mentioned you are using Grafana Cloud, remember they include Prometheus and Graphite.

Another idea is that if you do not want to store your data, but just view it ephemerally, you could use the MQTT plugin (https://<your_username>, but I can tell you from experience that it can be a bit difficult to set up and get going. Also, it does not support alerting a few other features.

1 Like

yes, sending data, store them in Grafana Cloud and then show in Grafana dashboard.

this is what I found:
“However, when you are sending data directly to Grafana Cloud, you can bypass the need for Prometheus or Graphite. You can send your data directly to Grafana Cloud using HTTP requests or other supported methods. Grafana Cloud provides its own data storage and visualization capabilities, so you can use it as a standalone solution for your monitoring and dashboarding needs.”

Can you provide the URL where you found the above?

ChatGPT :smiley:

Hi @alenahakkarainen1

OK, so this is possible, but much of what I said earlier holds true, i.e. Grafana needs to have a datasource. In this case, what ChatGPT left out is that if you send your data directly to Grafana Cloud using HTTP, it will be stored in either Prometheus or Graphite. Here are the official links to both methods:
Send metrics to Prometheus endpoint
Send metrics to Graphite endpoint

Having said that, I created a very rudimentary flow in Node-RED to send temperature and humidity values via HTTP to Prometheus hosted in Grafana Cloud. Here is the flow:

[{"id":"8a4adf449ce79d58","type":"http request","z":"ac2f4d692b3d4396","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"basic","senderr":false,"headers":[],"x":630,"y":420,"wires":[["2c8ad8ab20b22332"]]},{"id":"27b6da41d03a84ee","type":"function","z":"ac2f4d692b3d4396","name":"function 66","func":"// Sample data\nconst measurement = \"household_data_test1\";\nconst tags = \"room=kitchen\";\nconst fields = \"temperature=76,humidity=55.55\";\n\n// Combine into Influx Line Protocol format\nconst influxData = `${measurement},${tags} ${fields}`;\n\n// Send the formatted data to the next node\nmsg.payload = influxData;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":390,"y":420,"wires":[["8a4adf449ce79d58"]]},{"id":"2c8ad8ab20b22332","type":"debug","z":"ac2f4d692b3d4396","name":"debug 146","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":850,"y":420,"wires":[]},{"id":"88a8a3484cd8103a","type":"inject","z":"ac2f4d692b3d4396","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":420,"wires":[["27b6da41d03a84ee"]]}]

and here are the details worth covering:
Function node contains the following. You could obviously tailor this to accept actual temperatures or humidity values from a sensor.

// Sample data
const measurement = "household_data_test1";
const tags = "room=kitchen";
const fields = "temperature=76,humidity=55.55";

// Combine into Influx Line Protocol format
const influxData = `${measurement},${tags} ${fields}`;

// Send the formatted data to the next node
msg.payload = influxData;
return msg;

HTTP Request Node config looks like this. The URL, username and password (token) come from the Details section of Prometheus metrics in the cloud stack.

And the quick n’ dirty dashboard containing a few points of data sent by Node-RED:

Can I use this example also for my function (simulated data) or does it need to be in the influx line protocol format ( this output is JSON):

var power = 0; // Initial power value
var increment = 1; // Increment value in kW

// Function to send data to the debug node
function sendToDebug() {
var time = new Date().toLocaleTimeString(); // Get the current time
var data = {
time: time,
power: power
msg.payload = data; // Assign the data object to msg.payload
node.send(msg); // Send the message to the debug node

// Generate a new power value every second
var timer = setInterval(function () {
// Increment power by the specified value
power += increment;

// Check if the power value has reached the maximum (reset to minimum)
if (power > 100) {
    power = 0;

// Check if it's time to send the data to the debug node (every 15 minutes)
if (new Date().getMinutes() % 15 === 0 && new Date().getSeconds() === 0) {

}, 1000);

in this your example, Am I actually sending the data to the Grafana Cloud or Influx DB?

In my example, I was sending it to Prometheus hosted in Grafana Cloud (this is articulated in the link that I sent).

If you are sending to Prometheus, it needs to be in Influx Line Protocol format per the docs.

If you are sending to Graphite, then there appear to be more allowable format options (maybe JSON is acceptable?), but read through the link above and try working it out.

1 Like

Im getting an error (invalid authentication credentials)when trying with your flow
using url:

generated token and my username number…

You have the wrong URL.

See the docs in the link that I sent:

I guess Im using the right now
but still getting another error:
{“code”:“Error”,“message”:“It looks like there is an issue with this instance.”}

the username and token are correct

If you are certain you have the correct URL, username and token (pwd), and it still does not work, I
would Open a Support Ticket from the Cloud Portal

1 Like