## Graphite-Grafana-Install #@ MaartenDeBoer.nl, 2016-10-14 #= Installation notes for Graphite-Grafana DOC: - Graphite_Grafana_Quick_Start_v1.4.pdf by Christopher Madden, NetApp (7 September, 2015) - http://graphite.wikidot.com/ - http://docs.grafana.org/ * At RedHat (CentOS7) installation + Disable SELinux # vi /etc/sysconfig/selinux SELINUX=disabled # reboot + Modify Firewall Rules - For RHEL 6 use the following commands: iptables -I INPUT -p tcp --dport 443 -j ACCEPT iptables -I INPUT -p tcp --dport 81 -j ACCEPT iptables -I INPUT -p tcp --dport 2003 -j ACCEPT service iptables save + Install Graphite and Prerequisites - Online / Internet based installation - When connected via proxy, configure; export http_proxy=http://proxy.myproxy.com:#### export https_proxy=https://proxy.myproxy.com:#### - RPM packages # yum install -y python-devel mod_wsgi pycairo dejavu-sans-fonts gcc git pytz python-memcached nc net-tools lsof unzip - Python packages Install pip, and then use pip to install prerequisite Python packages: # cd /tmp # curl -O https://bootstrap.pypa.io/get-pip.py # python get-pip.py # pip install pyparsing # pip install 'Twisted<12.0' # pip install 'django<1.5' "Error about Django 1.4 does not support wheel" can be ignored ?!? # pip install 'django-tagging==0.3.6' - Graphite components from source Graphite and PIP have packages in EPEL but as of today (21-Aug-2015) each has issues installing on RHEL. For this reason we will install from source. Because all Graphite components are Python code installing from source is not much more difficult than from a package. Execute the following commands: # cd /tmp # git clone https://github.com/graphite-project/graphite-web.git # git clone https://github.com/graphite-project/carbon.git # git clone https://github.com/graphite-project/whisper.git # cd whisper; git checkout 0.9.13-pre1; python setup.py install # cd ../carbon; git checkout 0.9.13-pre1; python setup.py install # cd ../graphite-web; python check-dependencies.py; git checkout 0.9.13pre1; python setup.py install - Copy the configuration files from the example files: # cd /opt/graphite/conf # cp carbon.conf.example carbon.conf # cp graphite.wsgi.example graphite.wsgi # cp storage-schemas.conf.example storage-schemas.conf # cp storage-aggregation.conf.example storage-aggregation.conf # cd /opt/graphite/webapp/graphite/ # cp local_settings.py.example local_settings.py # cp /opt/graphite/examples/example-graphite-vhost.conf /etc/httpd/conf.d/graphite-vhost.conf + Configure Graphite - Configure Carbon cache # vi /opt/graphite/conf/carbon.conf MAX_CREATES_PER_MINUTE = 600 - Configure connect Schema definitions for Whisper files # vi /etc/carbon/storage-schemas.conf [collectd] pattern = ^collectd\.* retentions = 10s:1d,1m:7d,10m:1y [domotica] pattern = ^solar\.* retentions = 10m:5y ! Mind the "\" before ".*" - When init.d script is not in /etc/init.d/ # cp /tmp/carbon/distro/redhat/init.d/carbon-cache /etc/init.d/ # chmod 755 /etc/init.d/carbon-cache # chkconfig carbon-cache on # service carbon-cache start - Configure graphite-web # vi /opt/graphite/webapp/graphite/local_settings.py change to (but fill with your own random characters!) SECRET_KEY = TIME_ZONE = 'Europe/Amsterdam' # django-admin.py syncdb --pythonpath /opt/graphite/webapp --settings graphite.settings "yes" "root" "e-mail-address" # chown -R apache:apache /opt/graphite/storage - Configure Apache # vi /etc/httpd/conf/httpd.conf Listen 81 ServerName # vi /etc/httpd/conf.d/graphite-vhost.conf change to Header set Access-Control-Allow-Origin "*" Header set Access-Control-Allow-Methods "GET, OPTIONS" Header set Access-Control-Allow-Headers "origin, authorization, accept" Order deny,allow Allow from all change to for RHEL 6 Options All AllowOverride All # chkconfig httpd on # service httpd start;sleep 15; service httpd restart + Install Grafana - Online / Internet based installation # vi /etc/yum.repos.d/grafana.repo [grafana] name=grafana baseurl=https://packagecloud.io/grafana/stable/el/6/$basearch repo_gpgcheck=1 enabled=1 gpgcheck=1 gpgkey=https://packagecloud.io/gpg.key https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana sslverify=1 sslcacert=/etc/pki/tls/certs/ca-bundle.crt # yum install –y grafana + Configure Grafana # cd /etc/grafana # openssl req -x509 -newkey rsa:2048 -keyout cert.key -out cert.pem -days 3650 -nodes # vi /etc/grafana/grafana.ini ;protocol = http change to protocol = https ;http_port = 3000 change to http_port = 443 # https certs & key file ;cert_file = ;cert_key = change to # https certs & key file cert_file = /etc/grafana/cert.pem cert_key = /etc/grafana/cert.key default_theme = light # setcap 'cap_net_bind_service=+ep' /usr/sbin/grafana-server # chkconfig --add grafana-server # chkconfig grafana-server on # service grafana-server start + Verify & update - Carbon # echo "test.metric 50 `date +%s`" | nc 127.0.0.1 2003 # ls -l /opt/graphite/storage/whisper/test - Graphite Open webbrowser: http://:81 - Grafana Open webbrowser: https://:443 Admin > Users Modify admin password Add with Admin rights Data Sources> Add datasource> Name = Graphite Type = Graphite Url = http://127.0.0.1:81 Access = proxy Dashboard> Home> "New dashboard" Add Panel > Graph with the "test.metric" Building time ~ 2hr -.-