Use Node-RED to fetch JSON or CSV data and store it in InfluxDB

Versions

  • Node-RED v0.16.2
  • InfluxDB v1.2.2
  • Grafana v4.2.0
  • Ubuntu 16.04.2

I'm looking to access weather data from a local official weather station. The options available are in either csv or JSON format.

  • I am attempting to retrieve the JSON feed using Node-RED.
  • Using an HTTP request node, I managed to obtain parsed JSON data.

The retrieved data is structured as follows:

object

  • observations: object
    • notice: array[1]
    • 0: object
      • copyright: "Copyright Commonwealth of Australia 2017, Bureau of Meteorology. For more information see: urlhere urlhere"
      • copyright_url: "urlhere"
      • disclaimer_url: "urlhere"
      • feedback_url: "urlhere"
    • header: array[1]
    • 0: object
      • refresh_message: "Issued at 9:32 pm EST Tuesday 2 May 2017"
      • ID: "IDV60801"
      • main_ID: "IDV60800"
      • name: "Moorabbin Airport"
      • state_time_zone: "VIC"
      • time_zone: "EST"
      • product_name: "Weather Observations"
      • state: "Victoria"
    • data: array[155]
    • [0 … 9]
      • 0: object

To isolate and extract only the data: array, I used a function node called "Extract Value" containing the following code:


msg.payload = msg.payload.observations.data[0]
return msg;

The output object generated by this function contains relevant weather data fields.

Upon attempting to store this data into InfluxDB, an error occurred due to invalid number parsing.

Inserting a JSON node before saving to InfluxDB yielded successful debug output but resulted in no values being visible within Grafana charts or tables.

Your assistance is needed on the best approach to fetch data from the specified website and effectively display it graphically via Grafana after storing it in InfluxDB.

Answer №1

Here is a suggestion for you to consider:

try implementing the following code snippet:
  return {
    payload: {
      info : message.payload.list.item[0]
    }
  };

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Leveraging AngularJS to enhance the dynamic HTML content within Datatables

My angular application includes a Datatable where I alter cell content to include HTML elements. In the given code snippet, I specifically modify the cell content of the 5th column to incorporate links. Additionally, I intend to implement a tooltip featur ...

Why isn't my Angular directive able to access the parent controller's scope within its isolated scope?

I have meticulously followed the Angular documentation to implement a directive with an isolated scope that contains a few variables from the parent Controller's scope object. app.controller('MainCtrl', function($scope) { $scope.name = ...

Having trouble retrieving data from the React form

import React from 'react' import ThankYouModal from '../components/modals/ThankYouModal'; export default class ContactForm extends React.Component { constructor(props){ super(props); //inputs this.showOrgan ...

Navigate through a JSON data structure containing nested arrays

Does anyone know an effective way to loop through a JSON object that contains two or more nested arrays? The goal is to extract the values from each array without including key-value pairs in the output. {"Obj": ["array 0", ["nested array 1"], ...

AngularJS - Issue with ng-mouseover not triggering controller function

I am struggling to get a function to trigger when my button is hovered over. Despite writing what I believe is the correct code, the function from my controller is not being called. Can anyone spot the issue? Below is the JavaScript code: angular.module( ...

Keep only certain fields and eliminate the rest

Write a function that filters out all fields except 'firstName' and 'lastName' from the objects. Check out this code snippet I came up with. Any feedback? let people = [ { firstName: 'John', lastName: &apo ...

Ways to append a number to the start or end of an array using JavaScript

Can you help me figure out why the function to order the "s" array from minor to major is adding the number at the end instead of the beginning? The if statement seems to be true (2 < 7 = true) but the logic is not working as expected. Any advice on how ...

Can you provide me with some insight on the process of iterating through an object utilizing the

I've developed an app that randomly plays a sound from a selected array when a button is pressed. Now, I want to add the functionality to display and play all sounds in the array upon request. I've explored various methods such as for loops and ...

What is the reason for AngularJS's inclusion of a colon at the end of a data object in an $http post

While attempting to utilize angular js $http for sending a post request to elasticSearch, I encounter an "Unexpected token : " Error. Here is a snippet of my code: var request= $http({ method: "post", url: path, accept:"*/*", headers:{"Co ...

Angular: displaying dates in a specific format while disregarding time zones

Is there a way to format date-time in Angular using DatePipe.format() without converting timezones, regardless of location? For instance, for various examples worldwide (ignoring time differences) I would like to obtain 07/06/2022: console.log('2022-0 ...

AngularJS approach to binding window scroll

Hey there, I'm a newcomer to AngularJS with a background in jQuery. I'm trying to create a fixed-top navbar using AngularJS that has a background which changes from transparent to opaque as the window is scrolled. Unfortunately, I'm struggli ...

JQuery: Techniques for accessing the assigned font of an element

Can the assigned font of an element be retrieved using jQuery? For example, if there is this CSS: #element { font-family: blahblah,Arial; } In the above case, the Arial font will be assigned to #element. Is it possible to extract that information using ...

The Implementation of Comet Programming

I'm interested in creating a web application similar to Google Docs where multiple users can edit and view changes in real-time. Would Comet Programming be the best approach for this? As a newcomer to Web Development, I'm currently learning Java ...

In the realm of jQuery, erasing dynamically generated elements across multiple elements sharing the same index is a task

Currently, I am enhancing the select box dropdown and list of new fonts by adding custom font names. In addition to this, I also want to incorporate a feature for deleting fonts. For instance, when I delete font A from the list (which is currently functio ...

Tips for validating user input in AngularJS without using a form tag

Within a popup, I am displaying HTML content that has been copied from another div and shown in the popup. I need to validate this input field to ensure it is required, and display an error message below the input box. <!-- HTML code for changing zip c ...

Challenges with Vue and the <noscript> element

I recently deployed a vue app and everything seems to be functioning as expected. However, I encountered an issue when trying to view the page source in any browser - the actual content is not visible and instead, the body section starts with a message ins ...

Using JavaScript functions within PHP is not supported

Currently, I am utilizing Laravel for my backend operations. Within my setup, there exists a JavaScript function called StartJob() that facilitates Google crawling. In the scenario where I input a keyword, which is then cross-referenced with the database, ...

Disable body scrolling on mobile devices in native browsers

When using the native browser on Samsung Galaxy S5 / S6, the following CSS code: body { overflow: hidden; } does not successfully prevent the body from scrolling. Is there a way to work around this issue? Edit: As mentioned below, one workaround is t ...

Tips for inserting an object into an array while concurrently saving it to a file in Node.js

Is there a way to add objects to an array while writing to a file in Node Js? Presently, my functioning code looks like this: fs.appendFile("sample.json", JSON.stringify(data, undefined, 2) + ","); with 'data' being an object similar to this: ...

JavaScript not functional post AJAX request - navigating AJAX tabs

I am attempting to create a submenu that can update the page content without refreshing by using AJAX tabs to call an external HTML file. While the tabs are functioning properly, I am facing an issue with a JavaScript code within the external HTML file tha ...