Install Docker
- Uninstall previous docker packages if installed
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
- Setup Docker's
apt
repository
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
- Install Latest Docker Packages
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Add User to Docker Group
sudo usermod -aG docker your_username
Install Grafana
Docker Compose
- Create a
docker-compose.yml
file with this content
version: '3.8'
services:
grafana:
image: grafana/grafana-oss
container_name: grafana
restart: unless-stopped
ports:
- '3000:3000'
environment:
- GF_SERVER_ROOT_URL=http://grafana.aadarshadhakal.com.np/
volumes:
- grafana-storage:/var/lib/grafana
volumes:
grafana-storage: {}
- Run containers
docker compose up -d
This runs the services defined inside docker-compose.yml
file in detached mode.
Setup Nginx Reverse Proxy
-
Install Nginx
sudo apt update && sudo apt install nginx
-
Install certbot for SSL certificatr
sudo apt install certbot python3-certbot-nginx
-
Create a new nginx web server
/etc/nginx/sites-available/<YOURDOMAIN>
with the following content.
server {
server_name <YOURDOMAIN>;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_buffering off;
proxy_pass http://127.0.0.1:3000;
}
}
-
Enable the newly created nginx web server
sudo ln -s /etc/nginx/sites-available/<YOURDOMAIN> /etc/nginx/sites-enabled/<YOURDOMAIN>
-
Install SSL certificate using Certbot
sudo certbot run -d <YOURDOMAIN> -d www.<YOURDOMAIN>
Default Username and Password is
admin
andadmin
Install Influx DB
- Create a
docker-compose.yml
file with the following contents
version: '3.8'
services:
influxdb2:
image: influxdb:2
restart: always
ports:
- 8086:8086
environment:
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME_FILE: /run/secrets/influxdb2-admin-username
DOCKER_INFLUXDB_INIT_PASSWORD_FILE: /run/secrets/influxdb2-admin-password
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN_FILE: /run/secrets/influxdb2-admin-token
DOCKER_INFLUXDB_INIT_ORG: <YOUR ORGANIZATIO NAME>
DOCKER_INFLUXDB_INIT_BUCKET: <BUCKET NAME>
secrets:
- influxdb2-admin-username
- influxdb2-admin-password
- influxdb2-admin-token
volumes:
- type: volume
source: influxdb2-data
target: /var/lib/influxdb2
- type: volume
source: influxdb2-config
target: /etc/influxdb2
secrets:
influxdb2-admin-username:
file: .env.influxdb2-admin-username
influxdb2-admin-password:
file: .env.influxdb2-admin-password
influxdb2-admin-token:
file: .env.influxdb2-admin-token
volumes:
influxdb2-data:
influxdb2-config:
- Execute this command from the directory where your
docker-compose.yml
file is located.
echo "<USERNAME>" > .env.influxdb2-admin-username
echo "<PASSWORD>" > .env.influxdb2-admin-password
echo "<TOKEN>" > .env.influxdb2-admin-token
*Replace USERNAME, PASSWORD and TOKEN
- Start services
docker compose up -d
Add Influx DB as Data Source in Grafana
- Login to grafana dashboard
- From the drawer menu go to Data Sources
- Click on Add New Data Source button and select InfluxDB
- Select FLUX as the Query Language
- Add InfluxDB server url and port in the URL text field
- Enable Skip TLS Verify
- Enter Organization Name, Bucket Name and Token and click Save and Test
To get API token, in InfluxDB dashboard go to Load Data > API Tokens > Generate API Token or You can use the token provided during InfluxDB installation