Part 4: Deploy Grafana Dashboard to AWS EC2

Rayhan Rafiud Darojat
3 min readFeb 21, 2020

--

In this part we will learn how to be devops haha ✌️, deploying grafana local to server with AWS EC2

Before we go, i hope you have a aws account, and have a credit for creating instances.

Create New Instance

https://console.aws.amazon.com/ec2/v2/home?region=us-east-1

Select Ubuntu Server 16.04 LTS

In configure security add HTTP, HTTPS and Custom TCP

Create new key.pem

  • Chmod 400 grafana-server.pem
  • Create file name login.sh
ssh -i “pemname.pem” ubuntu@domainnameexample : ssh -i "grafana-server.pem" ubuntu@ec2-3-23-161-56.compute-1.amazonaws.com
  • Change permission login.sh file
sudo chmod 755 login.sh
  • Login AWS EC2 with
./login.sh

Setting Nodejs and Docker

  • Install nodejs and npm
sudo apt update
sudo apt install nodejs
sudo apt install npm
  • Install nginx
sudo apt install nginx
  • And check ip address
  • Install Docker
sudo apt-get updatesudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt updatesudo apt-get install docker-ce docker-ce-cli containerd.iosudo docker --version
  • Install docker-compose
sudo curl -L “https://github.com/docker/compose/releases/download/1.25.4/docker-compose-$(uname -s)-$(uname -m)” -o /usr/local/bin/docker-composesudo chmod +x /usr/local/bin/docker-composedocker-compose --version
  • Clone your project
git clone https://github.com/rafiudd/bigquery-api-nodejscd bigquery-api-nodejsnpm install
  • Setting credentials path
export GOOGLE_APPLICATION_CREDENTIALS="[PATH]"example : export GOOGLE_APPLICATION_CREDENTIALS="/home/bigquery-api-nodejs/key.json"
  • Last bro 😍, but not least run docker compose
sudo docker-compose up -d
  • And check the ip with port 3000

yeayyy ,grafana is successfully running in server️ ✌️

  • Login with default username and password
username: admin
password: admin

--

--