{"id":108,"date":"2023-08-05T08:06:00","date_gmt":"2023-08-05T08:06:00","guid":{"rendered":"http:\/\/it4home.dk\/?p=108"},"modified":"2023-08-06T09:13:20","modified_gmt":"2023-08-06T09:13:20","slug":"setting-up-prometheus-with-docker-for-monitoring","status":"publish","type":"post","link":"https:\/\/it4home.dk\/index.php\/2023\/08\/05\/setting-up-prometheus-with-docker-for-monitoring\/","title":{"rendered":"Setting Up Prometheus with Docker for Monitoring"},"content":{"rendered":"<div class=\"pdfprnt-buttons pdfprnt-buttons-post pdfprnt-top-right\"><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/108?print=pdf\" class=\"pdfprnt-button pdfprnt-button-pdf\" target=\"_blank\" ><\/a><a href=\"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/108?print=print\" class=\"pdfprnt-button pdfprnt-button-print\" target=\"_blank\" ><img decoding=\"async\" src=\"https:\/\/it4home.dk\/wp-content\/plugins\/pdf-print\/images\/print.png\" alt=\"image_print\" title=\"Print Content\" \/><\/a><\/div>\n<p class=\"wp-block-paragraph\">Introduction:<br>Prometheus is a widely-used open-source monitoring and alerting toolkit. In this guide, we&#8217;ll show you how to set up Prometheus using Docker, allowing you to monitor your applications and systems efficiently.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 1: Install Prometheus with Docker<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To install Prometheus and run it in Docker, execute the following command:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker run --restart always -d --name prometheus -p 9090:9090 -v prometheus_data:\/prometheus prom\/prometheus<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Explanation of options used:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>--restart always<\/code>: Configure the Prometheus container to restart automatically if it stops unexpectedly.<\/li>\n\n\n\n<li><code>-d<\/code>: Run the container in the background (detached mode).<\/li>\n\n\n\n<li><code>--name prometheus<\/code>: Assign the name &#8220;prometheus&#8221; to the container for easy management.<\/li>\n\n\n\n<li><code>-p 9090:9090<\/code>: Map port 9090 from the container to port 9090 on the host system. This allows you to access Prometheus&#8217;s web interface at <code>http:\/\/localhost:9090<\/code>.<\/li>\n\n\n\n<li><code>-v prometheus_data:\/prometheus<\/code>: Create a Docker volume named &#8220;prometheus_data&#8221; and mount it to the &#8220;\/prometheus&#8221; directory inside the container. This volume allows you to persist Prometheus&#8217;s data and configurations.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Step 2: Access Prometheus Web Interface<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Once the Prometheus container is up and running, open a web browser and navigate to <code>http:\/\/localhost:9090<\/code>. You will be directed to Prometheus&#8217;s web interface, where you can explore and configure the monitoring system.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Step 3: Add Prometheus Data Source<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To use Prometheus as a data source in visualization tools like Grafana, follow these steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open Grafana&#8217;s web interface, which should be available at <code>http:\/\/192.168.0.223:3000<\/code> (assuming Grafana is running on port 3000).<\/li>\n\n\n\n<li>Log in to Grafana using your credentials.<\/li>\n\n\n\n<li>Click on the &#8220;Configuration&#8221; (gear) icon in the sidebar and select &#8220;Data Sources.&#8221;<\/li>\n\n\n\n<li>Click on &#8220;Add data source.&#8221;<\/li>\n\n\n\n<li>Choose &#8220;Prometheus&#8221; from the list of available data sources.<\/li>\n\n\n\n<li>In the &#8220;HTTP&#8221; section, set the &#8220;URL&#8221; field to <code>http:\/\/localhost:9090<\/code> or the IP address of your Prometheus instance.<\/li>\n\n\n\n<li>Optionally, provide a custom name for the data source in the &#8220;Name&#8221; field.<\/li>\n\n\n\n<li>Click on &#8220;Save &amp; Test&#8221; to save the data source configuration.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">Congratulations! You have successfully set up Prometheus with Docker and added it as a data source in Grafana. You can now use Prometheus to monitor your applications and systems, as well as create dashboards and visualizations in Grafana.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Enjoy the power and flexibility of Prometheus for monitoring and alerting in your Docker environment! Happy monitoring!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction:Prometheus is a widely-used open-source monitoring and alerting toolkit. In this guide, we&#8217;ll show you how to set up Prometheus using Docker, allowing you to monitor your applications and systems efficiently. Step 1: Install&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":196,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[35],"class_list":["post-108","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","tag-ok"],"_links":{"self":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/comments?post=108"}],"version-history":[{"count":2,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/108\/revisions"}],"predecessor-version":[{"id":125,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/posts\/108\/revisions\/125"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media\/196"}],"wp:attachment":[{"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/media?parent=108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/categories?post=108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it4home.dk\/index.php\/wp-json\/wp\/v2\/tags?post=108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}