{"id":751,"date":"2024-03-28T11:37:00","date_gmt":"2024-03-28T11:37:00","guid":{"rendered":"https:\/\/blog.ngocha.biz\/?p=751"},"modified":"2024-03-28T11:37:00","modified_gmt":"2024-03-28T11:37:00","slug":"prometheus-architecture","status":"publish","type":"post","link":"https:\/\/blog.ngocha.biz\/?p=751","title":{"rendered":"Learn Prometheus Architecture: A Complete Guide"},"content":{"rendered":"<p>In this guide, we will look at Prometheus architecture in detail to understand, configure, and leverage Prometheus architecture effectively.<\/p>\n<p>Prometheus is a popular open-source monitoring and alerting system written in Golang, capable of <strong>collecting and processing metrics<\/strong> from various targets. You can also query, view, analyse the metrics and get alerted based on the thresholds.<\/p>\n<p>Also, in today&#8217;s world, <a href=\"https:\/\/devopscube.com\/what-is-observability\/\">observability<\/a> is becoming paramount for every organisation, and Prometheus is one of the key observability tools in the open source space.<\/p>\n<h2 id=\"what-is-prometheus-architecture\">What is Prometheus Architecture?<\/h2>\n<p>Here is the high level overview of Prometheus architecture.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-architecture.gif\" class=\"kg-image\" alt=\"Prometheus Architecture- Components Workflow\" loading=\"lazy\" width=\"1280\" height=\"720\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/prometheus-architecture.gif 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/prometheus-architecture.gif 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-architecture.gif 1280w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Prometheus primarily consists of the following.<\/p>\n<ol>\n<li>Prometheus Server<\/li>\n<li>Service Discovery<\/li>\n<li>Time-Series Database (TSDB)<\/li>\n<li>Targets<\/li>\n<li>Exporters<\/li>\n<li>Push Gateway<\/li>\n<li>Alert Manager<\/li>\n<li>Client Libraries<\/li>\n<li>PromQL<\/li>\n<\/ol>\n<p>Lets look at each component in detail.<\/p>\n<h2 id=\"prometheus-server\"><strong>Prometheus Server<\/strong><\/h2>\n<p>The Prometheus server is the <strong>brain of the metric-based monitoring system<\/strong>. The main job of the server is to collect the metrics from various targets using pull model.<\/p>\n<p>Target is nothing but a server, pod, endpoints etc which we will look in to detail in the next topic.<\/p>\n<p>The general term for collecting metrics from the targets using Prometheus is called <strong>scraping.<\/strong><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-server-1.gif\" class=\"kg-image\" alt=\"Prometheus Server components\" loading=\"lazy\" width=\"848\" height=\"720\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/prometheus-server-1.gif 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/prometheus-server-1.gif 848w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Prometheus periodically scrapes the metrics, based on the <strong>scrape interval<\/strong> that we mention in the <strong>Prometheus configuration file.<\/strong><\/p>\n<p>Here is an example configuration.<\/p>\n<pre><code>global:\n  scrape_interval: 15s \n  evaluation_interval: 15s \n  scrape_timeout: 10s \n\nrule_files:\n  - \"rules\/*.rules\"\n\nscrape_configs:\n  - job_name: 'prometheus'\n    static_configs:\n      - targets: ['localhost:9090'] \n  - job_name: 'node-exporter'\n    static_configs:\n      - targets: ['node-exporter:9100'] \n\nalerting:\n  alertmanagers:\n    - static_configs:\n        - targets: ['alertmanager:9093']\n<\/code><\/pre>\n<h2 id=\"time-series-database-tsdb\"><strong>Time-Series Database (TSDB)<\/strong><\/h2>\n<p>The metric data which prometheus receives changes over time (CPU, memory, network IO etc..). It is called time-series data.  So Prometheus uses a <strong>Time Series Database<\/strong> (TSDB) to store all its data.<\/p>\n<p>By default Prometheus stores all its data in an <strong>efficient format (chunks)<\/strong> in the local disk. Overtime, it <strong>compacts all the old data<\/strong> to save space. It also has retention policy to get rid of old data.<\/p>\n<p>The TSDB has inbuilt mechanisms to manage data kept for long time. You can choose any of the following data retention policies.<\/p>\n<ol>\n<li><strong>Time based retention:<\/strong> Data will be kept for the specified days. The default retention is 15 days.<\/li>\n<li><strong>Size-based retention<\/strong>: You can specify the maximum data TSDB can hold. Once this limit it reached, prometheus will free up the space to accommodate new data.<\/li>\n<\/ol>\n<p>Prometheus also offers <strong>remote storage options<\/strong>. This is primarily required for storage scalability, long-term storage, backup &amp; disaster recovery etc.<\/p>\n<h2 id=\"prometheus-targets\"><strong>Prometheus Targets<\/strong><\/h2>\n<p>Target is the <strong>source<\/strong> where Prometheus scrape the metrics. A target could be servers, services, <a href=\"https:\/\/devopscube.com\/kubernetes-pod\/\">Kubernetes pods<\/a>, application endpoints, etc.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/target.png\" class=\"kg-image\" alt=\"prometheus targets\" loading=\"lazy\" width=\"2000\" height=\"1315\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/target.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/target.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/target.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w2400\/2025\/03\/target.png 2400w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>By default prometheus looks for metrics under <strong><code>\/metrics<\/code><\/strong> path of the target. The default path can be changed in the target configuration. This means, if you dont specify a custom metric path, Prometheus looks for the metrics under <strong><code>\/metrics<\/code><\/strong>.<\/p>\n<p>Target configurations are present under the <strong>scrape_configs<\/strong> in the <code>Prometheus<\/code> configuration file. Here is an example configuration.<\/p>\n<pre><code>scrape_configs:\n  \n  - job_name: 'node-exporter'\n    static_configs:\n      - targets: ['node-exporter1:9100', 'node-exporter2:9100']\n \n  - job_name: 'my_custom_job'\n    static_configs:\n      - targets: ['my_service_address:port']\n    metrics_path: '\/custom_metrics'\n\n  - job_name: 'blackbox-exporter'\n    static_configs:\n      - targets: ['blackbox-exporter1:9115', 'blackbox-exporter2:9115']\n    metrics_path: \/probe\n\n  - job_name: 'snmp-exporter'\n    static_configs:\n      - targets: ['snmp-exporter1:9116', 'snmp-exporter2:9116']\n    metrics_path: \/snmp<\/code><\/pre>\n<p>From the target endpoints, prometheus <strong>expects data in certain text format<\/strong>. Each metric has to be on a new line.<\/p>\n<p>Usually these metrics are exposed on target nodes using <strong>prometheus exporters<\/strong> running on the targets.<\/p>\n<h2 id=\"prometheus-exporters\"><strong>Prometheus Exporters<\/strong><\/h2>\n<p>Exporters are like agents that run on the targets. It <strong>converts metrics<\/strong> from specific system to format that prometheus understands.<\/p>\n<p>It could be system metrics like CPU, memory etc, or Java JMX metrics, MySQL metrics etc.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-118-9.png\" class=\"kg-image\" alt=\"Prometheus exporters\" loading=\"lazy\" title=\"nb\" width=\"808\" height=\"624\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-118-9.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-118-9.png 808w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>By default these converted metrics are exposed by the exporter on <strong><code>\/metrics<\/code><\/strong> path(HTTPS endpoint) of the target.<\/p>\n<p>For example, if you want to <strong>monitor a servers CPU and memory<\/strong>, you need to install a node exporter on that server and the <strong>node exporter exposes<\/strong> the CPU and memory metrics in the prometheus metrics format on <strong><code>\/metrics<\/code><\/strong>.<\/p>\n<p>Once the Prometheus <strong>pulls<\/strong> the metrics, it will then combine the <strong>metric name, labels, value, and timestamp<\/strong> to give a <strong>structure<\/strong> to that data.<\/p>\n<p>There are a lot of community <strong>Exporters<\/strong> available, but only some of them are officially approved  by Prometheus. In cases where you need more customizations, you need to create your own exporters.<\/p>\n<p>Prometheus categorized the <strong>Exporters<\/strong> in various sections such as Databases, Hardware, Issue trackers and continuous integration, Messaging systems, Storage, Software exposing Prometheus metrics, Other third-party utilities, etc.<\/p>\n<p>You can see the list of <strong>Exporters<\/strong> from each category from the <a href=\"https:\/\/prometheus.io\/docs\/instrumenting\/exporters\/?ref=devopscube.com\" rel=\"noreferrer noopener\">official documentation<\/a>.<\/p>\n<p>In the Prometheus configuration file, all the exporters&#8217; details will be given under the <code>scrape_configs<\/code>.<\/p>\n<pre><code>scrape_configs:\n  - job_name: 'node-exporter'\n    static_configs:\n      - targets: ['node-exporter1:9100', 'node-exporter2:9100']\n\n  - job_name: 'blackbox-exporter'\n    static_configs:\n      - targets: ['blackbox-exporter1:9115', 'blackbox-exporter2:9115']\n    metrics_path: \/probe\n\n  - job_name: 'snmp-exporter'\n    static_configs:\n      - targets: ['snmp-exporter1:9116', 'snmp-exporter2:9116']\n    metrics_path: \/snmp<\/code><\/pre>\n<h2 id=\"prometheus-service-discovery\">Prometheus Service Discovery<\/h2>\n<p>Prometheus uses two methods to scrape metrics from the targets.<\/p>\n<ol>\n<li><strong>Static configs<\/strong>: When the targets have a static IP or DNS endpoint, we can use those endpoints as targets.<\/li>\n<li><strong>Sevice Discovery:<\/strong> In most autoscaling systems and distributed systems like Kubernetes, the target will not have a static endpoint. In this case, that target endpoints are discovered using prometheus service discovery and targets are added automatically to the prometheus configuration.<\/li>\n<\/ol>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/service-discovery-2.png\" class=\"kg-image\" alt=\"prometheus service discovery\" loading=\"lazy\" width=\"2000\" height=\"1487\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/service-discovery-2.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/service-discovery-2.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1600\/2025\/03\/service-discovery-2.png 1600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w2400\/2025\/03\/service-discovery-2.png 2400w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Before going further, let me show a small example of the <strong>Kubernetes service discovery<\/strong> block of the <strong>Prometheus configuration<\/strong> file using <code>kubernetes_sd_configs<\/code>.<\/p>\n<pre><code>scrape_configs:\n      - job_name: 'kubernetes-apiservers'\n        kubernetes_sd_configs:\n        - role: endpoints\n        scheme: https\n        tls_config:\n          ca_file: \/var\/run\/secrets\/kubernetes.io\/serviceaccount\/ca.crt\n        bearer_token_file: \/var\/run\/secrets\/kubernetes.io\/serviceaccount\/token\n        relabel_configs:\n        - source_labels: [__meta_kubernetes_namespace, __meta_kubernetes_service_name, __meta_kubernetes_endpoint_port_name]\n          action: keep\n          regex: default;kubernetes;https<\/code><\/pre>\n<p>Kubernetes is the perfect example for <strong>dynamic targets.<\/strong>  Here, you cannot use the static targets method, because targets (pods) in a <a href=\"https:\/\/devopscube.com\/setup-kubernetes-cluster-kubeadm\/\">Kubernetes cluster<\/a> is ephemeral in nature and could be short lived.<\/p>\n<p>There is also <strong>File-Based Service Discovery<\/strong> <code>file_sd_configs<\/code> in Kubernetes. It is for static targets, but the main difference between the classic <strong>Static configuration <\/strong><code>static_configs<\/code> and the <code>file_sd_configs<\/code> is that, in this, we create <strong>separate JSON or YAML files<\/strong> and keep our target information in them.  Prometheus will read the files to identify the targets.<\/p>\n<p>Not only these two, but various service discovery methods are available such as consul_sd_configs (where prometheus get target details from <a href=\"https:\/\/devopscube.com\/service-discovery-example\/\">consul<\/a>), ec2_sd_configs, etc.<\/p>\n<p>To know more about the configuration details, please visit the <a href=\"https:\/\/prometheus.io\/docs\/prometheus\/1.8\/configuration\/configuration\/?ref=devopscube.com\" rel=\"noreferrer noopener\">official documentation<\/a>.<\/p>\n<h2 id=\"prometheus-pushgateway\">Prometheus Pushgateway<\/h2>\n<p>Prometheus by default uses pull mechanism to scrap the metrics.<\/p>\n<p>However, there are <strong>scenarios where metrics need to be pushed<\/strong> to prometheus.<\/p>\n<p>Lets take an example of a <strong>batch job<\/strong> running on a <a href=\"https:\/\/devopscube.com\/create-kubernetes-jobs-cron-jobs\/\">Kubernetes cronjob<\/a> that runs daily for 5 mins based on certain events. In this scenario, Prometheus will not be able to scrape the <strong>service level metrics<\/strong> properly using pull mechanism.<\/p>\n<p>So instead for waiting for prometheus to pull the metrics, we need to <strong>push the metrics<\/strong> to prometheus. To push metrics, prometheus offers a solution called <strong>Pushgateway. <\/strong>It is kind of a intermediate gateway.<\/p>\n<p><strong>Pushgateway<\/strong> needs to be run as a standalone component. The batch jobs can push the metrics to the pushgateway using HTTP API. Then <strong>Pushgateway<\/strong> exposes those metrics on <strong><code>\/metrics<\/code><\/strong> endpoint. Then prometheus scrapes those metrics from the Pushgateway.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-119-11.png\" class=\"kg-image\" alt=\"Prometheus push gateway\" loading=\"lazy\" width=\"781\" height=\"682\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-119-11.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-119-11.png 781w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Pushgateway stores the metrics data temporarily in <strong>in-memory storage<\/strong>. It&#8217;s more of a temporary cache.<\/p>\n<p><strong>Pushgateway <\/strong>configuration also will be configured under the <code>scrape_configs<\/code> section in the <code>Prometheus<\/code> configuration.<\/p>\n<pre><code>scrape_configs:\n  - job_name: \"pushgateway\"\n        honor_labels: true\n        static_configs:\n        - targets: [pushgateway.monitoring.svc:9091]<\/code><\/pre>\n<p>To send metrics to the Pushgateways, you need to use the prometheus <strong>Client Libraries<\/strong> and <strong>instrument the application<\/strong> or script to expose the required metrics.<\/p>\n<h2 id=\"prometheus-client-libraries\"><strong>Prometheus Client Libraries<\/strong><\/h2>\n<p>Prometheus <strong>Client Libraries<\/strong> are software libraries that can be used to instrument application code to expose metrics in the way Prometheus understands.<\/p>\n<p>In cases where you need <strong>custom instrumentation<\/strong> or you want to create your own exporters, you can use the client libraries.<\/p>\n<p>A very good use case is batch jobs that need to push metrics to the Pushgateway. The batch job needs to be instrumented with client libraries to expose requirement metrics in prometheus format.<\/p>\n<p>Here is an example <code>Python Client Library<\/code> that exposes custom metrics named <strong><code>batch_job_records_processed_total<\/code><\/strong>.<\/p>\n<pre><code>from prometheus_client import start_http_server, Counter\nimport time\nimport random\n\nRECORDS_PROCESSED = Counter('batch_job_records_processed_total', 'Total number of records processed by the batch job')\n\ndef process_record():\n    time.sleep(random.uniform(0.01, 0.1))\n    RECORDS_PROCESSED.inc()\n\ndef batch_job():\n   \n    for _ in range(100):\n        process_record()\n\nif __name__ == '__main__':\n \n    start_http_server(8000)\n    print(\"Metrics server started on port 8000\")\n\n    batch_job()\n    print(\"Batch job completed\")\n\n    while True:\n        time.sleep(1)<\/code><\/pre>\n<p>Also when using client libraries, <code><strong>prometheus_client<\/strong><\/code> HTTP server exposes the metrics in <code>\/metrics <\/code>endpoint.<\/p>\n<p>Prometheus has <strong>Client Libraries<\/strong> for almost every programming language, and also if you want to create a Client Library, you can do it.<\/p>\n<p>To learn more about the guidelines of the creation and view the list of Client Libraries, you can refer to the <a href=\"https:\/\/prometheus.io\/docs\/instrumenting\/clientlibs\/?ref=devopscube.com#client-libraries\" rel=\"noreferrer noopener\">official documentation.<\/a><\/p>\n<h2 id=\"prometheus-alert-manager\">Prometheus Alert Manager<\/h2>\n<p><a href=\"https:\/\/devopscube.com\/prometheus-alert-manager\/\">Alertmanager<\/a> is the key part of  Prometheus monitoring system. Its primary job is to send alerts based on metric thresholds set in the <strong>Prometheus alert configuration<\/strong>.<\/p>\n<p>The alert get <strong>triggered by Prometheus<\/strong> and sent to Alertmanager. It in turn sends the alerts to the respective notification <strong>systems\/receivers<\/strong> (email, slack etc) configured in the alert manager configurations.<\/p>\n<p>Also, alert manager takes care of the following.<\/p>\n<ol>\n<li><strong>Alert<\/strong> <strong>Deduplicating<\/strong>: Process of silencing duplicated alerts.<\/li>\n<li><strong>Grouping<\/strong>: Process of grouping related alerts togther.<\/li>\n<li><strong>Silencing<\/strong>: Silence alerts for maintenance or false positives.<\/li>\n<li><strong>Routing<\/strong>: Routing alerts to appropriate receivers based on severities.<\/li>\n<li><strong>Inhibition<\/strong>: Process of stopping low severity alert when there is a medium of high severity alert.<\/li>\n<\/ol>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-120-10.png\" class=\"kg-image\" alt=\"Prometheus Alert Manager\" loading=\"lazy\" width=\"972\" height=\"563\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-120-10.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-120-10.png 972w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p>Here is an example configuration of an alert rule.<\/p>\n<pre><code>groups:\n- name: microservices_alerts\n  rules:\n  - record: http_latency:average_latency_seconds\n    expr: sum(http_request_duration_seconds_sum) \/ sum(http_request_duration_seconds_count)\n  - alert: HighLatencyAlert\n    expr: http_latency:average_latency_seconds &gt; 0.5\n    for: 5m\n    labels:\n      severity: critical\n    annotations:\n      summary: \"High latency detected in microservices\"\n      description: \"The average HTTP latency is high ({{ $value }} seconds) in the microservices cluster.\"\n\n<\/code><\/pre>\n<p>This is an example of the <strong>routing configuration<\/strong> of the Alertmanager configuration file<\/p>\n<pre><code>routes:\n- match:\n    severity: 'critical'\n  receiver: 'pagerduty-notifications'\n\n- match:\n    severity: 'warning'\n  receiver: 'slack-notifications'<\/code><\/pre>\n<p>Alert managers supports most of the message and notification systems such as Discord, Email, Slack, etc to reach the alert as a notification to the receiver.<\/p>\n<h2 id=\"promql\">PromQL<\/h2>\n<p>PromQL is a flexible <strong>query language<\/strong> that can be used to query time series metrics from the prometheus.<\/p>\n<p>We can directly  used the queries from the <code>Prometheus<\/code> <strong>user interface<\/strong> or we can use <code>curl<\/code> command to make a query over the command line interface.<\/p>\n<p><strong>Prometheus UI<\/strong><\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-109-5.png\" class=\"kg-image\" alt=\"PromQL on Prometheus UI\" loading=\"lazy\" width=\"794\" height=\"298\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-109-5.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-109-5.png 794w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<p><strong>Query over the CLI<\/strong><\/p>\n<pre><code>curl \"http:\/\/54.186.154.78:30000\/api\/v1\/query?query=$(echo 'up' | jq -s -R -r @uri)\" | jq .<\/code><\/pre>\n<p>Also, when you add prometheus as a data source to Grafana, you can use PromQL to query and create Grafana dashboards as shown below.<\/p>\n<figure class=\"kg-card kg-image-card\"><img decoding=\"async\" src=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-110-11.png\" class=\"kg-image\" alt=\"Grafana Dashboard with promQL\" loading=\"lazy\" width=\"1053\" height=\"593\" srcset=\"https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w600\/2025\/03\/image-110-11.png 600w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/size\/w1000\/2025\/03\/image-110-11.png 1000w, https:\/\/storage.ghost.io\/c\/5f\/2f\/5f2f4d20-2abf-4534-8d40-7aa233aedd43\/content\/images\/2025\/03\/image-110-11.png 1053w\" sizes=\"auto, (min-width: 720px) 720px\"><\/figure>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>This explains the major components of the Prometheus architecture and will give the basic overview of the Prometheus configuration, there are a lot more things you can do with the configuration.<\/p>\n<p>Each organization&#8217;s requirements would be different and the implementation of Prometheus in different environments also vary such as VMs and Kubernetes. If you understand the fundamentals and the key configurations, you can easily implement it in any platform.<\/p>\n<p>Also, it will help you prepare for the <a href=\"https:\/\/devopscube.com\/prometheus-certified-associate\/\">Prometheus certification<\/a> as well<\/p>\n<p>As a next step, you can try setting up <a href=\"https:\/\/devopscube.com\/setup-prometheus-monitoring-on-kubernetes\/\">prometheus on Kubernetes<\/a>.<\/p>\n<hr>\n<p><strong>Ngu\u1ed3n:<\/strong> <a href=\"https:\/\/devopscube.com\/prometheus-architecture\/\" target=\"_blank\" rel=\"noopener noreferrer\">Learn Prometheus Architecture: A Complete Guide \u2014 DevOpsCube<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source: https:\/\/devopscube.com\/prometheus-architecture\/<\/p>\n","protected":false},"author":1,"featured_media":752,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-751","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops"],"_links":{"self":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/751","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=751"}],"version-history":[{"count":0,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/posts\/751\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=\/wp\/v2\/media\/752"}],"wp:attachment":[{"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=751"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=751"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ngocha.biz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=751"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}