{"id":7234,"date":"2020-10-09T10:32:58","date_gmt":"2020-10-09T10:32:58","guid":{"rendered":"https:\/\/blog.cloudthat.com\/?p=7234"},"modified":"2024-06-25T11:10:28","modified_gmt":"2024-06-25T11:10:28","slug":"everything-about-prometheus","status":"publish","type":"blog","link":"https:\/\/www.cloudthat.com\/resources\/blog\/everything-about-prometheus","title":{"rendered":"Everything about Prometheus"},"content":{"rendered":"<h2><strong>Understanding Prometheus<\/strong><\/h2>\n<p>Prometheus is an open-source tool for monitoring and alerting. It is a data model &amp; query language which can help the user to analyze the application and monitor the performance of the infrastructure. Over a decade, many companies and organizations have adopted Prometheus for its lightweight feature.<\/p>\n<p>It is used for recording numeric time series and for monitoring dynamic service-oriented architecture. It collects the data in the form of time series, which is built through a pull model.<\/p>\n<p>For starters, understanding Prometheus can be tricky. In this article, you will gather an overview about Prometheus, the architecture, the highlighted features, how to install it on ubuntu server and other references to get deeper knowledge on related topics.<\/p>\n<h2><strong>What does Prometheus do?<\/strong><\/h2>\n<p>Prometheus stores the metrics sent by multiple exporters into chunks of data and it stores for 90 days, which means the data older than 90 days is not available is Prometheus <em>(this limit can be changed).<\/em><\/p>\n<p>Every exporter has a set of queries that fetches information about a specific set of metrics, all the raw metrics fetched by the exporter, which can be used for alerting or visualization purposes.<\/p>\n<p>The data metrics are being collected by different types of exporters that have different use cases. The list of exporters currently in use are:<\/p>\n<ul>\n<li><strong>Node Exporter: <\/strong>Used to export OS and system-level metrics for the Linux server, which will allow us to measure various machine resources like memory, disk, CPU utilization, etc. By Specifying the targets of the node.<\/li>\n<li><strong>WMI Exporter: <\/strong>Used to export OS and system-level metrics window server, which is used to export the metrics such as CPU, Memory, and disk I\/O and also use to monitor the IIS site application and network interface.<\/li>\n<li><strong>Blackbox Exporter: <\/strong>It is a tool that is used to monitor HTTP, DNS, TCP endpoints such as its status code, success\/failure, etc.<\/li>\n<\/ul>\n<p>Prometheus does not support the intended dashboard to view the metrics. It is used only for fetching specific queries and data for the log. Therefore, the metrics collected from different types of the exporter are stored into Prometheus.<\/p>\n<h2><strong>Prometheus Architecture:<\/strong><\/h2>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Prometheus.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7240\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Prometheus.png\" alt=\"Everything about Prometheus\" width=\"700\" height=\"365\" \/><\/a><\/p>\n<h2><strong>Features Overview:<\/strong><\/h2>\n<ul>\n<li>Prometheus is a multi-dimensional data model with a time series by name and key\/value pair<\/li>\n<li>The Prometheus server scrapes and stores time-series data<\/li>\n<li>It supports multiple modes of graphs and dashboard which can be visualized with Grafana<\/li>\n<li>It supports alert manager to handle alerts and notify the team either with Slack, PagerDuty, etc.<\/li>\n<li>It uses service discovery to discovery targets<\/li>\n<\/ul>\n<p><strong>Installing Prometheus on ubuntu server:<\/strong><\/p>\n<ol>\n<li>Login into the AWS console, choose the ubuntu server 18.04 and launch the server with the basic configuration<\/li>\n<\/ol>\n<p><strong>Note:<\/strong> Open port 9090 in the security group along with SSH and HTTP port.<\/p>\n<ol start=\"2\">\n<li>Login into the server with sudo privilege and update the yum package\n<pre class=\"lang:default decode:true \">sudo yum update -y<\/pre>\n<\/li>\n<li>Create a Prometheus user, required directories, and make Prometheus user as the owner of those directories.\n<pre class=\"lang:default decode:true \">sudo useradd --no-create-home --shell \/bin\/false prometheus\r\nsudo mkdir \/etc\/prometheus\r\nsudo mkdir \/var\/lib\/prometheus\r\nsudo chown prometheus:prometheus \/etc\/prometheus\r\nsudo chown prometheus:prometheus \/var\/lib\/prometheus<\/pre>\n<\/li>\n<li>Download the source using curl, unzip the package, and rename the\u00a0extracted folder to prometheus-files.\n<pre class=\"lang:default decode:true \">curl -LO https:\/\/github.com\/prometheus\/prometheus\/releases\/download\/v2.17.1\/prometheus-2.17.1.linux-amd64.tar.gz\r\n\r\ntar -xvf prometheus-2.17.1.linux-amd64.tar.gz\r\nmv prometheus-2.17.1.linux-amd64 prometheus-files<\/pre>\n<\/li>\n<li>Copy\u00a0prometheus\u00a0and promtool\u00a0binary from\u00a0prometheus-files folder to\u00a0\/usr\/local\/bin and change the ownership to prometheus user.\n<pre class=\"lang:default decode:true \">sudo cp prometheus-files\/prometheus \/usr\/local\/bin\/\r\nsudo cp prometheus-files\/promtool \/usr\/local\/bin\/\r\nsudo chown prometheus:prometheus \/usr\/local\/bin\/prometheus\r\nsudo chown prometheus:prometheus \/usr\/local\/bin\/promtool<\/pre>\n<\/li>\n<li>Move the\u00a0consoles\u00a0and\u00a0console_libraries\u00a0directories from prometheus-files to\u00a0\/etc\/prometheus\u00a0folder and change the ownership to prometheus\u00a0user.\n<pre class=\"lang:default decode:true \">sudo cp -r prometheus-files\/consoles \/etc\/prometheus\r\nsudo cp -r prometheus-files\/console_libraries \/etc\/prometheus\r\nsudo chown -R prometheus:prometheus \/etc\/prometheus\/consoles\r\nsudo chown -R prometheus:prometheus \/etc\/prometheus\/console_libraries<\/pre>\n<\/li>\n<li>Create the prometheus.yml file.\n<pre class=\"lang:default decode:true \">sudo vi \/etc\/prometheus\/prometheus.yml<\/pre>\n<\/li>\n<li>Copy the following contents to the prometheus.yml file.\n<pre class=\"lang:default decode:true \">global:\r\n  scrape_interval: 10s\r\n\r\nscrape_configs:\r\n  - job_name: 'prometheus'\r\n    scrape_interval: 5s\r\n    static_configs:\r\n      - targets: ['localhost:9090']<\/pre>\n<\/li>\n<li>Change the ownership of the file to prometheus user.\n<pre class=\"lang:default decode:true \">sudo chown prometheus:prometheus \/etc\/prometheus\/prometheus.yml<\/pre>\n<\/li>\n<li>Create a prometheus\u00a0service file.\n<pre class=\"lang:default decode:true \">[Unit]\r\nDescription=Prometheus\r\nWants=network-online.target\r\nAfter=network-online.target\r\n\r\n [Service]\r\nUser=prometheus\r\nGroup=prometheus\r\nType=simple\r\nExecStart=\/usr\/local\/bin\/prometheus \\\r\n    --config.file \/etc\/prometheus\/prometheus.yml \\\r\n    --storage.tsdb.path \/var\/lib\/prometheus\/ \\\r\n    --web.console.templates=\/etc\/prometheus\/consoles \\\r\n    --web.console.libraries=\/etc\/prometheus\/console_libraries\r\n\r\n [Install]\r\nWantedBy=multi-user.target<\/pre>\n<\/li>\n<li>Reload the systemctl service to register the prometheus service and start the prometheus service.\n<pre class=\"lang:default decode:true \">sudo systemctl daemon-reload\r\nsudo systemctl start prometheus<\/pre>\n<\/li>\n<li>Check the prometheus service status using the following command.\n<pre class=\"lang:default decode:true \">sudo systemctl status prometheus<\/pre>\n<\/li>\n<li>Let us access Prometheus portal on the web browser\n<pre class=\"lang:default decode:true\">http:\/\/&lt;prometheus-ip&gt;:9090\/graph<\/pre>\n<\/li>\n<\/ol>\n<p><a href=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Prometheus_11.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-7241\" src=\"https:\/\/content.cloudthat.com\/resources\/wp-content\/uploads\/2022\/11\/Prometheus_11.png\" alt=\"Everything about Prometheus\" width=\"700\" height=\"280\" \/><\/a><\/p>\n<p>As always, if you have any more queries or feedback, feel free to drop a comment and we will get back to you right away.<\/p>\n<p>If you want to learn more about Prometheus go to our\u00a0<a href=\"https:\/\/cloudthat.in\/?utm_source=blog-website&amp;utm-medium=text-link&amp;utm_campaign=training-website\" target=\"_blank\" rel=\"noopener\">website<\/a>\u00a0and check more courses on DevOps.<\/p>\n<p>We have just touched the tip of the iceberg and there is a lot more about Prometheus. Would you like to know more on Prometheus? Visit our blogsite<\/p>\n<p><a href=\"https:\/\/blog.cloudthat.com\/integration-and-visualization-of-prometheus-metrics-in-grafana\/\"><strong>https:\/\/blog.cloudthat.com\/integration-and-visualization-of-prometheus-metrics-in-grafana\/<\/strong><\/a><\/p>\n<p>That is all folks!<\/p>\n","protected":false},"author":224,"featured_media":7243,"parent":0,"comment_status":"open","ping_status":"open","template":"","blog_category":[3606,3608,3607],"user_email":"sindhum@cloudthat.com","published_by":"324","primary-authors":"","secondary-authors":"","acf":[],"_links":{"self":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/7234"}],"collection":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/types\/blog"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/users\/224"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/comments?post=7234"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/7234\/revisions"}],"predecessor-version":[{"id":42443,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog\/7234\/revisions\/42443"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/media?parent=7234"}],"wp:term":[{"taxonomy":"blog_category","embeddable":true,"href":"https:\/\/www.cloudthat.com\/resources\/wp-json\/wp\/v2\/blog_category?post=7234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}