Prometheus is :
- Open source monitoring and alerting toolkit, originally build by sound cloud.
- Currently managed under CNCF.
- Scrapes metrics from servers which are exposing metrics data.
- Written in Go.
The features of prometheus are:
- Easy to configure and deploy
- Using TSDB (Time Series Database)
- Multi dimensional data model with time series data identified by metric name and key / value pair
- Targets are discovered via service discovery or static configuration.
- Data collection over HTTP
To run prometheus ecosystem, following things are required:
- Prometheus server for scraping metrics and stores as time series data
- Push gateway for identifying short lived jobs.
- Exporters which expose their metrics to an HTTP endpoint and prometheus accesses these endpoint to scrape those data.
- Alertmanager to handle alerts
In prometheus ecosystem following things are generally used:
- Prometheus server to scrape data and store in time series.
- Push gateway for gathering metrics from shot lived jobs.
- Client libraries for instrumenting application code.
- Exporters like node exporter which expo
- Grafana for data visualization
Prometheus gathers metrics from jobs configured in prometheus configuration and stores all scraped data locally and run rules over this data to either aggregate and record new time series from existing data or generated alerts. Grafana or any other data visualization toolo
Prometheus - 9090
Grafana - 9091
cAdvisor - 9092
Pushgateway - 9093
Node Exporter - 9100
git clone https://github.com/pgaijin66/Infrastructure-Monitoring.git
If you are working on a vanilla server. you might want to run the bootstrapping script. This will check your operating system and install all the necessary libraries and packages along with docker and docker-compose.
If you have already installed docker and docker-compose you can ignore this step.
cd Infrastructure-Monitoring
sudo chmod +x Bootstrap/bootstrap.sh
sudo bash Bootstrap/bootstrap.sh
Add username and password for grafana in infra-monitoring.yml
file
- GF_SECURITY_ADMIN_USER=devops
- GF_SECURITY_ADMIN_PASSWORD=iamhappytoday
Make sure you are in directory which has infra-monitoring.yml
and run following commands.
sudo docker-compose -f infra-monitoring.yml up -d
NOTE: Make sure you have ports opened in firewall. If this monitoring is cirtical then, make sure you only allow access through VPN.
To access monitoring solutions, You can go to
http://<IP_ADDRESS_OF_SERVER>:<PORT>
To access prometheus
http://<IP_ADDRESS_OF_SERVER>:9090
To access Grafana
http://<IP_ADDRESS_OF_SERVER>:9091
To access Cadvisor
http://<IP_ADDRESS_OF_SERVER>:9092
When loggen into Grafana, Do following :
- On bottom left there is a gear icon, click that and click add data source and select prometheus.
- Add your prometheus URL
- Access: SERVER and leave everything as default.
- Click Save and Test.
Now, to add dashboard Click Dashboard > Manage > Import . You can import json file or just write "1860" which is the code for node exporter dashboard.
You can follow this Youtube Link if you are not sure how to add it. https://www.youtube.com/watch?v=xvKR1rqX74M
Make sure you are in directory which has infra-monitoring.yml
and run following commands.
sudo docker-compose -f infra-monitoring.yml down