InfluxDB and Grafana

![](upload://8yuvKGAeLIFs5YzjJxii6a5YIYD.png)![](upload://qOCXDtu6pOOb5s2gBO37Rq0SfgO.png) The InfluxDB database is a so-called time series database primarily designed to store sensor data and real-time analytics.

The influxdb component makes it possible to transfer all state changes from Home Assistant to an external InfluxDB database.

The first step is to install the InfluxDB packages. If you are not running Fedora, check the installation section for further details.

$ sudo dnf -y install http://influxdb.s3.amazonaws.com/influxdb-0.9.5.1-1.x86_64.rpm

Launch the InfluxDB service.

$ sudo systemctl start influxdb

If everything went well, then the web interface of the database should be accessible at http://localhost:8083/. Create a database home_assistant to use with Home Assistant either with the web interface or the commandline tool influx.

![](upload://1m2xNGOSzIEPUnWstTsdLTJ3jgv.png) InfluxDB web frontend

$ influx
Visit https://enterprise.influxdata.com to register for updates, InfluxDB server management, and monitoring.
Connected to http://localhost:8086 version 0.9.5.1
InfluxDB shell 0.9.5.1
> CREATE DATABASE home_assistant

An optional step is to create a user. Keep in mind to adjust the configuration (add username and password) in the next step if you prefer to go this way.

> CREATE USER "home-assistant" WITH PASSWORD 'password'

To use the influxdb component in your installation, add the following to your configuration.yaml file:

influxdb:
  host: 127.0.0.1

After you restart Home Assistant you should see that the InfluxDB database gets filled. The language to query the database is similar to SQL.

$ influx
[...]
> USE home_assistant
Using database home_assistant
> SELECT * FROM binary_sensor
name: binary_sensor
-------------------
time			domain		entity_id	value
1449496577000000000	binary_sensor	bathroom_door	0
1449496577000000000	binary_sensor	bathroom_window	0
1449496577000000000	binary_sensor	basement_door	0
1449496577000000000	binary_sensor	basement_window	0
1449496684000000000	binary_sensor	bathroom_window	1
[...]

Grafana is a dashboard that can create graphs from different sources including InfluxDB. The installation is simple, and there are detailed steps for many different configurations on the Grafana installation page. For a recent system that is running Fedora:

$ sudo dnf -y install https://grafanarel.s3.amazonaws.com/builds/grafana-2.5.0-1.x86_64.rpm

Start the grafana server.

$ sudo systemctl daemon-reload
$ sudo systemctl start grafana-server
$ sudo systemctl status grafana-server

Login with the username admin and the password admin at http://localhost:3000/login. Now follow the InfluxDB setup instructions.

Now you can start to create dashboards and graphs. You have various options to get the data from the graph. The next image just shows a screenshot of the setting for a temperature sensor.

![](upload://2WzraIOCNKaG1nt8HKzsgmy54s0.png) Grafana settings

If the graph is not showing up in the dashboard you need to adjust the time range in the right upper corner. The graph is created for all state changes recorded by Home Assistant.

![](upload://3Dh6d9zKGKz5sYLbUWXsnYxEMZu.png) Grafana Temperature graph


This is a companion discussion topic for the original entry at https://home-assistant.io/blog/2015/12/07/influxdb-and-grafana/
2 Likes

Could someone help with the historical data from default DB?

Noob question:
I am running HA on a QNAP NAS in a virtual machine with Ubuntu 18.04. Due to limited resources I cannot put another virtual machine with influx Db and another with Grafana. Can I install them on QNAP environment and make them comunicate with HA from virtual machine? How ?

Thank you,

What exactly are you running in that VM? HAOS? Supervised?

If either of those two, use the addons provided.

hass it is . i thought that graphics can take a lot of space and my virtual machine is around 12-13 GB now and limit is 50 and i thought that installing into NAS is better (there i have more than 1tb free).