Monitoring Docker Container Metrics Using cAdvisor Prometheus and Grafana

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello friends welcome back to my channel and today we are back with another another interesting topic uh this is more related to monitoring docker container metrics and its performance using c advisor prometheus and grafana okay so in this tutorial we are going to see how we can write the complete grafana prometheus docker compose file okay and which will also include a node exporter and c advisor services so if you don't know what is c advisor it's a short form of container advisor okay so what it actually does is it provides us the complete information on the resource usage and performance characteristics of the containers running on the node okay so this can be easily integrated with prometheus so that's why we are going to use prometheus in this uh tutorial okay so how this setup would be like we'll have a prometheus container running okay and we will have a node exporter and also we will have c advisor okay and we will have uh the prometheus.aml file uh which will be scrapping the content for node exporter and c advisor in it okay and we'll be running all these uh prometheus node exporter c advisor and even grafana as uh containers on docker okay so docker will be the base or the node in which it will be running and we'll have grafana at the end where we'll be getting all the output as a dashboard in grafana okay so that's how it will be in this uh tutorial by end of this tutorial what you will be getting as an output so just to have a quick view on this uh docker compose file like grafana prometheus docker compose file what uh we'll be writing which will usually have four section okay the first section will be on the prometheus service so we'll be writing the prometheus uh volumes or uh command and ports and everything i will show you this in the sublime text editor okay so and we'll have a one section for node exporter and we'll have one section for c advisor and at the end we'll have something for grafana as well okay so and we'll also have a prometheus.yaml file where we'll be configuring the scrapping of the content okay so before i get into the actual uh process if you haven't subscribed to my channel or you're new to my channel kindly check my videos i am sure you'll be liking it if you have feedbacks please give the comments okay so kindly subscribe to my channel like this video share and comment so now to get started if you see this is the uh docker compose file which i'll be using for this tutorial so i have shown a lot of tutorial on docker compose file so i'm not going to go step by step writing but i will just uh tell you what we have it here so we have one service called prometheus where we are using the image for prometheus and we have a volume where i will be using this prometheus.yaml file from the host machine which will be mapped to the container prometheus container okay so this yaml file will have the scrapping of the content for prometheus server and also the node exporter and also from the c advisor okay so what we are saying is the command like uh to run this prometheus using this uh prometheus.aml file okay and the port for prometheus is nine zero nine zero okay and i have another service for node exporter and the image is uh from hyphen not exporter and the port for node exporter is nine one zero zero okay so i'm mapping both from the no uh host machine and also from the container and the c advisor as i said it's a container advisor uh package where i'm using the google c advisor image again the port will be used for 8080 and the volumes has to be mapped these are some demands for docker which has to be mapped okay so in order to understand more about c advisor you can go to this uh github link i will link it in the video's description so where you can see what is the uh you know uh process or how we can easily start the container 4c advisor in docker so what all the volumes you can map to get what kind of data to be scrapped okay so i'll link this tutorial page in the video description so you can have a look there so if once we have uh not exporter c advisor and prometheus running the next part is we should have a grafana so that we can display the output in the grafana dashboard okay so for grafana i'm using the image grafana and the user uh for grafana okay and i'm going to set the environment variable where i want to set the password for default login so i'm just setting the password as password okay and i'm going to say that this uh grafana container is dependent on prometheus so which is uh this service right so prometheus service and the port for grafana is 3000 okay so this is the whole docker compose file i will share the github link so you can go to my github location and you can download this uh uh yaml file okay docker compositional file so another one important thing is this prometheus.yaml file which we'll be using to scrap the content so if you have seen these are the main jobs one for prometheus where i'm targeting the node docker node where i'm you know this is my ip address for you it may be different so change this with your host ip address okay and the node exporter is going to be in the port 9100 and the host the ip address is same okay and the c advisor is uh running on 8080 okay so this will be the uh prometheus.yaml file which i'll be using uh here to scrap the content okay so let's get started so i will go to my docker machine so this is my docker container machine okay so if i see i don't have any containers running so i'm inside a folder called prometheus grafana so i'm going to create first a file called prometheus.yaml okay i'm going to copy the content from here and i'm going to paste it here okay so i'm going to save this file so if you see i have a file called prometheus.yaml so let me create another file for call dockercompose.yaml okay and let me go to my text editor and i'm going to copy this content okay and i'm going to paste it here okay so you have the whole content over here for the yaml file which i have copied from there okay so i'm going to save this so we have a two file one for docker compose and one for uh prometheus.tml file okay so if you see this location i have given like it's in the current location if you are keeping in some other folder or something you have to change this volume accordingly okay so now let's start the containers using docker compose up okay so i'm going to use composer and the detach mode so it can run on the back end okay so now if you see it's uh created uh four containers right one for prometheus one for node exporter one for c advisor and one for grafana okay it has done uh so quickly because all these images are already downloaded in my docker machine if you are newly doing this this will download each and every uh images uh what we need so it will download for prometheus nor exporter c advisor grafana so it may take some time for you okay for in my machine these images are already available that's why it's quickly done it so if i see docker p as you can see we have four containers running one for grafana one for advisor one for prometheus one for nordexporter right so now what i want to do is to access uh grafana i need to use the ip address and the port number uh 3000 right so let me go here so this will be the ip address okay let me go to my browser so let me try to access the grafana using 3000 okay okay so you can see the grafana is up so let me try to log in so the username will be admin and the password is password which i set it in the image right so now we are in the grafana okay so we don't have much any data here so we need to configure it so before that i also want to show how i can access the c advisor so the c advisor is running on the port uh eight zero eight zero okay so you can run that you can see the c advisor is uh up here right so you can see the details over here so if you slash docker you can see what are the containers running right one is for prometheus knowledge percy advisor grafana right so you can see the details for c advisor as well so if you want prometheus you can change this to nine zero nine zero right yep so you can see the prometheus uh up here right and uh you can see the targets we have node exporter and the prometheus and c advisors right so if you're not aware of prometheus stuff you know just have a look in my previous tutorial i have shown multiple tutorial on how to set up prometheus how to add new exporter how to create alerts how to integrate with slacks a lot of tutorials are there on prometheus and also on grafana so you can uh go through that okay so now if i go to grafana you need to add a data source right so here our data source is prometheus so i'll select this and host i will be this nine zero nine zero okay and let me go and save and test so it's uh working okay so let me go back to the home page so we have this stage completed right now if i go to create dashboard you can click on create a new panel you can select the you know the data sources prometheus and then you can go to the metrics you will be able to see the details over here so if you see the containers it has scrap lot of contents right so if you see machine you can see here you have node uh contents here you have process you have prometheus right you have scrapping details so you have all these details showing up here in this data source so for example if i just go to containers and if i use uh something from here you can see the data i started coming up here right because since we just started these containers it's not available for longer period so it's just getting to start now okay but to make it much easier what i'm going to do is i'm going to import uh you know a dashboard okay so let me import a dashboard and this dashboard id is or six zero 11600 okay so you can search in the grafana dashboards available there you'll be able to uh see about this and also you will be able to see other uh dashboard as well so let me just select the prometheus data source and i'm just going to import it now do you see that the dashboard is already uh ready because this is pre-defined dashboards which are available using our data okay so you can see there is a dashboard for cpu usage or not network traffic or node and then these are containers right memory containers right so we can see a lot of data is already predefined right see advisor version prometheus version host right docker version so everything is pre-defined over here so similar way there are other dashboard as well you can create your own dashboard or you can import something like this and you can start using it okay so that's all uh just to recap you know we have this prometheus.yaml uh where we are scrapped in the content right and we have the docker compose file where we have four services prometheus node exporter c advisor grafana right all these details are available in my github so i'll be sharing this github location where i have this docker compose and prometheus.aml file where you can just copy and use it for your uh tutorials or your learning or whatever you want to use with those files so that is all for this tutorial i hope this is informative for you and thank you for watching kindly subscribe to my channel like this video share and comment [Music] you
Info
Channel: Thetips4you
Views: 15,806
Rating: undefined out of 5
Keywords: cadvisor prometheus grafana, cadvisor metrics explained, cadvisor docker monitoring, cadvisor install, cadvisor tutorial, cadvisor setup, cadvisor prometheus config, prometheus grafana docker, grafana prometheus docker compose, cadvisor, docker, prometheus, grafana, compose, thetips4you
Id: SVIGKcMJ31E
Channel Id: undefined
Length: 13min 39sec (819 seconds)
Published: Fri Feb 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.