How install and Configure Prometheus in a Docker Container on AWS EC2 instance.
Prometheus is an open-source tool for metrics collection. It collects the metrics from static or dynamic environment and stores in a time series database.
Prometheus is pull-based system. it sends an HTTP request, a so-called scrape, based on the configuration defined in the prometheus.yml file discussed below. The response to this scrape request is stored and parsed in the storage along with the metrics for the scrape itself.
Prerequisites:
AWS Account with the running AWS EC2-Ubuntu-18 machine.
Step1: SSH into your machine and Install Docker.
Docker is a set of platform as a service (PaaS) products that uses OS-level virtualization to deliver software in packages called containers.Before insatlling anything you have to update your machine “sudo apt-get update”. Now insatll docker.
Step2: Define Configuration File.
We are going to pull Prometheus image from docker.hub. Lets create the configuration file for Prometheus at “/root/prometheus.yml”.
There are two targets for the Prometheus server. First is your localhost and second is your Ubuntu machine public IP.
Step3: Launch Prometheus Container.
The image to be pulled is prom/prometheus from docker.hub and the Prometheus server will run on port number 9090, that is binded to your Ubuntu machine port 9090.
Step4: Configure your security group of AWS EC2 instance.
Select your running Ubuntu machine go to the security group->edit inbound rules->Add Rule. Allow the following ports as shown below.
Step5: Launch the Prometheus Dashboard.
Open your browser and type- http://54.167.231.125:9090/targets
Step6: Setting the Node Exporter.
Node Exporter is a Prometheus exporter for hardware and OS metrics with plug-able metric collectors. It allows to measure various machine resources such as memory, disk and CPU utilization.
Step7: Open Dashboard.
Open the the browser and hit the same url you hit above http://54.167.231.125:9090/targets
Conclusion:
Awesome! we did it. We didthe whole setup with some easy steps.Thanks for reading. Please write the response if we can do it in better way.