{"id":3594,"date":"2019-03-05T07:00:13","date_gmt":"2019-03-05T01:30:13","guid":{"rendered":"http:\/\/www.upnxtblog.com\/?p=3594"},"modified":"2020-04-23T12:34:56","modified_gmt":"2020-04-23T07:04:56","slug":"monitoring-docker-containers-using-prometheus-cadvisor-grafana","status":"publish","type":"post","link":"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/","title":{"rendered":"Monitoring Docker containers using Prometheus + cAdvisor + Grafana"},"content":{"rendered":"<div class='booster-block booster-read-block'><\/div><p>With the increasing adoption of containers and <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/03\/12\/introduction-to-microservices\/\">microservices<\/a> in the enterprises, monitoring utilities have to handle more services and server instances than ever before. Support for multi-dimensional data collection, querying and perfect dashboard visualization tool is a great strength and makes the right fit to be part of your operational toolset. In this post, we take look at\u00a0\u00a0Monitoring Docker containers using <strong><a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/05\/11\/prometheus-open-source-systems-monitoring-and-alerting-toolkit\/\">Prometheus<\/a> + <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/08\/02\/use-google-cadvisor-for-monitoring-your-containers-docker-tutorial\/\">cAdvisor<\/a> + Grafana.<\/strong><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3601\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/docker-prometheus-grafana\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/Docker-Prometheus-Grafana.png?fit=592%2C199&amp;ssl=1\" data-orig-size=\"592,199\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Docker-Prometheus-Grafana\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/Docker-Prometheus-Grafana.png?fit=592%2C199&amp;ssl=1\" class=\"aligncenter size-full wp-image-3601 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/Docker-Prometheus-Grafana.png?resize=592%2C199\" alt=\"\" width=\"592\" height=\"199\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/Docker-Prometheus-Grafana.png?w=592&amp;ssl=1 592w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/Docker-Prometheus-Grafana.png?resize=300%2C101&amp;ssl=1 300w\" data-sizes=\"auto, (max-width: 592px) 100vw, 592px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 592px; --smush-placeholder-aspect-ratio: 592\/199;\" \/><\/p>\n<p>This quickstart assumes basic understanding of Docker\u00a0<a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/\">concepts<\/a>, please refer to earlier posts for understanding on Docker &amp; how to <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/12\/how-to-install-docker-on-ubuntu\/\">install<\/a> and containerize <a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/09\/19\/docker-tutorial-build-docker-image-for-your-angular-6-application\/\">applications<\/a>.<\/p>\n\n<h2>Architecture<\/h2>\n<p>We are going to use the following tools to collect, aggregate &amp; visualize metrics.<\/p>\n<ol>\n<li>Container metrics using <strong><a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/08\/02\/use-google-cadvisor-for-monitoring-your-containers-docker-tutorial\/\"><em>cAdvisor<\/em><\/a><\/strong><\/li>\n<li>Host metrics using <strong><em>Prometheus Node Exporter<\/em><\/strong><\/li>\n<li>Alerting using <strong><em>Prometheus Alert Manager<\/em><\/strong><\/li>\n<li>Visualization using <strong><em>Grafana<\/em><\/strong> pre-built dashboards<\/li>\n<\/ol>\n<p><strong><a href=\"https:\/\/github.com\/prometheus\" target=\"_blank\" rel=\"noopener\">Prometheus<\/a>\u00a0<\/strong>is an open-source systems monitoring and alerting toolkit originally built at\u00a0<a href=\"http:\/\/soundcloud.com\/\" target=\"_blank\" rel=\"noopener\">SoundCloud<\/a>.\u00a0<a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/05\/11\/prometheus-open-source-systems-monitoring-and-alerting-toolkit\/\">Prometheus<\/a> collects metrics from monitored targets by scraping metrics HTTP endpoints, we are going to configure it to scrape metrics for containers from <a href=\"https:\/\/github.com\/google\/cadvisor\" target=\"_blank\" rel=\"noopener\">cAdvisor<\/a>\u00a0and node metrics from Prometheus Node exporter.<\/p>\n<figure id=\"attachment_3596\" aria-describedby=\"caption-attachment-3596\" style=\"width: 1707px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3596\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/monitoring\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?fit=1707%2C939&amp;ssl=1\" data-orig-size=\"1707,939\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"monitoring\" data-image-description=\"&lt;p&gt;Monitoring Architecture&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Monitoring Architecture&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?fit=1024%2C563&amp;ssl=1\" class=\"size-full wp-image-3596 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?resize=1140%2C627\" alt=\"Monitoring Architecture\" width=\"1140\" height=\"627\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?w=1707&amp;ssl=1 1707w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?resize=300%2C165&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?resize=768%2C422&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?resize=1024%2C563&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring.png?resize=600%2C330&amp;ssl=1 600w\" data-sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1140px; --smush-placeholder-aspect-ratio: 1140\/627;\" \/><figcaption id=\"caption-attachment-3596\" class=\"wp-caption-text\">Image &#8211; Monitoring Architecture<\/figcaption><\/figure>\n<h2>#1. Prepare Docker Compose Configuration<\/h2>\n<p>Create New Project directory and prepare Docker compose file like the one below<\/p>\n<pre>version: '3'\r\nservices:\r\nprometheus:\r\n    image: 'prom\/prometheus:v2.1.0'\r\n    container_name: prometheus\r\n    ports:\r\n    - '9090:9090'\r\n    command:\r\n    - '--config.file=\/etc\/prometheus\/prometheus.yml'\r\n    - '--storage.tsdb.path=\/prometheus'\r\n    - '--web.console.libraries=\/usr\/share\/prometheus\/console_libraries'\r\n    - '--web.console.templates=\/usr\/share\/prometheus\/consoles'\r\n    volumes:\r\n    - '.\/prometheus.yml:\/etc\/prometheus\/prometheus.yml:ro'\r\n    - '.\/alert.rules:\/etc\/prometheus\/alert.rules'\r\n    depends_on:\r\n    - cadvisor\r\n    networks:\r\n    - samplenet\r\ncadvisor:\r\n    image: google\/cadvisor\r\n    container_name: cadvisor\r\n    ports:\r\n    - '8081:8081'\r\n    volumes:\r\n    - '\/:\/rootfs:ro'\r\n    - '\/var\/run:\/var\/run:rw'\r\n    - '\/sys:\/sys:ro'\r\n    - '\/var\/lib\/docker\/:\/var\/lib\/docker:ro'\r\n    networks:\r\n    - samplenet\r\nalertmanager:\r\n    image: prom\/alertmanager\r\n    ports:\r\n    - '9093:9093'\r\n    volumes:\r\n    - '.\/alertmanager\/:\/etc\/alertmanager\/'\r\n    restart: always\r\n    command:\r\n    - '--config.file=\/etc\/alertmanager\/config.yml'\r\n    - '--storage.path=\/alertmanager'\r\n    networks:\r\n    - samplenet\r\nnode-exporter:\r\n    image: prom\/node-exporter\r\n    volumes:\r\n     - '\/proc:\/host\/proc:ro'\r\n     - '\/sys:\/host\/sys:ro'\r\n     - '\/:\/rootfs:ro'\r\n    command:\r\n     - '--path.procfs=\/host\/proc'\r\n     - '--path.sysfs=\/host\/sys'\r\n     - '--collector.filesystem.ignored-mount-points'\r\n     - ^\/(sys|proc|dev|host|etc|rootfs\/var\/lib\/docker\/containers|rootfs\/var\/lib\/docker\/overlay2|rootfs\/run\/docker\/netns|rootfs\/var\/lib\/docker\/aufs)($$|\/)\r\n    ports:\r\n     - '9100:9100'\r\n    networks:\r\n     - samplenet\r\n    restart: always\r\ngrafana:\r\n    image: grafana\/grafana\r\n    depends_on:\r\n    - prometheus\r\n    ports:\r\n    - '3000:3000'\r\n    volumes:\r\n    - 'grafana_data:\/var\/lib\/grafana'\r\n    - '.\/grafana\/provisioning\/:\/etc\/grafana\/provisioning\/'\r\n    env_file:\r\n    - .\/grafana\/config.monitoring\r\n    networks:\r\n    - samplenet\r\n    restart: always\r\nvolumes:\r\ngrafana_data: {}\r\nprometheus_data: {}\r\n\r\n<\/pre>\n<h2>#2.Prometheus Node Exporter Configuration<\/h2>\n<p>On the compose file, mount the <code>host \/proc<\/code> and <code>\/sys<\/code> directory so that the container has access to the necessary information to report on.<\/p>\n<h2>#3.cAdvisor Configuration<\/h2>\n<p>On the compose file, mount the <code>var\/run, \/sys<\/code> directory<code> \/var\/lib\/docker<\/code> so that the cAdvisor can collect container metrics and report to Prometheus.<\/p>\n<h2>#4.Prometheus Configuration<\/h2>\n<p>Create new Prometheus configuration in a file called\u00a0<code>prometheus.yml<\/code>\u00a0. Prometheus server requires a configuration file that defines the endpoints to scrape along with how frequently the metrics should be accessed and to define the servers and ports that Prometheus should scrape data from. In the below example, we have defined 3 targets (<em>1st one for Prometheus itself, 2nd One for collecting container metrics using cAdvisor and last one is for node metrics using Node exporter<\/em>) running on different ports.<\/p>\n<pre>scrape_configs:\r\n- job_name: prometheus\r\nscrape_interval: 5s\r\nstatic_configs:\r\n- targets:\r\n- prometheus:9090\r\n\r\n- job_name: cadvisor\r\nscrape_interval: 5s\r\nstatic_configs:\r\n- targets:\r\n- cadvisor:8081\r\n\r\n- job_name: node-exporter\r\nscrape_interval: 5s\r\nstatic_configs:\r\n- targets:\r\n- node-exporter:9100\r\n\r\nalerting:\r\nalertmanagers:\r\n- static_configs:\r\n- targets: \r\n- alertmanager:9093\r\n\r\nrule_files:\r\n- 'alert.rules'<\/pre>\n<p>For a complete specification of configuration options, see the\u00a0<a href=\"https:\/\/prometheus.io\/docs\/operating\/configuration\" target=\"_blank\" rel=\"noopener\">configuration documentation<\/a>.<\/p>\n<h2>#5.Alert Manager Configuration<\/h2>\n<p>Alert Manager takes care of de-duplicating, grouping, and routing the alerts to the correct receiver integration such as email, slack channels, etc.,<\/p>\n<p>We are going to make use of default configuration like the example below, create a new folder <code>alertmanager<\/code> and paste the configuration file (<code>config.yml<\/code>)<\/p>\n<pre>route:\r\n   receiver: 'slack'\r\n\r\nreceivers:\r\n   - name: 'slack'\r\n      slack_configs:\r\n      - send_resolved: true\r\n      username: '&lt;username&gt;'\r\n      channel: '#&lt;channel-name&gt;'\r\n      api_url: '&lt;incomming-webhook-url&gt;'\r\n\r\n<\/pre>\n<h2>#6.Grafana Configuration<\/h2>\n<p><a href=\"https:\/\/grafana.com\/\" target=\"_blank\" rel=\"noopener\">Grafana<\/a> would be the dashboard visualization tool of choice for Prometheus users and support for Grafana ships with the tool. For monitoring Docker containers, we are going to import pre-built dashboards from<a href=\"https:\/\/grafana.com\/dashboards\/179\" target=\"_blank\" rel=\"noopener\"> Grafana.com.<\/a><\/p>\n<p>Create new folder <code>Grafana<\/code> and copy the contents from the <a href=\"https:\/\/github.com\/karthi4india\/prometheus\/\" target=\"_blank\" rel=\"noopener\">source<\/a> to automate the provisioning of data sources &amp; dashboards. For the full Grafana installation instructions, see the <a href=\"http:\/\/docs.grafana.org\/installation\/\" target=\"_blank\" rel=\"noopener\">official Grafana documentation<\/a>.<\/p>\n<p>Finally, our folder would look like the one below.<\/p>\n<figure id=\"attachment_3612\" aria-describedby=\"caption-attachment-3612\" style=\"width: 897px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3612\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/monitoring2-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?fit=897%2C469&amp;ssl=1\" data-orig-size=\"897,469\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1549886017&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}\" data-image-title=\"monitoring2\" data-image-description=\"&lt;p&gt;Monitoring Folder structure&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Monitoring Folder structure&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?fit=897%2C469&amp;ssl=1\" class=\"size-full wp-image-3612 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?resize=897%2C469\" alt=\"Monitoring Folder structure\" width=\"897\" height=\"469\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?w=897&amp;ssl=1 897w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?resize=300%2C157&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?resize=768%2C402&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.jpg?resize=600%2C314&amp;ssl=1 600w\" data-sizes=\"auto, (max-width: 897px) 100vw, 897px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 897px; --smush-placeholder-aspect-ratio: 897\/469;\" \/><figcaption id=\"caption-attachment-3612\" class=\"wp-caption-text\">Image &#8211; Monitoring Folder structure<\/figcaption><\/figure>\n<p><em>Congrats! we have now configured all tools to monitor our containers, let&#8217;s start the compose and check.<\/em><\/p>\n<h2>#7.View Metrics<\/h2>\n<p>Start the Docker compose using <code>docker-compose up -d<\/code><\/p>\n<p>Once all the containers are up, Prometheus will now scrape and store the data based on the configuration. Prometheus is configured on port <code>9090<\/code>, Go to the dashboard <code>http:\/\/localhost:9090<\/code> and verify that Prometheus now has information about the time series information on the containers, node.<\/p>\n<p>Use the dropdown next to the &#8220;Execute&#8221; button to see a list of metrics this server is collecting. In the list, you&#8217;ll see a number of metrics prefixed with <code>node_<\/code>, that have been collected by the Node Exporter. For example, you can see the node&#8217;s CPU usage via the\u00a0<code>node_cpu<\/code>\u00a0metric.<\/p>\n<p>With this expression browser, you can enter any expression and see its result either in a table or graph over time.<\/p>\n<figure id=\"attachment_2395\" aria-describedby=\"caption-attachment-2395\" style=\"width: 1311px\" class=\"wp-caption alignnone\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"2395\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/05\/11\/prometheus-open-source-systems-monitoring-and-alerting-toolkit\/pro3\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?fit=1311%2C609&amp;ssl=1\" data-orig-size=\"1311,609\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"pro3\" data-image-description=\"&lt;p&gt;Prometheus Dashboard&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Prometheus Dashboard&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?fit=1024%2C476&amp;ssl=1\" class=\"wp-image-2395 size-full lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?resize=1140%2C530\" alt=\"Prometheus Dashboard\" width=\"1140\" height=\"530\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?w=1311&amp;ssl=1 1311w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?resize=300%2C139&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?resize=768%2C357&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?resize=1024%2C476&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2018\/04\/pro3.png?resize=1100%2C511&amp;ssl=1 1100w\" data-sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1140px; --smush-placeholder-aspect-ratio: 1140\/530;\" \/><figcaption id=\"caption-attachment-2395\" class=\"wp-caption-text\">Image &#8211; Prometheus Dashboard<\/figcaption><\/figure>\n<p>Grafana will be listening on\u00a0<code>http:\/\/localhost:3000<\/code>. The default login is <code>\"admin\" \/ \"admin\"<\/code>, once you log in use the &#8220;Filter&#8221; option to browse for dashboards. From the list, choose &#8220;<em><strong>Docker Prometheus Monitoring<\/strong><\/em>&#8221; to view it.<\/p>\n<figure id=\"attachment_3609\" aria-describedby=\"caption-attachment-3609\" style=\"width: 1003px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3609\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/monitoring1-2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?fit=1003%2C475&amp;ssl=1\" data-orig-size=\"1003,475\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"monitoring1\" data-image-description=\"&lt;p&gt;Node metrics &lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Node metrics &lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?fit=1003%2C475&amp;ssl=1\" class=\"size-full wp-image-3609 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?resize=1003%2C475\" alt=\"Node metrics \" width=\"1003\" height=\"475\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?w=1003&amp;ssl=1 1003w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?resize=300%2C142&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?resize=768%2C364&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring1.png?resize=600%2C284&amp;ssl=1 600w\" data-sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1003px; --smush-placeholder-aspect-ratio: 1003\/475;\" \/><figcaption id=\"caption-attachment-3609\" class=\"wp-caption-text\">Image &#8211; Host metrics<\/figcaption><\/figure>\n<figure id=\"attachment_3610\" aria-describedby=\"caption-attachment-3610\" style=\"width: 1162px\" class=\"wp-caption aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3610\" data-permalink=\"https:\/\/www.upnxtblog.com\/index.php\/2019\/03\/05\/monitoring-docker-containers-using-prometheus-cadvisor-grafana\/monitoring2\/\" data-orig-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?fit=1162%2C504&amp;ssl=1\" data-orig-size=\"1162,504\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"monitoring2\" data-image-description=\"&lt;p&gt;Container Metrics \/ Alerts&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Image &amp;#8211; Container Metrics \/ Alerts&lt;\/p&gt;\n\" data-large-file=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?fit=1024%2C444&amp;ssl=1\" class=\"size-full wp-image-3610 lazyload\" data-src=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?resize=1140%2C494\" alt=\"Container Metrics \/ Alerts\" width=\"1140\" height=\"494\" data-srcset=\"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?w=1162&amp;ssl=1 1162w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?resize=300%2C130&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?resize=768%2C333&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?resize=1024%2C444&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/monitoring2.png?resize=600%2C260&amp;ssl=1 600w\" data-sizes=\"auto, (max-width: 1140px) 100vw, 1140px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1140px; --smush-placeholder-aspect-ratio: 1140\/494;\" \/><figcaption id=\"caption-attachment-3610\" class=\"wp-caption-text\">Image &#8211; Container Metrics \/ Alerts<\/figcaption><\/figure>\n<p>If you want to modify Dashboard or data source, you should manually edit the downloaded JSON files and correct the <code>datasource:<\/code>\u00a0entries to reflect the Grafana data source name which you chose for your Prometheus server. Use the &#8220;Dashboards&#8221; \u2192 &#8220;Home&#8221; \u2192 &#8220;Import&#8221; option to import the edited dashboard file into your Grafana install.<\/p>\n<p>All source files used for this article can be found <a href=\"https:\/\/github.com\/karthi4india\/prometheus\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>In this post, we have got introduced on how to set up targets in Prometheus, configure Prometheus, cAdvisor, Node Exporter and Alert Manager to monitor both containers and host resources.<\/p>\n<p><em><strong>Like this post? Don\u2019t forget to share it!<\/strong><\/em><\/p>\n<h2>Additional Resources<\/h2>\n<ul>\n<li><a href=\"https:\/\/prometheus.io\/docs\/introduction\/overview\/\" target=\"_blank\" rel=\"noopener\">Prometheus Documentation<\/a><\/li>\n<li><a href=\"https:\/\/prometheus.io\/docs\/operating\/configuration\" target=\"_blank\" rel=\"noopener\">Prometheus Configuration options<\/a><\/li>\n<li><a href=\"https:\/\/prometheus.io\/docs\/guides\/\" target=\"_blank\" rel=\"noopener\">Prometheus Guides<\/a><\/li>\n<li><a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/05\/11\/prometheus-open-source-systems-monitoring-and-alerting-toolkit\/\">Prometheus Tutorial<\/a><\/li>\n<li><a href=\"http:\/\/www.upnxtblog.com\/index.php\/2018\/08\/02\/use-google-cadvisor-for-monitoring-your-containers-docker-tutorial\/\">Google cAdvisor for monitoring your containers + Docker tutorial<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2018\/01\/17\/top-6-gui-tools-for-managing-docker-environments\/\">TOP 6 GUI tools for managing Docker environments<\/a><\/li>\n<li><a href=\"https:\/\/www.upnxtblog.com\/index.php\/2017\/11\/29\/docker-tutorial-build-docker-image-for-your-java-application\/\">Docker tutorial \u2013 Build Docker image for your Java application<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>With the increasing adoption of containers and microservices in the enterprises, monitoring utilities have to handle more services and server instances than ever before. Support for multi-dimensional data collection, querying and perfect dashboard visualization tool is a great strength and makes the right fit to be part of your operational toolset. In this post, we [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":3601,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Monitoring Docker containers using Prometheus + cAdvisor + Grafana","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[310,37],"tags":[283,53,326,254],"class_list":["post-3594","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","category-how-to-guides","tag-cadvisor","tag-docker","tag-grafana","tag-prometheus"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2019\/02\/Docker-Prometheus-Grafana.png?fit=592%2C199&ssl=1","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9fbQS-VY","jetpack-related-posts":[{"id":4702,"url":"https:\/\/www.upnxtblog.com\/index.php\/2019\/12\/25\/15-best-and-the-most-popular-reads-for-this-year\/","url_meta":{"origin":3594,"position":0},"title":"15 BEST and the most popular reads for this year","author":"Karthik","date":"December 25, 2019","format":false,"excerpt":"Here are 15 best and the most popular reads for this year, hope you would love this compilation. As always, please feel free to leave your comment in case of any questions or additional inputs. Happy Holidays and Good Luck! #1.TOP 6 GUI tools for managing Docker environments (44,406 views)\u2026","rel":"","context":"In &quot;Trending&quot;","block_context":{"text":"Trending","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/trending\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2390,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/05\/11\/prometheus-open-source-systems-monitoring-and-alerting-toolkit\/","url_meta":{"origin":3594,"position":1},"title":"Tutorial : Prometheus open-source systems monitoring and alerting toolkit","author":"Karthik","date":"May 11, 2018","format":false,"excerpt":"Prometheus\u00a0is an open-source systems monitoring and alerting toolkit originally built at\u00a0SoundCloud.Prometheus primarily supports a pull-based HTTP model but it also supports alerts, it would be the right fit to be part of your operational toolset. Prometheus works well for recording any purely numeric time series. It fits both machine-centric monitoring\u2026","rel":"","context":"In &quot;Cloud Computing&quot;","block_context":{"text":"Cloud Computing","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/cloud\/"},"img":{"alt_text":"Prometheus architecture","src":"https:\/\/prometheus.io\/assets\/architecture.svg","width":350,"height":200,"srcset":"https:\/\/prometheus.io\/assets\/architecture.svg 1x, https:\/\/prometheus.io\/assets\/architecture.svg 1.5x"},"classes":[]},{"id":5923,"url":"https:\/\/www.upnxtblog.com\/index.php\/2020\/12\/25\/top-10-posts-for-this-year-2020\/","url_meta":{"origin":3594,"position":2},"title":"TOP 10 Posts for this year 2020","author":"Karthik","date":"December 25, 2020","format":false,"excerpt":"Here are TOP 10 best and the most popular reads for this year, hope you would love this compilation. As always, please feel free to leave your comment in case of any questions or additional inputs. Happy Holidays and Good Luck! #1.TOP 6 GUI tools for managing Docker environments As\u2026","rel":"","context":"In &quot;Trending&quot;","block_context":{"text":"Trending","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/trending\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2020\/12\/upnxtblog-banner-1.png?fit=300%2C350&ssl=1&resize=350%2C200","width":350,"height":200},"classes":[]},{"id":2755,"url":"https:\/\/www.upnxtblog.com\/index.php\/2018\/08\/02\/use-google-cadvisor-for-monitoring-your-containers-docker-tutorial\/","url_meta":{"origin":3594,"position":3},"title":"Use Google cAdvisor for monitoring your containers + Docker tutorial","author":"Karthik","date":"August 2, 2018","format":false,"excerpt":"If you're looking for tool to\u00a0understand the resource usage and performance characteristics of the running containers then\u00a0cAdvisor (Container Advisor) is the perfect tool that provides container metrics.It is a running daemon that collects, aggregates, processes, and exports information about running containers. Specifically, for each container it keeps resource isolation parameters,\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"cAdvisor (Container Advisor)","src":"https:\/\/i0.wp.com\/github.com\/google\/cadvisor\/raw\/master\/logo.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/github.com\/google\/cadvisor\/raw\/master\/logo.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/github.com\/google\/cadvisor\/raw\/master\/logo.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":3686,"url":"https:\/\/www.upnxtblog.com\/index.php\/2019\/04\/29\/prometheus-vs-weavescope-vs-datadog-vs-sysdig-monitoring-tools-compared\/","url_meta":{"origin":3594,"position":4},"title":"Prometheus vs WeaveScope vs DataDog vs Sysdig monitoring tools compared","author":"Karthik","date":"April 29, 2019","format":false,"excerpt":"With the increasing adoption of containers and microservices in the enterprises, monitoring utilities now have to handle more services and server instances than ever before. Although infrastructure landscape has changed, operations teams still need to monitor the same metrics on CPU, RAM, File System, Network utilization, and the availability of\u2026","rel":"","context":"In &quot;Kubernetes Guides&quot;","block_context":{"text":"Kubernetes Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/kubernetes\/"},"img":{"alt_text":"kubernetes logo","src":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.upnxtblog.com\/wp-content\/uploads\/2017\/11\/kubernetes.jpg?fit=722%2C612&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3821,"url":"https:\/\/www.upnxtblog.com\/index.php\/2019\/05\/23\/everything-you-need-to-know-about-docker-enterprise-3-0\/","url_meta":{"origin":3594,"position":5},"title":"Everything You Need To Know About Docker Enterprise 3.0","author":"Karthik","date":"May 23, 2019","format":false,"excerpt":"Docker has recently announced Docker Enterprise 3.0, In this post, we take look at the key features of Enterprise Platform on how it improves developer productivity, accelerating time-to-market for new applications. If you're looking for the basic understanding of Docker concepts, please refer to earlier posts for understanding on Docker\u2026","rel":"","context":"In &quot;Docker Guides&quot;","block_context":{"text":"Docker Guides","link":"https:\/\/www.upnxtblog.com\/index.php\/category\/docker\/"},"img":{"alt_text":"Docker Enterprise Platform","src":"https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=1050%2C600 3x, https:\/\/i0.wp.com\/blog.docker.com\/wp-content\/uploads\/2019\/04\/3222109f-b13e-4204-bd00-0c2ae19a9b6d-1.jpg?ssl=1&resize=1400%2C800 4x"},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3594","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=3594"}],"version-history":[{"count":16,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3594\/revisions"}],"predecessor-version":[{"id":5420,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/posts\/3594\/revisions\/5420"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/media\/3601"}],"wp:attachment":[{"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=3594"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=3594"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.upnxtblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=3594"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}