21 C
Texas

How To Install Graphite and Graphite Web On Ubuntu 20.04

Today we are going to learn that how to install Graphite & Graphite Web on Ubuntu 20.04. Before proceeding towards the installation process, let’s have a short introduction on it.

Introduction:

Graphite is an open source monitoring platform used for the purpose of data visualization. Graphite has front-end and backend that can be used to get and store the data from numeric time-series to the graph format. Main purpose of graphite is to store numeric time-series data and provide the graph of the stored data when requested. So, let’s move towards the installation process.

Step 1: Update Your System

As usual we do update your system to have the latest packages installed. To do so run the below command.

sudo apt update && sudo apt upgrade -y
- Advertisement -

Once, the update finished reboot your system and move towards the next step.

sudo reboot

Step 2: Install Docker Container Engine on Ubuntu 20.04

Type the following command after the system reboot in your terminal.

sudo apt -y install vim apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Now, import the docker GPG key using the below command.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

And then, add the Docker CE repository in Ubuntu system by hitting the given command.

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Finally, fire the below command to install Docker CE on Ubuntu 20.04 server.

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io

Once, the installation finished add your user to the docker group. To do so, fire the given command in your terminal.

sudo usermod -aG docker $USER
newgrp docker

Make sure the installation is successfull.

[email protected]:~$ docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.13
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 5.4.0-54-generic
Operating System: Ubuntu 20.04.1 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.914GiB
Name: Ubuntu20
ID: AAWZ:QW4H:GBZD:BTEX:N3L7:SMPQ:JATK:7KVM:HNCZ:DNC6:WYFW:FQAP
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

Also, verify that the service is in running status before further proceeding.

[email protected]:~$ systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor prese>
Active: active (running) since Mon 2020-11-30 02:51:53 PKT; 14min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 1252 (dockerd)
Tasks: 11
Memory: 99.5M
CGroup: /system.slice/docker.service
└─1252 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/con>
نومبر 30 02:51:50 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:50.816377373+>
نومبر 30 02:51:50 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:50.816385494+>
نومبر 30 02:51:50 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:50.816393200+>
نومبر 30 02:51:50 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:50.816775170+>
نومبر 30 02:51:52 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:52.057634448+>
نومبر 30 02:51:52 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:52.114419939+>
نومبر 30 02:51:53 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:53.017677598+>
نومبر 30 02:51:53 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:53.092645598+>
نومبر 30 02:51:53 Ubuntu20 systemd[1]: Started Docker Application Container En>
نومبر 30 02:51:53 Ubuntu20 dockerd[1252]: time="2020-11-30T02:51:53.490281794+>
lines 1-21/21 (END)

Step 3: Running Graphite in Docker Container

As we’ve finished the installation of docker engine, now we’ll start docker container for Graphite. Here we’ll use the official docker repository for graphite.

Get the latest docker image by typing

[email protected]:~$ docker pull graphiteapp/graphite-statsd
Using default tag: latest
latest: Pulling from graphiteapp/graphite-statsd
df20fa9351a1: Pull complete
a30ee9926b20: Pull complete
51a4bd789783: Pull complete
9eb78f4a78c8: Pull complete
Digest: sha256:aaec5e5daadad64efb8039dd128e89dc6ac95bc129553427fca980a049d1fb40
Status: Downloaded newer image for graphiteapp/graphite-statsd:latest
docker.io/graphiteapp/graphite-statsd:latest

This image will contain the following parts.

  • Nginx (Reverse proxy the graphite dashboard)
  • Graphite(Front-end)
  • Carbon(Back-end)
  • Statsd(UDP based backend proxy)

Following default mapped ports will be used.

HostContainerService
8080nginx
20032003carbon reciever – plaintext
20042004carbon reciever – pickle
20232023carbon aggregator – plaintext
20242024carbon aggregator – pickle
80808080Graphite internal gunicorn port
81258125statsd
81268126statsd admin

Graphite and Statsd should be handled carefully as they are very complex to setup. The docker image downloaded above help us to run & collect the stats in few minutes.

To see the available images type

[email protected]:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
graphiteapp/graphite-statsd latest 976c24bf0bc6 4 weeks ago 723MB

Now, create the following directories on the host system for persistent data storage.

sudo mkdir -p /data/graphite/{data,logs,conf,statsd_config}

Make sure to set the correct timezone and then run the following commands.

docker run -d \
--name graphit \
--restart=always \
-p 80:80 \
-p 2003-2004:2003-2004 \
-p 2023-2024:2023-2024 \
-p 8125:8125/udp \
-p 8126:8126 \
-v /data/graphite/data:/opt/graphite/storage \
-v /data/graphite/conf:/opt/graphite/conf \
-v /data/graphite/statsd_config:/opt/statsd/config \
-v /data/graphite/logs:/var/log \
-e GRAPHITE_TIME_ZONE='Asia/Karachi' \
graphiteapp/graphite-statsd

Verify the status of graphite container

[email protected]:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
420150f994b9 graphiteapp/graphite-statsd "/entrypoint" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, 0.0.0.0:2003-2004->2003-2004/tcp, 2013-2014/tcp, 8080/tcp, 0.0.0.0:2023-2024->2023-2024/tcp, 0.0.0.0:8126->8126/tcp, 8125/tcp, 0.0.0.0:8125->8125/udp graphit

If you face any error, refer to the logs

docker logs -f graphite

Output:

,,..
30/11/2020 01:23:58 :: [tagdb] Tagged carbon.aggregator.4a26c4c0f746-a.destinations.127_0_0_1:2004:None.attemptedRelays, carbon.aggregator.4a26c4c0f746-a.bufferedDatapoints in 0.021245479583740234
30/11/2020 01:24:06 :: [listener] MetricLineReceiver connection with 127.0.0.1:57472 established
30/11/2020 01:24:06 :: [listener] MetricLineReceiver connection with 127.0.0.1:57472 closed cleanly
30/11/2020 01:24:08 :: [tagdb] Tagging carbon.agents.4a26c4c0f746-a.errors
30/11/2020 01:24:08 :: [tagdb] Tagged carbon.agents.4a26c4c0f746-a.errors in 0.15246272087097168
30/11/2020 01:24:16 :: [listener] MetricLineReceiver connection with 127.0.0.1:57476 established
30/11/2020 01:24:16 :: [listener] MetricLineReceiver connection with 127.0.0.1:57476 closed cleanly
30/11/2020 01:24:26 :: [listener] MetricLineReceiver connection with 127.0.0.1:57478 established
30/11/2020 01:24:26 :: [listener] MetricLineReceiver connection with 127.0.0.1:57478 closed cleanly

As by default, statsd is listening to 8125 UDP port,you can change it to tcp port if you want. To do so, you’ve to set the environment variable STATSD_INTERFACE to TCP port while running the container.

Step 4: Access Graphite Web Dashboard

Access the Graphite web interface by typing server IP.

How To Install Graphite & Graphite Web On Ubuntu 20.04

Use the pre-defined credentials to login.

User:root
Pass:root

For security reasons, change the default credentials, by typing IP/admin/auth/user/1/

How To Install Graphite & Graphite Web On Ubuntu 20.04

You’ll get success message of password change.

So,this is how you can install graphite & graphite web on Ubuntu 20.04

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article