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

Can you clarify the concept of closures and how they bind the loop counter to the function scope?

I have observed programmers setting up event listeners inside loops, utilizing the counter. The syntax that I have come across is as follows: for(var i=0; i < someArray.length; i++){ someArray[i].onclick = (function(i){/* Some code using i */})(i); ...

Serializing a JsonElement field using JAXB in a POJO

I have a custom ordinary Java object (POJO) class called Cat. It looks like: class Cat { public Cat() {} private String name; private JsonElement arbitraryProperties; } Within my application, I am using Jackson (JAXB) to work with the Cat resource ...

Stop Browsers from Saving the Current Page in the History Log

Currently, I am facing an issue with a user-triggered popup window on my website that redirects to another site. It is important that users do not access this page directly and only navigate to it if the popup window opens as intended. mysite.com -> my ...

javascript: extracting class name from HTML elements

To extract class names from an HTML code using JavaScript, I can utilize the following method: var cPattern = new RegExp(/class[ \t]*=[ \t]*"[^"]+"/g); var cMatches = data.match(cPattern); However, the above code returns an array with values li ...

Minimize the number of HTTP requests by including CSS and JS files in PHP

I've been considering a method to reduce the number of HTTP requests made when loading a page by minimizing the amount of downloaded files, while still keeping separate files on the server. The thought process is as follows: <!DOCTYPE html> &l ...

What is the return value of the .pipe() method in gulp?

When using the code snippet below, what will be the input to and output of .pipe(gulpIf('*.css', cssnano()))? gulp.task('useref', function(){ return gulp.src('app/*.html') .pipe(useref()) .pipe(gulpIf('*.js&apo ...

Importing ReactDOM alone does not result in the rendering of anything

Having just started delving into the world of React, I've been grappling with getting a React app up and running. Despite my efforts, all I can manage to see is a blank page. Can anyone offer some assistance? HTML Markup (index.html) <html> & ...

Ensuring the cookie remains active throughout various subdomains

After implementing code to set a cookie on example.com, I noticed an issue with it carrying over to the subdomain dogs.example.com. <script> document.cookie="cid1={{utm_campaign}}; path=/;" </script> The {{}} is part of Google-Tag-Manager s ...

Loop through each object and add them to an array in a file using NodeJS

Currently, I have a scenario where I am executing a POST request inside a for loop function and the response needs to be stored as an object in an array file. Below is the code snippet that I am utilizing: var arrayFile = fs.createWriteStream("arrayFile.j ...

How to isolate a function in React when mapping data

I am currently working on mapping data as a repeater in my React project. However, I am facing an issue with isolating the opening function, specifically with an accordion component. As I continue to learn React, I want to ensure that each accordion operat ...

The process of retrieving keys and values from localStorage in html5

I have stored some important key-value pairs in local storage. Now I need to retrieve both the keys and values, and then display them by appending the values in a list item (li). Currently, my attempt at this looks like: for (var i = 0; i < localStorag ...

Transform the terraform resource data, which is in the form of a map containing keys of type string

I am currently developing a custom terraform provider and have encountered an issue. I'm attempting to convert a schema.TypeList field into a struct. Here is what the TypeList looks like: "template": { Type: schema.TypeLi ...

What methods can be used to test included content in Angular?

When testing an Angular component that includes transclusion slots utilizing <ng-content>, it becomes challenging to verify if the transcluded content is correctly placed within the component. For instance: // base-button.component.ts @Component({ ...

Make Fomantic-UI (Angular-JS) sidebar scroll independently

Is there a way to make a sidebar scroll independently of the content it pushes? Currently, my page is structured like this: -------------------------- |[button] Header | -------------------------- |S | Main content | |i | ...

What causes the "node: bad option" error to occur when I include a custom flag in the nodejs command line within an Angular 9 application?

Seeking assistance with adding a custom flag to the npm start command in an Angular 9 project. The goal is to intercept proxy requests within the local server and manipulate data. However, encountering the "node: bad option" error consistently. Looking for ...

Dealing with functions that may not consistently return a promise

When dealing with a situation where a function does not always return a promise, how can it be best handled? The complexity of my current code prevents me from providing a detailed explanation, but essentially, the issue involves checking a condition and t ...

"Enhance your Material-UI ListItems with dynamic ripple colors when using React-Router NavLink

Currently, I am attempting to nest a Material-UI <ListItem button> within a react-router <NavLink>. While functionality is present, I have observed that the ripple colors on the <ListItem button> are being altered by the <NavLink> C ...

Ensuring the accuracy of nested objects through class validator in combination with nestjs

I'm currently facing an issue with validating nested objects using class-validator and NestJS. I attempted to follow this thread, where I utilized the @Type decorator from class-transform but unfortunately, it did not work as expected. Here is my setu ...

Retrieving data arrays from response.json

I've been on a wild goose chase trying to solve this puzzling issue. RAWG has transitioned to using their own API instead of Rapid API for game reviews, and I'm in need of data for "Tom Clancy Rainbow Six Siege". Despite my efforts to convert t ...

Can you create a while loop that continuously asks for user input, stores the responses, and then makes them accessible in an array?

When developing a Yeoman generator, the necessary dependencies can be found at https://github.com/sboudrias/mem-fs-editor#copytplfrom-to-context-settings and https://github.com/SBoudrias/Inquirer.js/. The main goal is to prompt the user with a question an ...