{"id":8921,"date":"2022-01-11T12:45:25","date_gmt":"2022-01-11T07:15:25","guid":{"rendered":"https:\/\/opstree.com\/blog\/\/?p=8921"},"modified":"2025-11-20T17:11:26","modified_gmt":"2025-11-20T11:41:26","slug":"four-main-metrics-of-prometheus","status":"publish","type":"post","link":"https:\/\/opstree.com\/blog\/2022\/01\/11\/four-main-metrics-of-prometheus\/","title":{"rendered":"Four Main Metrics of Prometheus"},"content":{"rendered":"\r\n<p class=\"has-text-align-justify\">Let&#8217;s first understand <strong>what Prometheus is<\/strong>:<\/p>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\">Prometheus is an open-source monitoring solution built primarily for gathering and analyzing time-series data, with specific built-in tools making it appropriate for monitoring Kubernetes and other containerized environments. It is a cross-platform monitoring tool that lets you collect metrics from servers, containers, and applications and work with them all in the same way.<\/p>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\">Now let&#8217;s understand <a href=\"https:\/\/opstree.com\/blog\/2024\/10\/01\/a-fun-and-easy-guide-to-monitoring-and-observability-with-prometheus\/\"><strong>Prometheus Architecture<\/strong><\/a> to know how it works:<\/p>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\">Prometheus is a multi-component system. While the following integrates into a Prometheus deployment, there is flexibility in which of these pieces are actually implemented.<\/p>\r\n\r\n\r\n\r\n<p><!--more--><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>Prometheus server (scrapes and stores metrics as time series data)<\/li>\r\n<li>client libraries for instrumenting application code<\/li>\r\n<li>push gateway (supports metrics collection from short-lived jobs)<\/li>\r\n<li>special-purpose exporters (Supports tools like HAProxy, StatsD, Graphite, etc.)<\/li>\r\n<li>alertmanager ( sends alerts based on triggers)<\/li>\r\n<li>additional support tools<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<figure class=\"wp-block-image size-large is-resized\"><img decoding=\"async\" class=\"wp-image-9505\" src=\"https:\/\/opstree.com\/blog\/\/wp-content\/uploads\/2021\/12\/screen-shot-2020-09-14-at-121814-pm.png?w=1024\" alt=\"\" width=\"800\" \/><\/figure>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\">Prometheus can scrape metrics from jobs directly or, for short-lived jobs by using a push gateway when the job exits. The scraped samples are stored locally and rules are applied to the data to aggregate and generate new time series from existing data or generate alerts based on user-defined triggers. While Prometheus comes with a functional Web dashboard or other API consumers can be used to visualize the collected data, with Grafana being the de facto default.<\/p>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\">Now let&#8217;s see <strong>why Prometheus<\/strong> has gained so much popularity as a monitoring tool:<\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li><strong>Prometheus is Pull based<\/strong>: it actively scrapes targets in order to retrieve metrics from them.<\/li>\r\n<li><strong>Centralised control<\/strong>: the whole configuration is done on Prometheus server side and not on the client side which means you can decide who to scrape, and how often you should scrape them.\u00a0<\/li>\r\n<li><strong>In-built Alerting facility: <\/strong>Prometheus pushes alerts to the <a href=\"https:\/\/opstree.com\/blog\/2019\/03\/05\/alertmanager-integration-with-prometheus\/\">Alert manager<\/a> via custom rules defined in configuration files. From there it will send notifications to different endpoints such as Slack, Google hangout etc.<\/li>\r\n<li><strong>Service discovery:<\/strong> Prometheus can discover your targets dynamically and automatically scrap new targets on demand. Prometheus offers a variety of service discovery options for discovering scrape targets, including Kubernetes, Consul, and many others.<\/li>\r\n<li><strong>Scalability<\/strong>: it is highly scalable. You can club different Prometheus servers to a single one using federation approach.\u00a0<\/li>\r\n<li>Last but not the least, Prometheus provides a <strong>functional query language called\u00a0PromQL<\/strong>(Prometheus Query Language), that lets the user select and aggregate time-series data in real-time.<\/li>\r\n<\/ul>\r\n<p><strong>[ Also Read: <a href=\"https:\/\/opstree.com\/blog\/2021\/07\/27\/introduction-to-prometheus-monitoring\/\">Introduction to Prometheus Monitoring<\/a> ]<\/strong><\/p>\r\n\r\n\r\n\r\n<h6 class=\"wp-block-heading\" id=\"prometheus-provides-4-different-types-of-metrics-that-work-in-most-situations-let-s-have-a-brief-discussion-on-each-one\">Prometheus provides 4 different types of metrics that work in most situations. Let&#8217;s have a brief discussion on each one.<\/h6>\r\n\r\n\r\n\r\n<ol>\r\n<li><strong>Counters<\/strong>: The counter metric type is used for any value that increases, such as a request count or error count. Importantly, a counter should never be used for a value that can decrease.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Here are a few situations when you can use counters:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>you want to record a value that only goes up<\/li>\r\n<li>you want to be able to later query how fast the value is increasing.<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<ol start=\"2\">\r\n<li><strong>Gauges<\/strong>: The gauge metric type can be used for values that go down as well as up, such as current memory usage or the number of items in a queue.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Here are a few situations when you can use gauges:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>you want to record a value that can go up or down<\/li>\r\n<li>you don\u2019t need to query its rate<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Below are a few examples where you can use gauges:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>memory usage<\/li>\r\n<li>queue size<\/li>\r\n<li>number of requests in progress<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<ol start=\"3\">\r\n<li><strong>Histograms:<\/strong> The histogram metric type measures the frequency of value observations that fall into specific predefined buckets. Like you could measure request duration for a specific HTTP request call using histograms. Rather than storing every duration for every request, Prometheus will make an approximation by storing the frequency of requests that fall into particular buckets.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Here are a few situations when you can use histograms:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>you want to take many measurements of a value, to later calculate averages or percentiles<\/li>\r\n<li>you\u2019re not bothered about the exact values, but are happy with an approximation<\/li>\r\n<li>you know what the range of values will be upfront, so can use the default bucket definitions or define your own<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Below are a few examples where you can use histograms:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>request duration<\/li>\r\n<li>response size<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<ol start=\"4\">\r\n<li><strong>Summaries: <\/strong>Summaries and histograms share a lot of similarities. Summaries preceded histograms, and the recommendation is very much to use histograms where possible.<\/li>\r\n<\/ol>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Here are a few situations when you can use summaries:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>you want to take many measurements of a value, to later calculate averages or percentiles<\/li>\r\n<li>you\u2019re not bothered about the exact values, but are happy with an approximation<\/li>\r\n<li>you don\u2019t know what the range of values will be upfront, so cannot use histograms<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<p class=\"has-text-align-justify\"><strong>Below are a few examples where you can use summaries:<\/strong><\/p>\r\n\r\n\r\n\r\n<ul>\r\n<li>request duration<\/li>\r\n<li>response size<\/li>\r\n<\/ul>\r\n\r\n\r\n\r\n<h3 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h3>\r\n\r\n\r\n\r\n<p>We have discussed what Prometheus is, how does it work and why it is most commonly used industry-wide. Prometheus uses different metrics which are pulled from servers and we have discussed major 4 metrics which you will encounter in day-to-day life.<\/p>\r\n\r\n\r\n\r\n<h6 class=\"wp-block-heading\" id=\"hope-this-blog-can-answer-your-queries-will-soon-meet-with-another-blog-till-then\">Hope this blog can answer your queries.<\/h6>\r\n\r\n\r\n\r\n<h4 id=\"hope-this-blog-can-answer-your-queries-will-soon-meet-with-another-blog-till-then\" class=\"has-medium-font-size wp-block-heading\">Will meet soon with another blog till then stay safe<\/h4>\r\n\r\n\r\n\r\n\r\n\r\n<p><strong style=\"font-weight: bold;\">Blog Pundit: <\/strong><a href=\"https:\/\/opstree.com\/blog\/\/author\/bhupendersinghb5dca0b393\/\"><strong>Bhupender rawat<\/strong><\/a> and <strong><a href=\"https:\/\/opstree.com\/blog\/\/author\/adeel109\/\"><strong>Adeel Ahmad<\/strong><\/a><\/strong><\/p>\r\n\r\n\r\n\r\n<p><strong>Opstree<\/strong> is an End to End <a href=\"https:\/\/opstree.com\/\">DevOps solution<\/a> provider<\/p>\r\n\r\n\r\n\r\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\"><\/div>\r\n<p><strong>Related Searches &#8211; <a href=\"https:\/\/opstree.com\/services\/database-and-data-engineering\/\" target=\"_blank\" rel=\"noopener\">Data Engineering Services<\/a> | <a href=\"https:\/\/opstree.com\/aws-partner\/\" target=\"_blank\" rel=\"noopener\">AWS Partner<\/a>\u00a0<\/strong><\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s first understand what Prometheus is: Prometheus is an open-source monitoring solution built primarily for gathering and analyzing time-series data, with specific built-in tools making it appropriate for monitoring Kubernetes and other containerized environments. It is a cross-platform monitoring tool that lets you collect metrics from servers, containers, and applications and work with them all &hellip; <a href=\"https:\/\/opstree.com\/blog\/2022\/01\/11\/four-main-metrics-of-prometheus\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Four Main Metrics of Prometheus&#8221;<\/span><\/a><\/p>\n","protected":false},"author":212268737,"featured_media":29900,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[28070474,2788],"tags":[460,768739287,728613662,728613664,4996032],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/opstree.com\/blog\/wp-content\/uploads\/2025\/11\/DevSecOps-1.jpg","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfDBOm-2jT","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/8921"}],"collection":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/users\/212268737"}],"replies":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/comments?post=8921"}],"version-history":[{"count":27,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/8921\/revisions"}],"predecessor-version":[{"id":29947,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/posts\/8921\/revisions\/29947"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media\/29900"}],"wp:attachment":[{"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/media?parent=8921"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/categories?post=8921"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/opstree.com\/blog\/wp-json\/wp\/v2\/tags?post=8921"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}