Install and configure a Grafana server

From techdocs
Revision as of 16:16, 19 August 2022 by Jbc (talk | contribs)
Jump to navigation Jump to search
  • Create a bare-bones nw server - no host-classes needed, just an IP address and host
  • Add the Grafana repository to /etc/apt/sources.list.d/grafana.list:

deb https://packages.grafana.com/enterprise/deb stable main

  • Grab the Grafana gpg key to allow installation from the repository:
apt install -y apt-transport-https software-properties-common wget gnupg
wget -q -O - https://packages.grafana.com/gpg.key
cat gpg.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/grafana.gpg
  • Install the Grafana package:

apt update && apt install grafana-enterprise

  • Install sqlite3:

apt install sqlite3

  • Install sqlite3 datasource plugin for grafana:

grafana-cli plugins install frser-sqlite-datasource

  • (Re)tart the service:

systemctl restart grafana-server

  • Create schema.sql:
CREATE TABLE stats
(
  ts integer not null,
  hostname text not null,
  metric text not null,
  value real not null,
  hosttype text not null
);
  • Create grafana database:
sqlite3 /var/lib/grafana/data.db < schema.sql
chown grafana. /var/lib/grafana/data.db
  • Install snmpget:

apt install snmp

  • Default snmp mibs seem to be broken out of the box; lots of errors from snmpget.
  • Had to copy some files from a working box:
 scp nw-syd-monitor1:/usr/share/snmp/mibs/IANA-ADDRESS-FAMILY-NUMBERS-MIB.txt /usr/share/snmp/mibs/
 scp nw-syd-monitor1:/usr/share/snmp/mibs/RFC-1215.txt /usr/share/snmp/mibs/
 mv /usr/share/snmp/mibs/UCD-SNMP-MIB.txt /usr/share/snmp/mibs/UCD-SNMP-MIB-old.txt
 scp nw-syd-monitor1:/usr/share/snmp/mibs/UCD-SNMP-MIB.txt /usr/share/snmp/mibs/
    • I don't know why, and I don't like it.
  • Create script to populate the db - /usr/local/infrastructure/bin/getstats.sh (look in ~jbc/Projects/nw-k17-grafana)
  • Or roll your own. to use snmpget and/or nagios-stat to gather load / usercount and populate the table.
  • Hosttype column to distinguish different classes of hosts, to populate the different rows in grafana
  • Prune stats older than 60 minutes at the end of the script
  • Copy in nagios-stat script from acoustics:

scp acoustics:/import/acoustics/1/status/infoterm/nagios-stat /usr/local/infrastructure/bin

  • The need for nagios-stat will go away once everything is new-world and we can just use snmp

  • Once that's all set up, you can start using Grafana: http to port 3000 on the machine, and log in. Default password is admin:admin - you'll be prompted to change it immediately.