Prometheus And Grafana Together // Explained with DEMO // Kubernetes Monitoring

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys and girls raj here back with another kubernetes video in this video we are going to learn about both prometheus and grafana we are going to start with what is prometheus and then do a demo of prometheus and then we are going to jump into grafana what is grafana why we need grafana and then do a demo especially there are a lot of cryptic ideas with grafina dashboards so i'm going to show you how how can you import those ids what those ids mean and also how can you export your own cool dashboards to graphina website all the timestamps are given in the description so feel free to jump over if you already know prometheus or if you already know grafana so you can just jump to the portions you want to listen also please subscribe like and comment in the video if you like the video if you have any questions etc uh it makes me look like a better youtuber than i actually am and it actually helps grow the channel um all right guys and girls let's jump into the video so prometheus is a monitoring tool monitoring is basically are you checking the memory usage cpu usage and then if something goes wrong you create a alert and then it actually saves the data in a time series uh database you can query the data to generate graphs tables etc you can create alerts and it is also open source how does this tool run so this actually also runs as a demon so like i said before any time you hear the name demon it basically means within the node is basically running within a pod so there will be a part for prometheus and basically it's going to send the data to the prometheus server but how could you tell so after you install a tool and then let's say for this case i'm running cubectl get all and then we are installing it in the namespace of prometheus that's why i'm passing uh dash and prometheus and it's gonna show you the pods uh that it installed anytime you install something you'll see in the demo i do that i always run a cube ctl get all uh to find out what did the command do and then if you see the after you install the tool some pods are running you can go and describe the part and it will tell you what node it is running so then you know how each tool runs in your cluster so yeah pretty straightforward monitoring tool uh so let's do a demo and then things will become more clear so in this demo we are going to install prometheus and then look at some control plane metrics for this demo i'm going to follow the steps written in this documentation i'm going to give you the link it's pretty straightforward we're going to utilize helm for installing it that's the easy installation rather than installing bunch of manifest files separately so i have a cluster up and running which i'm going to use for this demo so before we can install prometheus we need to install a metric server metric server aggregates your resource usage data in your cluster so it doesn't get deployed by default in eks cluster but when we do demos for horizontal part autoscaler or the kubernetes dashboard you will see that they also need to access the resource usage right that's how auto scaling works so even in those demos we will use metric server so let's do that so i'm just going to run this to commands and then i'm going to check if everything is up and running okay seems like metric server is ready okay let's deploy prometheus so let's create the prometheus namespace then we are going to deploy prometheus using the help help command so please make sure you guys and girls watch the helm demo where we show how to install helm because you do need helm to install this okay so prometheus is installed okay now we are going to check that all the parts for prometheus are up and running okay couple of the containers are in container creating state so i'm just gonna wait couple minutes and come back okay seems like all the parts are up and running now so now what we are going to do is use cubectl to put forward to the prometheus console to my local machine okay this should start the forward now we are going to open this port in localhost and then we should see the prometheus console so i'm just going to click this okay here we go so this is the prometheus console uh so just to just to make sure we understand you can read the raw control plane metrics using cube ctl but that will be too much to uh understand right so prometheus gives you the control parent metrics in in a much simplified and understandable way okay let's take a look at a sample metric so it comes with a bunch of metrics that you can use how about container memory usage bytes okay container memory usage bytes i'm just going to select this and then click execute okay so you can see the raw data or you can click graph and it's going to show you the graphs so it's going to show for different targets and different processes how much memory it is using so these are all control plane components note that prometheus is not going to show you your application level metrics right because this is monitoring the control plan for application we have different monitoring that we are going to go over in separate lectures you can also select different targets by clicking the status and then targets so there it shows what are the end points that it is showing the metrics for so you can come here and change stuff okay let's run another metrics how about api server request count click execute okay here we go and here is the raw data and then you can hover over and it's going to show the details so if you're an application developer or you work in the application so generally you don't worry about this control plan metrics uh the admins who manage the eks cluster they monitor this and they can create alerts and stuff what happens is so this this gives you some data and gives you some graph but it is not presentable to senior management so what most enterprises do is they will run grafana on top of prometheus so okay so with that being said let's jump into grafana and see how it works with prometheus so prometheus has all the data remember the time series database where we ran the query the prometheus query language or from ql so grafana is just a visualization layer on top of the data so it visualize the metrics works out of the box with prometheus you can create a lives and it's open source and i mean you can live without graffana but graffama just makes your dashboards look prettier and it comes with a set of inbuilt dashboards for prometheus so if you are running a cluster in your enterprise and it's a big release day and i don't know your director or vice president walks in and he or she wants to see how things are going if you show them the prometheus graph they won't be that impressed but if you show them graffana graphs it looks kind of shiny and more eye-catching and more functional uh so let's do a demo and then you will see what i mean so i have given all the steps in this install grafana.txt and then i'm going to provide this file with the lecture as well so you can just copy paste and do it so first step is install grafana again we are going to use the helm uh for installing grafana so please make sure you have helm installed in your machine okay so let's run this now we are going to check if grafana is deployed properly basically all the pods and everything should be up and running nothing should be in pending our container creating state so let's check it out okay so uh not everything is up and running so you can see the pod uh it is zero by one even though it's running so it takes a few more seconds it should be one by one like everything should be ready so we're gonna give this few more seconds and then come back and rerun the command okay so we rerun the command and now it seems like things are ready you can see ready one one of one so everything is ready deployment is also ready uh one by one ready and then the replica sets are also desired current radial one so at this point we have the elastic load balancer we have the url so you can either run this command uh or you can just copy paste from this external ip uh but okay we're gonna just follow the commands and then you run an echo and you add http in front of it okay so we're gonna copy this and then for logging in you have to use the username admin and then get the password by running the following uh so we're just gonna run this and get the password okay so this is the password uh so let's copy this and open up a link okay i'm going to control click you can either copy and open up in your browser i'm working in visual studio code so i'm just going to control click ok so it opened up the grafana dashboard so the username is admin and password i'm just going to copy this and paste it here okay we are logged in to grafana okay so let's just create a dashboard with some charts so create a dashboard just hover your mouse to the plus symbol on the top left and then select import okay so this part is a little tricky uh so enter three one one nine okay and then click load okay see this that three one one nine points to the kubernetes cluster monitoring via prometheus so we'll learn in couple minutes how to search for different dashboards and import using the dashboard number like for example this dashboard has the number 3119 okay and then we have to select a prometheus data source so you can just select prometheus and then click import all right so we are in um so just to return it right all the installation that we did if we go back to visual studio it's in the same cluster as prometheus so it knows which prometheus to read the data from right because uh it's in the same cluster where we install prometheus and then we installed grafana so internally graffana can talk to prometheus in this cluster so this is the default view so it's a network input output cluster memory usage cluster cpu usage cluster file system usage and some of the other stats the port cpu usage container cpu usage okay so what i did next was i created this cube ctl deployment for the nginx deployment with rolling this is one of the files you can use any deployment just to show you guys and girls and then after a few seconds you can see we deployed this test deploy deployment it has three parts that's running and then one replica set managing those three parts so now what i'm going to do is go back to the grafana dashboard and then refresh or you can wait 10 seconds but patience is not my virtue so i'm just going to refresh and then it should start showing the cpu and container usage for those parts that we just deployed okay so here we go see it has deployed so these are the parts that we did oops uh let me scroll down test deploy so i'm not invoking it so everything is zero but at least you can see that you can see the name so if i go to pods uh so these are the containers so you can see it's engine x um okay so this is pretty nice right you can see this is much prettier than the prometheus matrix and all these is given uh out of the box okay so i know what you guys and girls are thinking uh what's up with those random ids uh for the graphs right and how how you know so i've given a link in my document so let me open this and then i'll show it to you so basically all the dashboards graphene is open source all the dashboards are built by community uh so this is the page and in my link uh see the data source i have selected as prometheus because graphena is supports lot of other stuff as well and then i always sort it by number of reviews you can do by average rating as well is totally up to you and then you can select from these dashboards i have to be honest though there are like tons of dashboards because it's open source so like you have to sometimes find out what dashboard you want but yeah i come here and browse so let's say this uh kubernetes cluster uh there have been like 157 000 downloads so i assume it's good because a lot of people are using it so you click this and then you should see this id 7249 right so let's do this so let's copy this 7249 go back to our graphana dashboard okay now go back to this plus sign click import and then paste your id here click load and then you can rename rename the dashboard a unique identifier you click change and then you should generate a unique identifier and from the drop down select data source prometheus click import boom you are done so this dashboard shows uh like the current connections uh minimum space minimum memory all this stuff and the cool thing is you can actually edit some of this stuff like if you click this drop down and you can remove this okay let's remove minimum memory sure okay so you can remove this and then you can move around stuff like so you want it by minimum space so see how you can move around uh so it's pretty neat uh this just was just kind of cool actually see it shows top five memory intense pods um so it shows the top five parts which are using most amount of memory uh these styles okay that's i guess that's why this one is so popular and you can save this dashboard for future use so you click this floppy disk icon i don't know how many of you know what a floppy disk is it shows how old i am but click this save dashboard icon and then you can say kts uh cluster dashboard something like that okay and then click save and now this is saved so now you can go and import other dashboards and then if you click home from this you click home and you can see all the recently viewed dashboards um and then here you can make a dashboard favorite like you can make click the star icon and then if you click it again it's gonna show you the dashboard again and you can see uh that our modification is still in there it's saved and then let's say you create some cool dashboard here and then you want to share it so you can click the share dashboard and then after you have to fill up some stuff and then it's gonna come to uh this list right so that's why see how easy it is to export a dashboard uh so that's why there are so many dashboards uh i don't know how many like 16 pages okay so this is how you create uh dashboards in grafana uh pretty neat i really like grafana a lot because grafana is not just for prometheus it supports a lot of other other systems as well all right guys and girls so that's how you install and create grafana and prometheus and remember again uh to work with kubernetes and eks you need to install prometheus before you can uh install grafana so there is one more thing i want to show you guys and girls how to uninstall prometheus and grafana pretty straightforward you just do helm uninstall uh like any other helm on install so i'm gonna run this and then that should uninstall prometheus and grafana all right they're uninstalled but again they're open source so no harm keeping them running you're not gonna pay anything for them all right guys and girls that's the video hopefully you guys and girls found it helpful i'll see you in the next video bye
Info
Channel: Cloud With Raj
Views: 13,687
Rating: undefined out of 5
Keywords: agent of change
Id: losQlALIsYY
Channel Id: undefined
Length: 18min 49sec (1129 seconds)
Published: Sun Sep 06 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.