Deployment Overview of Grafana on Server¶
Prerequisites and Basic Requirements¶
To ensure a successful deployment, the following requirements must be met:
-
Operating System: Compatible with Debian/Ubuntu or RHEL-based distributions (CentOS, Rocky Linux, AlmaLinux).
-
Privileges: Root or sudo access is required for package installation and Docker management.
-
Ports: The following network ports must be open to allow traffic:
-
22/tcp(SSH) -
80/tcp(HTTP) -
443/tcp(HTTPS) -
3000/tcp(Internal Grafana access)
FQDN of the final panel on the hostkey.in domain¶
The application is accessible via a specific subdomain based on the server ID.
| Parameter | Value |
|---|---|
| Prefix | grafana |
| Domain | hostkey.in |
| Full template | grafana{Server_ID_from_Invapi}.hostkey.in |
File and Directory Structure¶
The deployment utilizes the following directory structure for configuration and data persistence:
-
/root/grafana: Contains the application's orchestration files (compose.yml). -
/data/nginx/user_conf.d/: Stores Nginx proxy configurations. -
/data/nginx/nginx-certbot.env: Configuration environment file for the SSL proxy. -
/data/grafana/datasources: Directory used for provisioning Grafana data sources.
Application installation process¶
The application is deployed using a combination of system configuration and Docker Compose:
-
System Preparation: The installer identifies the operating system to configure the firewall (using
ufwon Debian/Ubuntu orfirewalldon RHEL-based systems) and ensures necessary dependencies are present. -
Docker Environment Setup: Docker is installed, and a dedicated Docker volume named
grafana-datais created for persistent storage. -
Configuration Generation: A
compose.ymlfile is generated in/root/grafana/to define the service orchestration. -
Container Orchestration: The application is launched using Docker Compose.
-
Security Initialization: Upon startup, a command is executed within the container to reset the default administrator password for security.
The installed Grafana version is 8.2.6.
Access Rights and Security¶
-
Firewall Configuration:
-
On Debian/Ubuntu systems,
ufwis used to allow traffic on ports 22, 80, and 443. -
On RHEL-based systems,
firewalldis configured to permit public access on ports 80 and 443. -
Container Security: The Grafana container runs with a restart policy of
unless-stopped.
Databases¶
The application uses Docker volumes for data persistence rather than an external database connection in this specific configuration. Data is stored within the grafana-data volume.
Docker Containers and Their Deployment¶
The deployment consists of two primary containers managed via Docker Compose:
nginx¶
-
Image:
jonasal/nginx-certbot:latest -
Ports:
-
80:80 -
443:443 -
Volumes:
-
nginx_secrets:/etc/letsencrypt(External volume for SSL certificates) -
/data/nginx/user_conf.d:/etc/nginx/user_conf.d -
Environment Variables:
-
Restart Policy:
unless-stopped
grafana¶
-
Image:
grafana/grafana-oss:8.2.6 -
Ports:
3000:3000 -
Volumes:
-
/data/grafana/datasources:/etc/grafana/provisioning/datasources -
grafana-data:/var/lib/grafana(External volume) -
Restart Policy:
unless-stopped
Application Update Instructions¶
To update the Grafana application, navigate to the deployment directory and pull the latest images defined in your configuration:
Location of configuration files and data¶
| Component | Path |
|---|---|
| Docker Compose File | /root/grafana/compose.yml |
| Grafana Data Volume | grafana-data (Docker managed) |
| Nginx Configuration | /data/nginx/user_conf.d/ |
| Datasource Provisioning | /data/grafana/datasources |
Available ports for connection¶
-
HTTPS:
443(via Nginx proxy) -
HTTP:
80(for SSL certificate challenges) -
Internal Grafana:
3000
Starting and Stopping the application¶
The application is managed using Docker Compose commands from the /root/grafana directory:
To start the application:
To stop the application:
Proxy Servers¶
The deployment includes an Nginx proxy container (nginx-certbot) that handles SSL termination via Let's Encrypt. It serves as a reverse proxy, forwarding HTTPS traffic from port 443 to the Grafana service running on port 3000.