Time Series Database: Difference between revisions

From Playful Exploration
Jump to navigation Jump to search
No edit summary
 
(2 intermediate revisions by 2 users not shown)
Line 6: Line 6:
:[http://opentsdb.net/overview.html OpenTSDB]
:[http://opentsdb.net/overview.html OpenTSDB]
:[http://gridengine.eu/index.php/other-stories/229-installing-influx-db-on-raspberry-pi-2-2015-10-18 influx for Raspberry Pi]
:[http://gridengine.eu/index.php/other-stories/229-installing-influx-db-on-raspberry-pi-2-2015-10-18 influx for Raspberry Pi]
:[https://www.influxdata.com/time-series-platform/ Influx is part of the "TICK" stack]
:[http://gridengine.eu/index.php/other-stories/230-installing-grafana-on-raspberry-pi-2-2015-10-24 view influx using grafana on RPi]
:[http://gridengine.eu/index.php/other-stories/230-installing-grafana-on-raspberry-pi-2-2015-10-24 view influx using grafana on RPi]
:[http://www.philipotoole.com/tag/influxdb/ Howto article]
:[http://www.philipotoole.com/tag/influxdb/ Howto article]
Line 18: Line 19:
  */5 * * * * M=`df|grep /dev/root|awk '{print $4}'`&&curl -i -XPOST 'http://localhost:8086/write?db=rocket' --data-binary "cpu,host=rpi2 mem_available=$M"
  */5 * * * * M=`df|grep /dev/root|awk '{print $4}'`&&curl -i -XPOST 'http://localhost:8086/write?db=rocket' --data-binary "cpu,host=rpi2 mem_available=$M"


* M=`...` : executes the back-quoted command and assigns he output to variable M
* M=`...` : executes the back-quoted command and assigns the output to variable M
* df : dumps some disk info, which gets piped into grep
* df : dumps some disk info, which gets piped into grep
* grep /dev/root : finds the line containing '/dev/root' which gets piped into awk
* grep /dev/root : finds the line containing '/dev/root' which gets piped into awk
Line 59: Line 60:
  /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/bin/grafana-server -homepath /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/
  /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/bin/grafana-server -homepath /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/


Navigate to http://chaospage.com/grafana , ensure the grafana web ui shows up.
Navigate to https://www.playfulexploration.com/grafana/ , ensure the grafana web ui shows up.


Then restart the pi and try again ensuring that the grafana webservice starts automatically.
Then restart the pi and try again ensuring that the grafana webservice starts automatically.
  restart
  restart

Latest revision as of 23:27, 28 October 2016

The abbreviation TSDB is commonly used for Time Series Database.

Links:

RRDTool
OpenTSDB
influx for Raspberry Pi
Influx is part of the "TICK" stack
view influx using grafana on RPi
Howto article

InfluxDB Write Examples

Write available disk space every 5 min

Crontab lets you edit the task scheduler. Run crontab as super user to edit the task scheduler of root. That way the running task will never be under privileged.

sudo crontab -e

Add this line to the end:

*/5 * * * * M=`df|grep /dev/root|awk '{print $4}'`&&curl -i -XPOST 'http://localhost:8086/write?db=rocket' --data-binary "cpu,host=rpi2 mem_available=$M"
  • M=`...` : executes the back-quoted command and assigns the output to variable M
  • df : dumps some disk info, which gets piped into grep
  • grep /dev/root : finds the line containing '/dev/root' which gets piped into awk
  • awk '{print $4}' : parses the line and outputs the 4th (space separated?) string which is the number we are looking for
  • &&curl : runs curl if the previous command (assignment to M) succeeded
  • curl -i -XPOST : writes data via POST request
  • 'http://localhost:8086/write?db=rocket' - target server is an influxdb server at 'localhost:8086', the target database is named 'rocket'
  • --data-binary "cpu,host=rpi2 mem_available=$M" : the measurement is called 'cpu', the value is called 'mem_available' and is tagged with the optional key and value host=rpi2

RPI2 Grafana Setup notes

Grafana by default runs on port 3000 root i.e. http://chaospage.com:3000/ . In order to reverse proxy this with nginx to http://chaospage.com/grafana do this:

Edit the grafana ini file:

nano /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/conf/defaults.ini

Change root_url to:

root_url = %(protocol)s://%(domain)s:%(http_port)s/grafana

Edit nginx configuration:

nano /etc/nginx/sites-enabled/default

Add this location section:

location /grafana {
      proxy_pass         http://localhost:3000;
      rewrite  ^/grafana/(.*)  /$1 break;
      proxy_set_header   Host $host;
}

Restart nginx service there should be no errors:

service nginx restart

To have grafana server start automatically add it to rc.local:

nano /etc/rc.local

Add this line:

/root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/bin/grafana-server -homepath /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/ &

Try it all out by starting grafana from the commanline:

/root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/bin/grafana-server -homepath /root/.gvm/pkgsets/go1.5/global/src/github.com/grafana/grafana/

Navigate to https://www.playfulexploration.com/grafana/ , ensure the grafana web ui shows up.

Then restart the pi and try again ensuring that the grafana webservice starts automatically.

restart