Skip to main content

Installing and Configuring Grafana

Now that you understand Grafana's role in observability, let's get it running on your system. In this lesson, you'll install Grafana and configure it for first use.

Learning Goals:

  • Install Grafana using multiple methods
  • Configure basic server settings
  • Start and verify the Grafana service
  • Access the web interface for the first time

Installation Methods

Grafana can be installed on various platforms. Choose the method that best fits your environment.

Using Package Managers

For most Linux distributions, package managers provide the simplest installation method.

Install on Ubuntu/Debian
# Add Grafana repository
sudo apt-get install -y software-properties-common
sudo add-apt-repository "deb https://packages.grafana.com/oss/deb stable main"
wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -

# Install Grafana
sudo apt-get update
sudo apt-get install grafana

Using Binary Archives

For maximum flexibility or when package managers aren't available, use the standalone binaries.

Install from Binary
# Download and extract
wget https://dl.grafana.com/oss/release/grafana-9.5.2.linux-amd64.tar.gz
tar -zxvf grafana-9.5.2.linux-amd64.tar.gz
cd grafana-9.5.2

# Start Grafana
./bin/grafana-server web
tip

The Docker method is excellent for testing and development. For production, consider using package managers or the binary with proper service management.

Basic Configuration

After installation, configure Grafana by editing the main configuration file.

Understanding grafana.ini

The main configuration file grafana.ini controls all aspects of Grafana's behavior. Key sections include:

/etc/grafana/grafana.ini (excerpt)
[server]
# Protocol (http, https, h2, socket)
protocol = http

# The ip address to bind to, empty will bind to all interfaces
http_addr =

# The http port to use
http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = localhost

[security]
# default admin user, created on startup
admin_user = admin

# default admin password, can be changed before first start of grafana, or in profile settings
admin_password = admin

# used for signing
secret_key = SW2YcwTIb9zpOOhoPsMm

[database]
# You can configure the database details here
type = sqlite3
path = grafana.db

Essential Security Settings

Before starting Grafana in production, update these critical security settings:

Security Configuration
[security]
admin_user = admin
# Change this before first startup!
admin_password = your_secure_password_here

# Force users to change password after first login
force_password_change = true

# Disable gravatar profile images
disable_gravatar = true
warning

Never leave the default admin/admin credentials in production! Change the admin password before starting Grafana for the first time.

Starting Grafana Service

System Service Management

For production systems, run Grafana as a service.

Start Grafana Service
# Enable and start the service
sudo systemctl daemon-reload
sudo systemctl enable grafana-server
sudo systemctl start grafana-server

# Check status
sudo systemctl status grafana-server

Manual Startup

For development or testing, you can start Grafana manually:

Manual Startup
# From binary installation
./bin/grafana-server

# With custom config
./bin/grafana-server --config=/path/to/grafana.ini

# With specific home path
./bin/grafana-server --homepath="/usr/share/grafana"

Verifying Installation

After starting Grafana, verify it's running correctly.

Check Service Status

Verify Service
# Check if Grafana is running
sudo systemctl status grafana-server

# Check listening ports
sudo netstat -tulpn | grep 3000

# Or using ss
sudo ss -tulpn | grep 3000

Access the Web Interface

Open your browser and navigate to http://localhost:3000. You should see the Grafana login page.

Test HTTP Access
# Test with curl
curl -I http://localhost:3000

# Expected response:
# HTTP/1.1 200 OK
# Cache-Control: no-cache
# Content-Type: text/html; charset=UTF-8

Verify Basic Functionality

Once logged in (using the credentials from your configuration), you should see the Grafana home dashboard. Try creating a test data source to verify everything works.

note

If you can't access Grafana on port 3000, check your firewall settings and ensure the service is running. Some systems may block non-standard ports by default.

Common Pitfalls

  • Default Credentials: Forgetting to change admin password before exposing to network
  • Port Conflicts: Other services already using port 3000 (common with development servers)
  • Firewall Issues: Forgetting to open port 3000 in system firewall
  • Permission Problems: Incorrect file permissions on configuration files or database
  • Memory Limits: Insufficient memory for Grafana to start (minimum 512MB recommended)

Summary

You've successfully installed Grafana using multiple methods, configured essential security settings, started the service, and verified it's running correctly. Grafana is now ready for you to explore the interface and connect data sources in the next lesson.

Grafana Installation and Configuration – Quick Check

What is the default port Grafana runs on?

Question 1/5