Install and configure a Grafana server: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
* Grab the Grafana gpg key to allow installation from the repository: | * Grab the Grafana gpg key to allow installation from the repository: | ||
< | <pre>apt install -y apt-transport-https software-properties-common wget gnupg | ||
apt install -y apt-transport-https software-properties-common wget gnupg | |||
wget -q -O - https://packages.grafana.com/gpg.key | wget -q -O - https://packages.grafana.com/gpg.key | ||
cat gpg.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/grafana.gpg</pre> | |||
cat gpg.key | gpg --dearmor -o /etc/apt/trusted.gpg.d/grafana.gpg | |||
</ | |||
* Install the Grafana package: | * Install the Grafana package: | ||
<code>apt update && apt install grafana-enterprise</code> | <code>apt update && apt install grafana-enterprise</code> | ||
* | * Install sqlite3: | ||
<code> | <code> apt install sqlite3</code> | ||
<code> | |||
* Install sqlite3 datasource plugin for grafana: | |||
<code>grafana-cli plugins install frser-sqlite-datasource</code> | |||
*(Re)tart the service: | |||
<code>systemctl restart grafana-server</code> | |||
* Create schema.sql: | |||
<pre><nowiki> | |||
CREATE TABLE stats | |||
( | |||
ts integer not null, | |||
hostname text not null, | |||
metric text not null, | |||
value real not null, | |||
hosttype text not null | |||
);</nowiki></pre> | |||
* Create grafana database: | |||
<pre> | |||
sqlite3 /var/lib/grafana/data.db < schema.sql | |||
chown grafana. /var/lib/grafana/data.db</pre> | |||
* Install snmpget: | |||
<code>apt install snmp</code> | |||
* 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: | |||
<pre> | |||
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/</pre> | |||
** 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 | |||
</code> | * Prune stats older than 60 minutes at the end of the script | ||
* Copy in nagios-stat script from acoustics: | |||
<code>scp acoustics:/import/acoustics/1/status/infoterm/nagios-stat /usr/local/infrastructure/bin</code> | |||
* 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. |
Revision as of 16:16, 19 August 2022
- 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.