Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
Key Takeaways
This video demonstrates how to monitor third-party applications like MongoDB using Prometheus Monitoring, MongoDB Exporter, Service Monitor, and Service Discovery in a Kubernetes cluster, with tools like Helm, Minikube, and Grafana.
Full Transcript
in this video i'm going to show you how to monitor a third-party application like mongodb or mysql or any other service in kubernetes using prometheus so our setup is going to look like this we're gonna have a mini cube local cluster and in the first part of this video series i have already deployed a prometheus operator using a helm chart so if you want to know how the deployment works how to install the helm chart and what are the components that get created when the chart is installed then you can check out that part first and set up prometheus operator in your cluster and then you can continue with this video after that in the cluster with prometheus running we're gonna deploy a mongodb application and we're gonna expose the data of mongodb or metrics of the mongodb application using mongodb exporter and once the metrics is exposed through a mongodb exporter we're gonna allow prometheus to scrape this data or this metrics and we're gonna do that using another component which is called service monitor so along the process i will explain all of these concepts in detail i will explain what exporter is what service monitor is so that you also understand the concept and then see how to use that in practice right away and finally once we've configured all of these and prometheus start scraping the mongodb application through the mongodb exporter we're gonna see the new prometheus target in prometheus ui and also we're gonna see the scraped data visualized in grafana ui so with that let's get right in so to get the maximum out of this video i do recommend to follow along the tutorial as i walk you through all the deployment steps and configuration steps and a prerequisite for that is to have a mini cube cluster installed so with that let's get right in for starting minicube cluster basically you can execute this command which starts the cluster with more resources in the default because we are going to use a little bit more resources because prometheus operator actually creates a lot of components so it may need more resources i'm going to put the commands for starting your mini cube cluster and installing prometheus operator in a git repository for you to just copy it from there and once you have everything set up we can go ahead and deploy our mongodb application so this is my cluster i only have prometheus pods running on it so i have a prometheus helm chart this is the version of the chart and this is the version of prometheus operator application and here we can see all the pods of prometheus we have grafana alert manager prometheus operator and the prometheus application itself and we also have all the services the chart installed so the first thing we're going to do now is expose prometheus ui so that we can see actually what endpoints are currently being scraped and this is all out of the default i haven't configured anything yet so in order to expose prometheus ui we're going to use cubectl port forward command so this will basically allow me to access the application that is running inside minicube virtualbox to access it on my localhost through a browser so i'm going to do cube ctl port forward service this is the prometheus application and then i'm going to need the port that it's running at and this command will expose prometheus ui at localhost port 1990 i can actually copy this and type it here and here you see prometheus ui and on the status targets i can actually see all the targets that are being scraped out of the box so if i close all this i have a list of all the end points so prometheus is monitoring itself the operator is getting scraped etc so what we're gonna do in our setup is we're gonna deploy a mongodb application and we're gonna add mongodb to the list of targets so that its metrics will also get scraped and as i said this is all out of the box i haven't configured anything and the way this works is actually through a component called service monitor and before we move on to the service monitor i want to thank octado who made this video possible octatocloud gives developers instant access to manage kubernetes namespaces that means you can focus on developing your application while they manage the infrastructure in the background if you want to try cloud check out the special offer in the video description below so if i go back to my cluster and i do cube ctl get service monitor i see a whole list of service monitors that the operator chart actually created and these are exactly the service monitors that generate these targets list here so these are exactly the same components service monitor is a custom component we can also see one of the service monitor components here let's actually take grafana and see its ymo file and here you see it's a kind service monitor and you have this configuration file with labels and the specification so you have the endpoint etc you don't have to understand all the attributes here there is one thing that is important in this service monitor and this is the label called release prometheus now why is that important because this label allows prometheus to find service monitors in the cluster and register them so that it can start scraping the application or endpoint which is right here of the application that service monitor is pointing to so here you see it's pointing to grafana at metrics endpoint and this attribute basically allows service monitor itself to be discovered by prometheus and this logic of how prometheus actually discovers service monitors using this attribute is configured in prometheus itself so i'm going to show you that as well so in order to see the configuration we have to check it in the crd so these are all the crds that prometheus has created and these are basically custom components for prometheus so this one right here so we're gonna check its configuration file like this and in this configuration file here we have the specification all the different configurations and if you scroll all the way down this line here is interesting for us it says service monitor selector match labels release prometheus so basically this says match all the service monitors that have a label release prometheus so this means if you create a service monitor component which doesn't have this label it will not be discovered by prometheus cool so now we understand how these targets got actually created or target endpoints using the service monitor now as a next step we're going to deploy mongodb and we're going to configure everything so that mongodb becomes one of the targets for prometheus to collect its metrics so let's do that so first we're going to create a mongodb deployment and a service so pretty straightforward i have this uh configuration file already created here so it's basically a simple deployment mongodb image and port defined here and we're creating a service for it pretty straightforward i'm also going to provide the yaml files that i use in this video in the repository so you can use them from there so i'm going to apply this in the cluster without exporter and our deployment and service got created so i have mongodb pod getting created here cool so now we have mongodb pod running and this is probably the typical scenario where you have an application deployed in your cluster and at some point you decide that you want to monitor it using prometheus so the way to do that is using a component called exporter so each application like mongodb mysql already kibana whatever application you have is going to have its own exporter right so export is basically a translator between the applications data or application metrics to metrics or data that prometheus will understand so it's basically sitting between the application and prometheus getting the data from the application transforming it into data or metrics that prometheus will be able to collect an exporter itself will expose the slash metrics endpoint so that prometheus will be able to scrape it from there right so it does two things it collects the matrix data from the application and converts it to data understandable by prometheus and the second thing is it exposes these metrics at a slash metrics endpoint for prometheus to be able to scrape them so this is the role of exporter an exporter can be a separate deployment in the cluster independent of the application which is a good thing because when you decide to monitor your application later you don't have to change the deployment configuration file or service or anything you don't have to touch the application you just create an exporter if you don't want to monitor it then you just delete the exporter and that's it so now the question is how do you find an exporter how do you know their exporters available and how do you install it so let's go back to the browser and here i'm gonna type prometheus exporters and on official prometheus page you can actually see the list of all the exporters available for different databases hardware related stuff messaging systems so basically for a lot of different applications there are already exporters that you can use instead of having to create them right and here if you notice in the prometheus operator that we installed there is a node exporter that gets deployed out of the box so this is one of the exporters and as the name says it is translating the metrics of the node of the cluster node in this case minicube into data that prometheus will understand and exposes that matrix data at slash metrics endpoint for prometheus to scrape it so here let's actually look for mongodb there are some of them which have official next to it are from prometheus itself so if i click on that actually end up in a repository of mongodb exporter these exporters are also available as docker images so you can also search them on docker hub actually so if i write here mongodb exporter then i will find a list of a lot of mongodb exporters which are managed by different communities and you should probably go with the one that has been recently updated so for example this one right here so you can actually find if there are any available like this now there are three things or three components that you need to have when you deploy an exporter so first of all it will be the application itself in docker image that the exporter application that will expose the metrics endpoint then you would of course need a service so that prometheus can connect to the exporter so we're going to need a service for that and with that you would have an exporter running in your cluster ready to be scraped however as i mentioned prometheus must know that there is a new application ready to be scraped so we have to tell prometheus hey there's a new endpoint that you need to scrape here and we do that as i mentioned using this component which is called service monitor right so we are gonna need that component as well so we're gonna need to create a service monitor for our mongodb exporter application now we could of course go and create all those three component configuration files ourselves so we can create a deployment service and the service monitor and put together all these attributes or my preferred way of doing it we can search for a helm chart that already has all these configuration files ready and configured so that you can basically just install them with one command so let's go back and check for mongodb exporter helm chart or chart and this is the first one in the search here it says deprecated this is something that happens often with helm charts they get deprecated they're moved a lot of them have been moved to prometheus community health chairs so they're managed by the community so always watch out for the deprecated so that you don't install something that is not maintained anymore so we're going to follow that link and this is basically the list of all the charts managed by prometheus community and here we have the list and here is our mongodb exporter you have one for mysql postgres etc so let's go inside and this is our chart and that's how we're gonna install the exporter in our cluster now there are two things that we need to configure for this chart before we install it right remember if you have watched my helm chart and explanation videos you know that helm charts are basically bundle of all the configuration files you need to deploy that complete application in this case the deployment service and service monitor with default values but if you want to overwrite some value if you want to configure something then you have a possibility to do that using parameters or chart parameters for that specific chart so how do you know which parameters you can override or what are the names of these parameters you can find them either in the documentation sometimes they have a list of those parameters this one doesn't but we can also do that using helm show values that will basically show you the list of all the parameters that this chart accepts so first let's actually add the repository let's clear this has been edited and now i can do hell show values and we need a chart name so helm show values chart name will actually show me all the parameters that i can configure and this is actually a yaml file and i can actually save them into values.yml and open it in the editor so these are all the default values and you can override any one of those so there are two things that we need to override and let's actually get rid of all of this till here and here you see service monitor configuration and we're gonna need to override this additional labels attribute right so these are the two parameters that we need to override for our chart the first one is pretty obvious we need to tell mongodb exporter how to connect to mongodb right so we need to give it a service endpoint so that it can connect to the independently running mongodb so the endpoint is going to be mongodb protocol and mongodb service that's the endpoint and the port right so at this uri mongodb is accessible now the second parameter service monitor additional labels remember i showed you this release prometheus label that all the service monitors in the cluster have right this release prometheus basically is a label that allows prometheus to discover or to automatically find a new service monitor in the cluster and this chart by default doesn't add that release prometheus label to service monitor which kind of makes sense because that label can be different so we have a possibility to add that label to the service monitor component that the chart will create so let's add that label right here so additional labels and i'm gonna say release prometheus so now we have all the parameters we need for this chart so let's go and install it i'm gonna copy the chart name again let's clear this helm install let's call it mongodb exporter and the chart name and of course we want to pass those parameters so i'm going to do minus f values dot yemo so the chart will take the values file as an attribute and it will apply all these parameters that we set here so i'm gonna install it now and let's check we have mongodb exporter and this is the chart version so it's 2.8.1 and our pods or our pod must be running already so this is the part of the exporter let's also check that the service was created here we have exporter service which exposes the metrics port and let's also check that the service monitor was created cube ctl get service monitor and here is our service monitor let's actually check that the label is there and here you see release prometheus cool everything looks good so the first thing that we can do is check the endpoint of the exporter at slash metrics so let's see what data it's collecting so let's print out the services again so this is the service and let's do port forward on that as well service and this is the service port and let's check it here we have the metrics endpoint and at slash metrics we see all these data being collected from mongodb awesome so the exporter is exposing the metrics for prometheus and since we have the service monitor also created with that release prometheus label prometheus must already have discovered our new service monitor in the cluster and it should already be scraping that metrics endpoint of the mongodb exporter so if i go back to the prometheus ui and if i refresh this see we have the mongodb exporter endpoint which was automatically added to the targets without me having to change the configuration file of prometheus and we have the state which is up and configuration file which is much more convenient than having to go and change the configuration file reload or restart the applications etc so what we can also do now is check those metrics data in grafana ui because that's usually the reason why we're collecting the metrics so that we can visualize them so let's go back to the command line and i'm actually going to expose grafana deployment so i'm going to do cube ctl port forward deployment deployment and it's called prometheus grafana and its port is three thousand and it is secured by default credentials you have admin and prom operator is the default password it says in the documentation i'm going to put all this information as well in git repository and we're logged in so if i go for example to manage and if i go to pods here i can see in the default namespace i have mongodb deployment in the drop down so i can see some of its metrics that has been collected and of course you can do some other visualization in grafana from this matrix so this is basically how you can configure metric scraping for any application in your kubernetes cluster so that it can be monitored by prometheus you can apply the same concept for any other application like mysql or some messaging services etc so i hope you learned a lot thank you for watching and see you in the next video
Original Description
► Part of the DevOps Bootcamp 🚀 More infos here: https://bit.ly/3q9iWly
Learn how to monitor any third-party application in Kubernetes using Prometheus Monitoring | MongoDB Exporter | Service Monitor and Service Discovery explained | Grafana
► Thanks Okteto for sponsoring this video!
► Get a 2 months free trial for Okteto Cloud Pro Plan here: https://cloud.okteto.com/#/promo/NANA2020 🚀
Full Prometheus Monitoring Tutorial:
► Prometheus explained: https://youtu.be/h4Sl21AKiDg
► Demo Part 1: Setup Prometheus Monitoring on Kubernetes using Prometheus Operator: https://youtu.be/QoDqxm7ybLc
Demo Part 2: this video
In this Prometheus Monitoring Tutorial I show you how to monitor a third party application, like Mysql, Mongodb, Redis or any other service running in your Kubernetes cluster using Prometheus Monitoring.
I personally think this is a complex topic, simply because there are so many options and combinations of doing it and it’s also very badly documented. So it’s difficult to get a clear picture of how it works. And this is exactly what I want to address with this video. I will give you a good overview of all the different options and clear image of steps required to set up the monitoring. So no matter what application you have, you will know exactly how to configure its metrics collection for Prometheus.
And here is what we are gonna do:
* First we will deploy a Prometheus Operator in our Minikube cluster using a helm chart - this is a pretty easy step (Part 1 of demo!)
* Second we will deploy a MongoDB application as an example
* and then we will configure our MongoDB application for Prometheus monitoring using a MongoDB exporter
I explain all the concepts, including Exporter, ServiceMonitor and so on as we go through the setup. So you understand with every step exactly what we are doing.
▬▬▬▬▬▬ T I M E S T A M P S ⏰ ▬▬▬▬▬▬
0:00 - Intro
0:13 - Steps to monitor MongoDB (or any other third party application) metrics
2:06 - Prometheus Operator
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from TechWorld with Nana · TechWorld with Nana · 54 of 60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
▶
55
56
57
58
59
60
What is Docker? Docker container concept explained || Docker Tutorial 1
TechWorld with Nana
What is a Docker Container? Docker Demo || Docker Tutorial 2
TechWorld with Nana
How to install docker? Step by Step || Docker Tutorial 3
TechWorld with Nana
8 Basic Docker Commands || Docker Tutorial 4
TechWorld with Nana
Debugging Docker Containers with docker exec and docker logs || Docker Tutorial 5
TechWorld with Nana
Docker vs Virtual Machine | simply explained || Docker Tutorial 6
TechWorld with Nana
Overview of Workflow with Docker - Docker in Practice || Docker Tutorial 7
TechWorld with Nana
Developing with Docker - Docker in Practice || Docker Tutorial 8
TechWorld with Nana
Docker Compose Tutorial - Docker in Practice || Docker Tutorial 9
TechWorld with Nana
Dockerfile Tutorial - Docker in Practice || Docker Tutorial 10
TechWorld with Nana
Private Repository explained | Registry on AWS - Docker in Practice || Docker Tutorial 11
TechWorld with Nana
Docker Volumes explained in 6 minutes
TechWorld with Nana
Deploying the containerized application with Docker Compose || Docker Tutorial 12
TechWorld with Nana
Docker Volumes Demo || Docker Tutorial 13
TechWorld with Nana
Docker vs Kubernetes vs Docker Swarm | Comparison in 5 mins
TechWorld with Nana
What is Kubernetes | Kubernetes explained in 15 mins
TechWorld with Nana
Kubernetes Components explained! Pods, Services, Secrets, ConfigMap | Kubernetes Tutorial 14
TechWorld with Nana
Kubernetes Architecture explained | Kubernetes Tutorial 15
TechWorld with Nana
Benefits of Kubernetes | Scalability, High Availability, Disaster Recovery | Kubernetes Tutorial 16
TechWorld with Nana
Minikube and Kubectl explained | Setup for Beginners | Kubernetes Tutorial 17
TechWorld with Nana
Top 3 programming languages to learn in 2020 | meta analysis
TechWorld with Nana
Kubectl Basic Commands - Create and Debug Pod in a Minikube cluster | Kubernetes Tutorial 18
TechWorld with Nana
Kubernetes YAML File Explained - Deployment and Service | Kubernetes Tutorial 19
TechWorld with Nana
Run Jenkins in Docker Container - Jenkins Pipeline Tutorial for Beginners 1/4
TechWorld with Nana
Create Multibranch Pipeline with Git - Jenkins Pipeline Tutorial for Beginners 2/4
TechWorld with Nana
Jenkinsfile - Jenkins Pipeline Tutorial for Beginners 3/4
TechWorld with Nana
Trigger Jenkins Build automatically - Jenkins Pipeline Tutorial for Beginners 4/4
TechWorld with Nana
Complete Application Deployment using Kubernetes Components | Kubernetes Tutorial 20
TechWorld with Nana
Kubernetes Namespaces Explained in 15 mins | Kubernetes Tutorial 21
TechWorld with Nana
Configure Build Tools in Jenkins and Jenkinsfile | Jenkins Tutorial
TechWorld with Nana
Complete Jenkins Pipeline Tutorial | Jenkinsfile explained
TechWorld with Nana
Kubernetes Ingress Tutorial for Beginners | simply explained | Kubernetes Tutorial 22
TechWorld with Nana
What is Helm in Kubernetes? Helm and Helm Charts explained | Kubernetes Tutorial 23
TechWorld with Nana
How Websites Work | simply explained with examples
TechWorld with Nana
What is JavaScript? | JavaScript Tutorial #1
TechWorld with Nana
What is Ansible | Ansible Playbook explained | Ansible Tutorial for Beginners
TechWorld with Nana
JavaScript Variables & JavaScript Data Types explained | JavaScript Tutorial #2
TechWorld with Nana
How Prometheus Monitoring works | Prometheus Architecture explained
TechWorld with Nana
Where to write JavaScript | Where to execute JavaScript Code | JavaScript Tutorial #3
TechWorld with Nana
JavaScript Operators & JavaScript Conditionals | JavaScript Tutorial #4
TechWorld with Nana
Pods and Containers - Kubernetes Networking | Container Communication inside the Pod
TechWorld with Nana
Kubernetes Volumes explained | Persistent Volume, Persistent Volume Claim & Storage Class
TechWorld with Nana
Kubernetes ConfigMap and Secret as Kubernetes Volumes | Demo
TechWorld with Nana
Pull Image from Private Docker Registry in Kubernetes cluster | Demo
TechWorld with Nana
Kubernetes StatefulSet simply explained | Deployment vs StatefulSet
TechWorld with Nana
Yaml Tutorial | Learn YAML in 18 mins
TechWorld with Nana
Terraform explained in 15 mins | Terraform Tutorial for Beginners
TechWorld with Nana
Setup Prometheus Monitoring on Kubernetes using Helm and Prometheus Operator | Part 1
TechWorld with Nana
Managed Kubernetes Cluster explained | Kubernetes on Cloud (1/2)
TechWorld with Nana
Step by Step Application Deployment on LKE using Helm | Kubernetes on Cloud (2/2)
TechWorld with Nana
Kubernetes Operator simply explained in 10 mins
TechWorld with Nana
What is Infrastructure as Code? Difference of Infrastructure as Code Tools
TechWorld with Nana
AWS EKS - Create Kubernetes cluster on Amazon EKS | the easy way
TechWorld with Nana
Prometheus Monitoring - Steps to monitor third-party apps using Prometheus Exporter | Part 2
TechWorld with Nana
GitHub Actions Tutorial - Basic Concepts and CI/CD Pipeline with Docker
TechWorld with Nana
Docker Tutorial for Beginners [FULL COURSE in 3 Hours]
TechWorld with Nana
Kubernetes Services explained | ClusterIP vs NodePort vs LoadBalancer vs Headless Service
TechWorld with Nana
Kubernetes Tutorial for Beginners [FULL COURSE in 4 Hours]
TechWorld with Nana
Containers on AWS Overview: ECS | EKS | Fargate | ECR
TechWorld with Nana
Kubernetes is dropping Docker support - What does it mean for YOU?
TechWorld with Nana
More on: ML Pipelines
View skill →Related AI Lessons
Chapters (3)
Intro
0:13
Steps to monitor MongoDB (or any other third party application) metrics
2:06
Prometheus Operator
🎓
Tutor Explanation
DeepCamp AI