3

How To Install Grafana 8 on Ubuntu 22.04|20.04|18.04

 2 years ago
source link: https://computingforgeeks.com/how-to-install-grafana-on-ubuntu-linux-2/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
How To Install Grafana 8 on Ubuntu 22.04|20.04|18.04

This is a guide on How to Install Grafana on Ubuntu 22.04|20.04|18.04. Earlier on our infrastructure and systems monitoring series, we covered Installation of Grafana on CentOS 7 server. Then later demonstrated how to monitor Linux systems with Grafana, telegraf, and InfluxDB.

A good infrastructure/systems monitoring can help you avoid a 3 am call by preventing issues from arising.  There are different monitoring tools available, and choosing the right one can be challenging. Also look at How to Install Zabbix Server on Ubuntu.

What is Grafana?

Grafana is an open source, feature rich metrics dashboard and graph editor for Graphite, Elasticsearch, OpenTSDB, Prometheus, and InfluxDB. As an example, when using InfluxDB as your data source, data stored on InfluxDB will be visualized using Grafana Graphs.

Install Grafana 8 on Ubuntu 22.04|20.04|18.04

There are two common ways to Install Grafana on Ubuntu 22.04|20.04|18.04:

  • Using the official APT repository
  • Installing from .deb package

The preferred method is using apt repository since you can easily upgrade to the latest release using the apt package manager for Debian and Ubuntu.

Step 1: Update system

Ensure your Ubuntu system is up to date.

sudo apt update

Step 2: Add Grafana APT repository

Add Grafana gpg key which allows you to install signed packages.

sudo apt-get install -y gnupg2 curl software-properties-common
curl https://packages.grafana.com/gpg.key | sudo apt-key add -

Then install Grafana APT repository:

sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"

If your system is missing , check How to Install add-apt-repository on Debian / Ubuntu

Step 3: Install Grafana on Ubuntu 22.04|20.04|18.04

Once the repository is added, proceed to update your Apt repositories and install Grafana

sudo apt-get update
sudo apt-get -y install grafana

Start Grafana service.

sudo systemctl enable --now grafana-server

The service should now be running.

$ systemctl status grafana-server.service 
● grafana-server.service - Grafana instance
   Loaded: loaded (/usr/lib/systemd/system/grafana-server.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-01-19 13:01:06 UTC; 17s ago
     Docs: http://docs.grafana.org
 Main PID: 15616 (grafana-server)
    Tasks: 10 (limit: 2362)
   CGroup: /system.slice/grafana-server.service
           └─15616 /usr/sbin/grafana-server --config=/etc/grafana/grafana.ini --pidfile=/var/run/grafana/grafana-server.pid --packaging=deb cfg:default.

Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing InternalMetricsService" logger=server
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing TracingService" logger=server
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing UsageStatsService" logger=server
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing CleanUpService" logger=server
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing NotificationService" logger=server
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing provisioningServiceImpl" logger=server
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Initializing Stream Manager"
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="HTTP Server Listen" logger=http.server address=[::]:3000 protoc
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=info msg="Backend rendering via phantomJS" logger=rendering
Jan 19 13:01:10 ubuntu18 grafana-server[15616]: t=2020-01-19T13:01:10+0000 lvl=warn msg="phantomJS is deprecated and will be removed in a future release

Step 4: Open Port on Firewall (Optional)

Grafana default http port is 3000, you’ll need to allow access to this port on the firewall. Ubuntu comes with ufw firewall. For Debian, you can install it using:

sudo apt -y install ufw

Then enable the firewall service:

sudo ufw enable

Open the port on the firewall:

sudo ufw allow ssh
sudo ufw allow 3000/tcp

To allow access only from a specific subnet, use:

sudo ufw allow from 192.168.50.0/24 to any port 3000

Step 5: Access Grafana Dashboard on Ubuntu22.04|20.04|18.04

Access Grafana Dashboard using the server IP address or hostname and port 3000.

Default logins are:

Username: admin
Password: admin

Change Admin Password

Remember to change admin password from default admin. Login and navigate to:

Preferences > Change Password

Grafana Package details:

  • Installs binary to /usr/sbin/grafana-server
  • Installs Init.d script to /etc/init.d/grafana-server
  • Creates default file (environment vars) to /etc/default/grafana-server
  • Installs configuration file to /etc/grafana/grafana.ini
  • Installs systemd service (if systemd is available) name grafana-server.service
  • The default configuration sets the log file at /var/log/grafana/grafana.log
  • The default configuration specifies a sqlite3 db at /var/lib/grafana/grafana.db
  • Installs HTML/JS/CSS and other Grafana files at /usr/share/grafana

The systemd service file and init.d script both use environment vars on the file located at /etc/default/grafana-server.

Next steps include looking at Adding data sources

Other monitoring guides:


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK