Here's an edited version of my notes for Node-Red/InfluxDB/Grafana on Raspberry Pi 3:
################################################################################
# This is a guide to installing Node-Red/InfluxDB/Grafana on a Raspberry Pi3
# along with a static IP address either configured on the RPI or (my personal
# preference) on the router.
#
# It may work on other models except the RPi Gen 1 and zero models which do not
# have ARM7. This guide assumes that you already have Raspbian Buster installed
# on the RPI and it is running and updated. Rather than using the desktop
# edition, Buster Lite was installed to reduce the load on the RPi.
#
# All notes are prefaced by the pound (#) sign. Lines that do not have a
# leading pound are commands that can be entered directly in the terminal.
# For ease on my part, the install commands were entered on a Windows 10
# computer using PuTTY. Please note that some of the comments contain task
# that must be performed as part of the install process.
################################################################################
# Install build essential
sudo apt-get install build-essential
# Note - already up to date on my Raspbian
####################
# Install Node-Red #
####################
# https://nodered.org/docs/getting-started/raspberrypi
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
# (Y)es to install and also to installing the extra pi nodes
# During the install it displayed: Node v12.13.1, Npm 6.13.1, Node-red core 1.0.3
# Run from terminal
node-red
# Open a web browser and access it at
# <your_static_IP_address>:1880
#CTRL+C to stop it running in a terminal
# Rrun node red as a service
sudo systemctl enable nodered.service
# returned: Created symlink /etc/systemd/system/multi-user.target.wants/nodered.service → /lib/systemd/system/nodered.service.
sudo shutdown -r now
# Test again
# access at:
# <your_static_IP_address>:1880
####################
# Install influxdb #
####################
#https://docs.influxdata.com/influxdb/v1.7/introduction/installation/
# Add the InfluxDB key
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
# Add the InfluxDB repository to the sources list
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update
sudo apt-get install influxdb
# Enable the InfluxDB service file
# The first command we use unmasks the influxdb service file. Unmasking the service ensures that we can enable and start the service as a masked service is unable to be started.
# The second command enables the influxdb service. This command will tell the service manager to keep an eye on the “influxdb.service” file and setup the service based on its contents.
sudo systemctl unmask influxdb
sudo systemctl enable influxdb
# Create a folder to store the Influx data
cd ~/data
mkdir influxdb
sudo chown -R influxdb:influxdb influxdb
#note - 776 is not adaquate
sudo chmod -R 777 influxdb/
cd ~
# Edit the config file to use the data folder
sudo nano /etc/influxdb/influxdb.conf
### Change these values
#[meta]
# dir = "/var/lib/influxdb/meta"
#to
# dir = "/home/pi/data/influxdb/meta"
#[data]
# dir = "/var/lib/influxdb/data"
#to
# dir = "/home/pi/data/influxdb/data"
# wal-dir = "/var/lib/influxdb/wal"
#to
# wal-dir = "/home/pi/data/influxdb/wal"
# Test
influxd
###IN A NEW SEPERATE TERMINAL
influx
# If you get the shell (not quick by the way), close by:
exit
# Close terminal
# For more testing
sudo apt-get install lsof
sudo lsof -i tcp:8088
# Results should be similar to:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# influxd 762 influxdb 3u IPv4 15008 0t0 TCP localhost:omniorb (LISTEN)
sudo lsof -i tcp:8086
# Results should be similar to:
# COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
# influxd 762 influxdb 5u IPv6 15012 0t0 TCP *:8086 (LISTEN)
### in the terminal where influxd is running
CRTL+C
#start up the InfluxDB server
sudo systemctl start influxdb
#WAIT A FEW MOMENTS... to make sure it's running.
systemctl
# Scroll up and down using the arrow keys looking for:
# "influxdb.service loaded active running"
# type the letter Q to exit
sudo lsof -i tcp:8088
sudo lsof -i tcp:8086
# You should get the same results as above
# Run the command line tool in terminal
influx
#If you get to the shell, it's running
quit
###################
# Install Grafana #
###################
cd~
mkdir Downloads
cd Downloads
# https://grafana.com/docs/installation/debian/#apt-repository
# and
# https://grafana.com/grafana/download?platform=arm
wget https://dl.grafana.com/oss/release/grafana_6.5.0_armhf.deb
sudo apt-get install -y adduser libfontconfig1
sudo dpkg -i grafana_6.5.0_armhf.deb
# Results of the install
# "NOT starting on installation, please execute the following statements to configure grafana to start" automatically using systemd
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
# Returned:
# Synchronizing state of grafana-server.service with SysV service script with /lib/systemd/systemd-sysv-install.
# Executing: /lib/systemd/systemd-sysv-install enable grafana-server
# Created symlink /etc/systemd/system/multi-user.target.wants/grafana-server.service → /usr/lib/systemd/system/grafana-server.service.
# You can start grafana-server by executing
sudo systemctl start grafana-server
# Open in a web browser:
# http://<your_static_IP_address>:3000/login
# Default username and password is admin/admin
# I changed the password and clicked 'Save' button
######DOCUMENT THE PASSWORD YOU ENTERED#####
# Reboot
sudo shutdown -r now
# Login and test
systemctl
# scroll up and down looking for these 3 entries:
# grafana.service loaded active running
# influxdb.service loaded active running
# nodered.service loaded active running
# type the letter Q to quit
#######################################################
# AT THIS POINT THE SOFTWARE IS INSTALLED AND RUNNING #
# Now time to do some configuration #
#######################################################
# Create the database to use in influxdb named "hubitat"
# Run the influx command line
influx
# At the ">" prompt in the InfluxDB shell enter:
CREATE DATABASE hubitat
exit
# Open node-red in a web browser (I used Firefox on Windows 10):
# <your_static_IP_address>:1880
# hamburger menu (3 horizontal lines) / manage pallet / install tab
# Search for "node-red-contrib-filter" and click the 'install' button on 'node-red-contrib-filter'
# Click 'install'
# Search "node-red-contrib-influxdb" and click the 'install' button on 'node-red-contrib-influxdb'
# Click 'install'
# Click the 'Close' button
# Copy the contents of this page into the clipboard:
# https://raw.githubusercontent.com/danTapps/node-red/master/HE2InfluxFull.json
# Click the hamburger menu (3 horizontal lines) for Node-Red and select 'Import'
# Click the Hamburger menu (3 horiontal lines) and then click "Configuration nodes".
# You should see an 'influxdb' and a 'websocket-client' node.
# Since the influxdb is set to run on the local host of the RPi, no change is needed.
# Double-click the "ws://192.168.10.153"...
# Change the URL to reflect the IP address of YOUR hubitat and click the 'Update' button
# Double click on the flow tab (name 'flow 4')
# Give it a descriptive name. I used "Hubitat to InfluxDB"
# In the bottom-left corner make sure the button shows "Enabled". If not click it.
# Click the 'Done' button
# Now click the red 'Deploy' button
# Let's check and see if data is going into the database
# Back in terminal
influx
USE hubitat
# This will show all of the tables:
SHOW MEASUREMENTS
# So we can then get all records from the motion table via:
SELECT * FROM motion
# Exit the influx command line
quit
# Display data in Grafana
# Login to grafana with your username and password
# http://<your_static_IP_address>:3000/login
# Add a data source, Select 'Influx'DB
# In the URL field, put in http://<your_static_IP_address>:8086 where your IP number of the RPi
# under the "InFluxDB Details" put "hubitat" in the database name field.
# Click the 'Save and Test' button
# Click the 'Back' button
# Click the orange Grafana log in the top left corner to get back to the main page.
#################################################################################
# At this point you should have a working setup of Node-Red/InfluxDB/Grafana on
# a Raspberry Pi and need to setup some Grafana dashboards to display your data.
#################################################################################
ORIGINAL POST:
I’m hoping that someone out there is as anal about documenting installs as I am and have some notes they can share on setting up Node-Red/InfluxDB/Grafana on a Raspberry Pi 3. I’ve reached the point to where I need to be logging data (i.e. power usage, temp, humidity, etc) from Hubitat.
I have a brand new Raspberry Pi 3, 32 gig Sandisk Class 10 UHS microSD card freshly loaded with Raspbian Buster Lite (updated via apt), along with a 250 gig WD PiDrive mounted at /home/pi/data so there’s adequate space for data. The first problem (so far) is that after I installed the InfluxDB I got the error:
#add the InfluxDB key
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
#add the InfluxDB repository to the sources list
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update
sudo apt-get install influxdb
#OUTPUT of install
#Created symlink /etc/systemd/system/influxd.service → /lib/systemd/system/influxdb.service.
#Created symlink /etc/systemd/system/multi-user.target.wants/influxdb.service → /lib/systemd/system/influxdb.service.
#enable the InfluxDB service file
#The first command we use unmasks the influxdb service file. Unmasking the service ensures that we can enable and start the service as a masked service is unable to be started.
#The second command enables the influxdb service. This command will tell the service manager to keep an eye on the “influxdb.service” file and setup the service based on its contents.
sudo systemctl unmask influxdb
sudo systemctl enable influxdb
##################FIX TESTED - FAILED###############
#from https://github.com/influxdata/influxdb/issues/8912#issuecomment-431896205
sudo chown -R influxdb:influxdb /var/lib/influxdb
#edit the config file ****READ THROUGH AS THIS SETS THE LOCATIONS OF DATA
sudo nano /etc/influxdb/influxdb.conf
#start up the InfluxDB server
sudo systemctl start influxdb
#view at 192.168.1.183:8086
#################NOTHING LOADED#############
#run the command line tool in terminal
influx
#########
# ERROR #
#########
Failed to connect to http://localhost:8086: Get http://localhost:8086/ping: dial tcp [::1]:8086: connect: connection refused
Please check your connection settings and ensure 'influxd' is running.
I assume you haven't rebooted before you tried running "influx". Try "sudo service start influxdb"; that'll start the service without your having to reboot. And then "influx" will run.
Also to confirm everything is okay (and nothing else is bound to tcp ports 8088 and 8086), run the commands
sudo lsof -i tcp:8088
and
sudo lsof -i tcp:8086
The output will look something like this:
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd 26395 influxdb 3u IPv4 4800777 0t0 TCP localhost:omniorb (LISTEN)
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
influxd 26395 influxdb 14u IPv6 4799020 0t0 TCP *:8086 (LISTEN)
sudo service start influxdb #result: start: unrecognized service
sudo lsof -i tcp:8088 #result: sudo: lsof: command not found
sudo apt-get install lsof
sudo lsof -i tcp:8088 #Result: no data returned (nothing showing in terminal)
sudo lsof -i tcp:8086 #Result: no data returned
[root@office ~]
# apt-cache search influxdb
ethflux - InfluxDB data gatherer for ethtool-style network interface information
golang-github-dcso-fluxline-dev - Golang library to prepare sets of metrics in InfluxDB's Line Protocol format
golang-github-influxdata-flux-dev - lightweight scripting language for querying databases
golang-github-influxdata-influxql-dev - parser for the InfluxDB query language
golang-github-influxdata-line-protocol-dev - InfluxDB line protocol implementation
golang-github-influxdb-enterprise-client-dev - Golang client for speaking to the InfluxDB Enterprise application
golang-github-influxdb-influxdb-dev - Scalable datastore for metrics, events, and real-time analytics. Dev package
golang-github-influxdb-usage-client-dev - library for speaking to the InfluxDB Anonymous Usage Reporting API
golang-github-rcrowley-go-metrics-dev - Application level metrics capturing library for Go
golang-gopkg-alexcesaro-statsd.v1-dev - simple and efficient Golang StatsD client
grafana - feature rich metrics dashboard and graph editor
grafana-data - feature rich metrics dashboard and graph editor - data files
influxdb - Scalable datastore for metrics, events, and real-time analytics
influxdb-client - command line interface for InfluxDB
libinfluxdb-lineprotocol-perl - write and read InfluxDB LineProtocol
pcp-export-pcp2influxdb - Tool for exporting data from PCP to InfluxDB
python-influxdb - Client for InfluxDB - Python 2.7
python3-influxdb - Client for InfluxDB - Python 3.x
ruby-influxdb - library for InfluxDB
Now that you have those three running, the following link will help get you going. It's tailored to MySQL as a backend, but @dan.t did some amazing work getting the InfluxDB filter node working so you can use Influx as a backend.
Also, wrong syntax. You should be using the sudo systemctl start influxdb syntax. service will be going away in a future version of Linux (so the powers that be say).
I've read through that thread twice before ever posting for help here. I was hoping that someone had written a walk-through for themselves and could share it. I prefer to burn up a little less time if possible.
In the latest round of installs, I did use the systemctl syntax. Thanks for mentioning it.
Looking through a lot of web pages online, it appears that my original method should have been the correct repo for influxdb using this code:
I was actually going to do that at some point, but never got around to it. For me, the repo you posted did work. I think it was the service call that was messing you up.
One I get this up and running, I'd be more than willing to post my process as the setup is already documented. I've shutdown the RPi and am about to image what I have so far, restore an image of Buster installed and updated with my WD setup, and then try to reinstall the Node-Red/InfluxDB/Grafana again using the influx repo.
I re-read the Hubitat > NodeRed > MySQL > Grafana (LONG READ) thread and made a few notes on how to try and get it setup once the required components are installed and tested. How hard would that portion be to script out?
Poor choice of words on my part. Script as in providing the instructions necessary to complete the setup and have it feeding data into the database and a simple setup of data being graphed.
A bash script would be nice, but is far from necessary. I tend to write out Linux notes in a format where I can cut and paste them. I use comments with a hash mark so they can't be executed. But there are notes in the documentation that are strictly a manual process.
I had some permission issues with the default data directories, but since I was moving the data locations anyway I resolved them after creating the new folder. For me, the ~/data folder exists on a WD PiDrive (USB attached external HDD). But the same commands will work for any user.
To get influxdb installed:
#Install influxdb
#add the InfluxDB key
wget -qO- https://repos.influxdata.com/influxdb.key | sudo apt-key add -
#add the InfluxDB repository to the sources list
echo "deb https://repos.influxdata.com/debian buster stable" | sudo tee /etc/apt/sources.list.d/influxdb.list
sudo apt-get update
sudo apt-get install influxdb
#OUTPUT of install
#Created symlink /etc/systemd/system/influxd.service → /lib/systemd/system/influxdb.service.
#Created symlink /etc/systemd/system/multi-user.target.wants/influxdb.service → /lib/systemd/system/influxdb.service.
#enable the InfluxDB service file
#The first command we use unmasks the influxdb service file. Unmasking the service ensures that we can enable and start the service as a masked service is unable to be started.
#The second command enables the influxdb service. This command will tell the service manager to keep an eye on the “influxdb.service” file and setup the service based on its contents.
sudo systemctl unmask influxdb
sudo systemctl enable influxdb
cd ~/data
mkdir influxdb
sudo chown -R influxdb:influxdb influxdb
#note - 776 is not adaquate
sudo chmod -R 777 influxdb/
cd ~
#edit the config file to use the data folder
sudo nano /etc/influxdb/influxdb.conf
###Change these values
#[meta]
# dir = "/var/lib/influxdb/meta"
#to
# dir = "/home/pi/data/influxdb/meta"
#[data]
#dir = "/var/lib/influxdb/data"
#to
#dir = "/home/pi/data/influxdb/data"
#wal-dir = "/var/lib/influxdb/wal"
#to
#wal-dir = "/home/pi/data/influxdb/wal"
#test
influxd
###IN A NEW SEPERATE TERMINAL
influx
#if you get the shell (not quick), close by:
exit
#close terminal
sudo apt-get install lsof
sudo lsof -i tcp:8088
#results should be:
#COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
#influxd 762 influxdb 3u IPv4 15008 0t0 TCP localhost:omniorb (LISTEN)
sudo lsof -i tcp:8086
#results should be:
#COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
#influxd 762 influxdb 5u IPv6 15012 0t0 TCP *:8086 (LISTEN)
###in the terminal where influxd is running
CRTL+C
#start up the InfluxDB server
sudo systemctl start influxdb
#WAIT A FEW MOMENTS
#make sure it's running
systemctl
#scroll up and down using the arrow keys looking for:
# influxdb.service loaded active running
# type the letter Q to exit
sudo lsof -i tcp:8088
sudo lsof -i tcp:8086
#you should get the same results as above
#run the command line tool in terminal
influx
#if you get to the shell, it's working
quit
#Proceed to grafana install
I'll eventually go back through the entire Node-Red/InfluxDB/Grafana install and clean up the documentation/instructions to where it's clearer and maybe a little more precise.