{"id":3325,"date":"2024-07-28T11:38:20","date_gmt":"2024-09-29T21:25:08","guid":{"rendered":""},"modified":"2025-02-02T00:46:20","modified_gmt":"2025-02-01T23:46:20","slug":"how-to-monitor-mysql-or-mariadb-with-prometheus-and-grafana-on-windows-vps","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-monitor-mysql-or-mariadb-with-prometheus-and-grafana-on-windows-vps\/","title":{"rendered":"How to Monitor MySQL or MariaDB with Prometheus and Grafana on Windows VPS"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<h1>\u00a0<\/h1>\n<h2>Introduction<\/h2>\n<p>Monitoring MySQL or MariaDB using Prometheus and Grafana enables you to visualize database performance metrics in real-time. This guide will walk you through the steps to set up monitoring on a .<\/p>\n<h2>Prerequisites<\/h2>\n<ul>\n<li>A Windows VPS with MySQL or MariaDB installed. Consider using a service like <a href=\"https:\/\/ie.netcloud24.com\" target=\"_blank\" rel=\"follow\">NetCloud24<\/a>.<\/li>\n<li>Basic familiarity with the command line and Windows VPSservices.<\/li>\n<li>PowerShell or Command Prompt access to install necessary software.<\/li>\n<\/ul>\n<h2>Step 1: Install Prometheus<\/h2>\n<p>1. Download the latest version of Prometheus for Windows VPSfrom the <a href=\"https:\/\/prometheus.io\/download\/\" target=\"_blank\" rel=\"follow\">Prometheus downloads<\/a> page.<\/p>\n<pre><code>curl -LO https:\/\/github.com\/prometheus\/prometheus\/releases\/latest\/download\/prometheus-*.zip<\/code><\/pre>\n<p>2. Extract the downloaded ZIP file to a directory (e.g., <code>C:\\prometheus<\/code>).<\/p>\n<p>3. Navigate to the extracted folder and open the <code>prometheus.yml<\/code> configuration file in a text editor. Add a job to scrape MySQL metrics:<\/p>\n<pre><code>scrape_configs:\r\n  - job_name: 'mysql'\r\n    static_configs:\r\n      - targets: ['localhost:9104']  # Change the target if your MySQL is hosted elsewhere\r\n<\/code><\/pre>\n<h2>Step 2: Install MySQL Exporter<\/h2>\n<p>MySQL Exporter is necessary to expose MySQL metrics to Prometheus:<\/p>\n<p>1. Download the MySQL Exporter from the <a href=\"https:\/\/github.com\/prometheus\/mysqld_exporter\/releases\" target=\"_blank\" rel=\"follow\">Prometheus MySQL Exporter<\/a> GitHub page.<\/p>\n<pre><code>curl -LO https:\/\/github.com\/prometheus\/mysqld_exporter\/releases\/latest\/download\/mysqld_exporter-*.zip<\/code><\/pre>\n<p>2. Extract the contents to a folder (e.g., <code>C:\\mysqld_exporter<\/code>).<\/p>\n<p>3. Create a configuration file for the exporter. Create a text file named <code>mysql.cnf<\/code> with the following content:<\/p>\n<pre><code>[mysql]\r\nuser=\r\npassword=\r\n<\/code><\/pre>\n<p>Replace <code>&lt;your_user&gt;<\/code> and <code>&lt;your_password&gt;<\/code> with your database credentials.<\/p>\n<h2>Step 3: Run MySQL Exporter<\/h2>\n<p>1. Open a PowerShell or Command Prompt window. Navigate to the MySQL Exporter directory:<\/p>\n<pre><code>cd C:\\mysqld_exporter<\/code><\/pre>\n<p>2. Run the exporter with:<\/p>\n<pre><code>mysqld_exporter.exe --config.my-cnf=mysql.cnf<\/code><\/pre>\n<p>You should see the output indicating that the exporter is running and listening for requests.<\/p>\n<h2>Step 4: Install Grafana<\/h2>\n<p>1. Download the latest version of Grafana from the <a href=\"https:\/\/grafana.com\/grafana\/download\" target=\"_blank\" rel=\"follow\">Grafana download page<\/a>.<\/p>\n<p>2. Install Grafana by running the installer and following the prompts.<\/p>\n<p>3. Once installed, start the Grafana service. You can do this from the Windows VPSServices management console or by using PowerShell:<\/p>\n<pre><code>Start-Service grafana<\/code><\/pre>\n<h2>Step 5: Configure Grafana<\/h2>\n<p>1. Open your web browser and access Grafana at <code>http:\/\/localhost:3000<\/code>.<\/p>\n<p>2. Log in with the default credentials:<\/p>\n<ul>\n<li>Username: <code>admin<\/code><\/li>\n<li>Password: <code>admin<\/code><\/li>\n<\/ul>\n<p>3. You will be prompted to change the password. Follow the prompts to create a new password.<\/p>\n<p>4. Add Prometheus as a data source:<\/p>\n<ul>\n<li>Click on the gear icon (??) in the left sidebar and select <strong>Data Sources<\/strong>.<\/li>\n<li>Click on <strong>Add data source<\/strong>.<\/li>\n<li>Select <strong>Prometheus<\/strong>.<\/li>\n<li>In the URL field, enter <code>http:\/\/localhost:9090<\/code>.<\/li>\n<li>Click <strong>Save &amp; Test<\/strong> to verify the connection.<\/li>\n<\/ul>\n<h2>Step 6: Create a Dashboard<\/h2>\n<p>1. In Grafana, click on the plus icon (?) in the sidebar and select <strong>Dashboard<\/strong>.<\/p>\n<p>2. Click on <strong>Add new panel<\/strong> to create a new panel.<\/p>\n<p>3. In the query editor, choose <code>prometheus<\/code> as the data source and use queries like:<\/p>\n<pre><code>mysql_global_status_connections<\/code><\/pre>\n<p>4. Configure your panel settings and save your dashboard.<\/p>\n<h2>Conclusion<\/h2>\n<p>You have successfully set up monitoring for MySQL or MariaDB using Prometheus and Grafana on your Windows VPS! You can now visualize your database performance metrics in Grafana.<\/p>\n<h2>Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/prometheus.io\/docs\/introduction\/overview\/\" target=\"_blank\" rel=\"follow\">Prometheus Documentation<\/a><\/li>\n<li><a href=\"https:\/\/grafana.com\/docs\/grafana\/latest\/getting-started\/getting-started-grafana\/\" target=\"_blank\" rel=\"follow\">Grafana Documentation<\/a><\/li>\n<li><a href=\"https:\/\/github.com\/prometheus\/mysqld_exporter\" target=\"_blank\" rel=\"follow\">MySQL Exporter GitHub Page<\/a><\/li>\n<\/ul>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 Introduction Monitoring MySQL or MariaDB using Prometheus and Grafana enables you to visualize database performance metrics in real-time. This guide will walk you through the steps\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-3325","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=3325"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/3325\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=3325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=3325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=3325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}