# Install Graphite and Grafana on SL7/CentOS7 DAQ node
###### tags: `DAQ`
## Grafana
* [Official Guide](https://grafana.com/docs/installation/rpm/)
## Graphite
* [Worklog on protoDUNE DAQ](https://its.cern.ch/jira/browse/NP04DAQ-129?focusedWorklogId=68866&page=com.atlassian.jira.plugin.system.issuetabpanels%3Aworklog-tabpanel#worklog-68866)
* [Official Guide](https://graphite.readthedocs.io/en/latest/install.html)
### Installing graphite on np04-srv-009.cern.ch
* login as root to np04-srv-009;
* setup http proxy with
```source /nfs/home/np04daq/bin/web_proxy.sh```
* install graphite with
```
yum install -y graphite-web python-whisper python-carbon --enablerepo=epel
```
* Modify `/etc/carbon/carbon.conf` with (moved original directories to "/log/graphite", make sure directories are owned by carbon.carbon):
```
STORAGE_DIR = /log/graphite/carbon/
LOCAL_DATA_DIR = /log/graphite/carbon/whisper/
WHITELISTS_DIR = /log/graphite/carbon/lists/
CONF_DIR = /etc/carbon/
LOG_DIR = /var/log/carbon/
PID_DIR = /var/run/```
```
* Modify `/etc/carbon/storage-schemas.conf` with:
```
[default]
pattern = .*
retentions = 12s:4h, 2m:3d, 5m:8d, 13m:32d, 1h:1y
```
* Start `carbon-cache` and enable it to start after reboot. `systemctl start carbon-cache; systemctl enable carbon-cache`.
* Modify `/etc/graphite-web/local_settings.py` with changes to storage directory (to `/log/graphite`, moved original directories there and kept ownership apache.apache), secret key, and time zone.
```
# secret key generated by:
openssl rand -base64 32
# time zone name found by:
timedatectl | grep "Time zone"
```
* Run database setup script for graphite with (and created np04daq user on prompt):
```
PYTHONPATH=/usr/share/graphite/webapp django-admin syncdb --settings=graphite.settings
```
* started "httpd" and enabled it to start after reboot
* Make sure file ownership is set correctly (e.g. `chown apache.apache /var/lib/graphite-web/graphite.db
`)
* tested sending plain text metric to graphite sever with:
```
PORT=2003
SERVER=np04-srv-009.cern.ch
echo "local.random.diceroll 4 `date +%s`" | nc ${SERVER} ${PORT}
```
* Verified the metrics is shown in `graphite` web frontend by going to http://np04-srv-009.cern.ch/ (follow the "Tree" browser on the left side of the page).