Install Prometheus MySQL exporter using Docker Compose | Prometheus

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello people and welcome back to my channel let's learn about how to install Prometheus MySQL exporter using Docker compose so MySQL as most of you must be knowing that it is a relational database system where basically you store the data for your application so there are multiple tables and basically we insert data we fetch data we delete data from this mySQL database there are some metrics which are very important related to mySQL so let's say what is the RAM usage what is the CPU usage how indexes are being performed what are the slow queries that are being done so to know all these particular data on a production system is very necessary because you need to have a 99% up time for your system so for that we have Prometheus as the monitoring system and what we are going to do here is we'll be installing the Prometheus exporter uh this Prometheus MySQL exporter to collect data from MySQL and then send it to the Prometheus so here we are only going to do this installation of Prometheus MySQL exporter and fetch the data from the MySQL instance so let's say what is needed here so there's a prerequisite of that Docker must be installed and Docker compose must be installed I have created this post on my website to install Docker on your machine and basically there are different operating system on which Docker can be installed so I'll be adding more block post here related to different operating system but you can search for your own here on this list and and if you find then you can use it for the installation you can go to the link and install it so this is one of the post which can help you for installation of Docker the next prerequisits SQL must be installed I've created this post on how to install MySQL using Docker compose and you can use it to have your own MySQL Docker container or mySQL database server once all these prerequisites are completed then let's understand what we are going to do so there will be a host operating system and there is a Docker environment so whenever you install Docker it creates an environment and in this environment only your Docker containers are being deployed so we will create a Docker container that will be Prometheus MySQL exporter and this will be exposed on the port 9104 inside the docker environment and same will be mapped to 9104 on the host operating system so if someone accesses this post port on 9104 on the host operating system so the messages or the requests will be forwarded to this 9104 port on the docker environment we'll also write a my CNF file basically which will contains the detail about the authentication related to the MySQL so when this Prometheus MySQL exporter Docker container will run what it will do it will take this my CNF file which is present on host operating system to gather the configuration for the for connecting to the MySQL instance so let's go to the terminal and I am present inside this YouTube playground here what I'm going to do I'm going to create a new directory that is MySQL Prometheus exporter and here we are going to write our MySQL Docker compose file so let's go inside this one the ls file and it is empty so let's create a new file so that would be touch Prometheus this MySQL Prometheus exporter I'll just copy it and do yaml do yaml file will be there so this file is created now let's go to the intellig or you can use whatever ID you are having to basically open this file and do the configuration so I'll go here open the file and the YouTube playground is already present here this my SQL Prometheus exporter folder is here I'll open the file and bring it here so now we need to do the configuration related to our Docker compose file so first we will write the version that we are going to use for our MySQL Docker compos file so that would be version three and then we are going to define the services now let's define the service that is my SQL exporter so this is the service name that we are going to Define and it is going to use the image PR MySQL D exporter so this image you can find on the docker Hub so let's go to the browser here and search for dockerhub inside the dockerhub you will find a search bar and we'll just paste it here so it is prom my SQL exporter and you can see this is the docker image that we going to use so you can read the details if you want um I I'll already explain it in our video so this is the image that will be downloaded and the docker container will be created from it then there are some configurations like the command that we want to supply to this MySQL exporter so that is what config that is hyphen config doy CNF it will be read from where so it will be read from SL CFG folder and there will be a my do doy do CNF file present and also what is the address that you want to connect to so in our case what we want to do is we need to provide the IP address of the MySQL container so we have already deployed a MySQL container here so if I see Docker PS you can see the my SQL container is present and if I do if config so you can find here I will be able to find my IP address so that is 192 168 18226 so this is my IP address so you need to find your own IP address so it will be under this eth0 so there are other things also that is related to Docker so you need to you need not to worry about it but let's to find the IP address you need to type the command if config inside your Linux if you are on Windows ip config for other operating system you can basically search on the internet so if config will give you the IP address inside this eth Z so this is my IP address I'll come here and then I will paste it so this is already here 192 168 18226 and the port is 3306 so my MySQL container is running on that port and there is a volume that is on the current folder do/ V in the current folder there's a my.cnf file and that should be mounted to this/ CFG sl. my.cnf so in that case what will happen when we provide this config the file which is present on our host operating system system will automatically get loaded here so we have already seen this in our uh presentation that okay my CNF file is there and we are mounting it to the docker container and that mounting is done using this volumes and also the port is 9104 on the host and 9104 on the inside the docker container so now let's create a new file so new file will be What DOT my. CNF so inside here you need to do some configuration related to your dock uh this my SQL container that is you need to provide the username and password so in my case what I've done the usern name is root and the password is password so I'll provide that in my case I'm using the my SQL Docker container and for that the username is root and the password is password so I'll do the same thing I'll just come here and I'll do a paste so you need to provide this configuration so there will there should be a client configuration the user and the password in your case you need to provide IDE the username and password for your MySQL uh instance it can be a Docker container it can be a run it can be running on a VM machine so what happens here is like all the configurations are done now let's go to our terminal and let's start this so I'll do a clear and I'll do Docker compos so let's first do LS so if you see you are not able to view that my do my do do my. CNF file because it is it starts with DOT so that's why it is a hidden file if I do LS hyphen La so you can see now you're able to view this let's do a cat also to just to confirm that okay everything is fine okay this is also fine there's a password and at the last there's a percentage I don't know why the percentage is coming but okay this looks fine so let's start the docker this uh my SQL exporter hyph F and the file name is my SQL doer Prometheus exporter up when I do up it starts uh the container in the foreground mode so that I able to view the logs if you want to start it in the background mode just to hyund D so what it is saying msage TLS is disabled sttp false 9104 listening on the address okay so it is able to listen on the address let's go to the browser and just do local host and then 9104 so let's see what happens okay so my SQL DX exporter metrix and you can see that my SQL Global status command total and everything is coming so this is able to scrape the metric from the MySQL container okay so this is done like what we did we basically uh deployed this container uh we deployed this container and there's a MySQL instance it can be a Docker container or it can be a VM where your my SQL is running and this is able to connect using the configuration that is this my SQL D address and you also need to provide the username and password in this my my.cnf which is mounted as a volume and this is running on 9104 Port so um I think we have successfully done the connection let's go to the terminal again and this time I'll start it in the demon mode now if I do Docker PS you can see there are two container my SQL and this MySQL D exporter so this is able to scrape the data from the uh this one my SQL instance so if I do this one you can see there are some datas which are changing so when you insert into it so you can go into the detail of this MySQL exporter or the metrics that myql export and you can plot graphs on the graph using it so hope you like this video hope you like my Channel please share these videos with other people and please support me the support details are in the description below so thank you
Info
Channel: CodeWithRajRanjan
Views: 189
Rating: undefined out of 5
Keywords: prometheus mysql exporter, prometheus mysql, mysql prometheus docker compose
Id: ANcxjbHa6MI
Channel Id: undefined
Length: 10min 33sec (633 seconds)
Published: Tue May 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.