{"id":26583,"date":"2023-07-07T13:00:00","date_gmt":"2023-07-07T11:00:00","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/?p=26583"},"modified":"2023-07-10T11:38:20","modified_gmt":"2023-07-10T09:38:20","slug":"instrument-your-application-with-prometheus_part1","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/","title":{"rendered":"Instrument your python application with Prometheus (Part1)"},"content":{"rendered":"\n<p>We continue our blog series about Prometheus, today addressing a particularly interesting but often overlooked topic: <mark class=\"has-inline-color has-luminous-vivid-orange-color\">Prometheus Instrumentation<\/mark>. <\/p>\n\n\n\n<p>What does that mean? I&#8217;m not telling you anything new when I say that Prometheus allows you to collect tons of metrics, assess the health of your systems, and keep an eye on everything that&#8217;s happening, thanks to a wide range of official and unofficial exporters available to you.<\/p>\n\n\n\n<p>However, for some reason, the available exporters may not provide you with the specific metrics you need for your application. This is where Prometheus libraries come into play.<\/p>\n\n\n\n<p>A Prometheus library provides you with a straightforward way to add instruments to your application code to track and expose metrics in Prometheus. These libraries allow you to track and expose metrics in the expected Prometheus format, similar to an exporter.<\/p>\n\n\n\n<p>Prometheus has several official client libraries written in Go, Java, Python, Ruby, and Rust. Additionally, there are unofficial third-party client libraries available for other languages. Moreover, if desired, you can even write your own client library for any unsupported language.<\/p>\n\n\n\n<p>Throughout this blog, I will explain how to instrument a Python application and collect metrics from an API.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installation-and-starting-of-our-application\">Installation and starting of our application<\/h2>\n\n\n\n<p>For the purpose of this blog, I will create an API using a web framework called Flask, which is a popular web framework in Python that allows for relatively easy API development. I will need to have Python and Flask installed on my system.<\/p>\n\n\n\n<p>I have written a small media management script that allows me to list, modify, add, and delete content.<\/p>\n\n\n\n<p>My application consists of two files: my Python script called app.py and an index.html file that serves as an HTML render to make our demonstrations more intuitive.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u251c\u2500\u2500 app.py\n\u2514\u2500\u2500 templates\n    \u2514\u2500\u2500 index.html\n\n2 directories, 2 files<\/code><\/pre>\n\n\n\n<p>The app.py script is a basic Flask application that provides a RESTful API for managing a collection of books.<br>I&#8217;ve set up the basic routes and functions for managing books through HTTP requests, allowing users to get all books, create a new book, update an existing book, and delete a book.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom flask import Flask, jsonify, request, render_template, redirect, url_for\n\napp = Flask(__name__)\n\n# Sample initial book data\nbooks = &#x5B;\n    {&quot;id&quot;: 1, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Leviathan Wakes&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 2, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Caliban&#039;s War&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 3, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Abaddon&#039;s Gate&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 4, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Cibola Burn&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 5, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Nemesis Games&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 6, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Babylon&#039;s Ashes&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n]\n\n# Welcome route for the root URL (&quot;\/&quot;)\n@app.route(&#039;\/&#039;)\ndef home():\n    return render_template(&#039;index.html&#039;)\n\n# Get all books\n@app.route(&#039;\/books&#039;, methods=&#x5B;&#039;GET&#039;])\ndef get_books():\n    return jsonify(books)\n\n# Create a new book\n@app.route(&#039;\/books&#039;, methods=&#x5B;&#039;POST&#039;])\ndef create_book():\n    new_book = {\n        &#039;id&#039;: len(books) + 1,\n        &#039;title&#039;: request.form&#x5B;&#039;title&#039;],\n        &#039;author&#039;: request.form&#x5B;&#039;author&#039;],\n        &#039;publisher&#039;: request.form&#x5B;&#039;publisher&#039;],\n        &#039;novel_title&#039;: request.form&#x5B;&#039;novel_title&#039;]\n    }\n    books.append(new_book)\n    return redirect(url_for(&#039;home&#039;))\n\n# Update a book\n@app.route(&#039;\/books\/&lt;int:book_id&gt;&#039;, methods=&#x5B;&#039;PUT&#039;])\ndef update_book(book_id):\n    book = next((book for book in books if book&#x5B;&#039;id&#039;] == book_id), None)\n    if book:\n        book&#x5B;&#039;title&#039;] = request.form.get(&#039;title&#039;, book&#x5B;&#039;title&#039;])\n        book&#x5B;&#039;novel_title&#039;] = request.form.get(&#039;novel_title&#039;, book&#x5B;&#039;novel_title&#039;])\n        book&#x5B;&#039;author&#039;] = request.form.get(&#039;author&#039;, book&#x5B;&#039;author&#039;])\n        book&#x5B;&#039;publisher&#039;] = request.form.get(&#039;publisher&#039;, book&#x5B;&#039;publisher&#039;])\n        return jsonify(book)\n    return jsonify({&quot;message&quot;: &quot;Book not found&quot;}), 404\n\n# Delete a book\n@app.route(&#039;\/books\/&lt;int:book_id&gt;&#039;, methods=&#x5B;&#039;DELETE&#039;])\ndef delete_book(book_id):\n    book = next((book for book in books if book&#x5B;&#039;id&#039;] == book_id), None)\n    if book:\n        books.remove(book)\n        return jsonify({&quot;message&quot;: &quot;Book deleted&quot;})\n    return jsonify({&quot;message&quot;: &quot;Book not found&quot;}), 404\n\nif __name__ == &#039;__main__&#039;:\n    app.run(host=&#039;0.0.0.0&#039;, port=8080)\n<\/pre><\/div>\n\n\n<p>The index.html file will be used to create a user interface for managing books.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: xml; title: ; notranslate\" title=\"\">\n&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Book Management System&lt;\/title&gt;\n    &lt;style&gt;\n        .button-container {\n            display: flex;\n            gap: 10px;\n            margin-bottom: 10px;\n        }\n    &lt;\/style&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;Blog: Instrument your python application - Book Management System&lt;\/h1&gt;\n    &lt;form action=&quot;\/books&quot; method=&quot;POST&quot;&gt;\n        &lt;label for=&quot;title&quot;&gt;Title:&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; id=&quot;title&quot; name=&quot;title&quot;&gt;\n        &lt;label for=&quot;novel_title&quot;&gt;Novel Title:&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; id=&quot;novel_title&quot; name=&quot;novel_title&quot;&gt;\n        &lt;label for=&quot;author&quot;&gt;Author:&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; id=&quot;author&quot; name=&quot;author&quot;&gt;\n        &lt;label for=&quot;publisher&quot;&gt;Publisher:&lt;\/label&gt;\n        &lt;input type=&quot;text&quot; id=&quot;publisher&quot; name=&quot;publisher&quot;&gt;\n        &lt;button type=&quot;submit&quot;&gt;Add Book&lt;\/button&gt;\n    &lt;\/form&gt;\n    &lt;br&gt;\n    &lt;div class=&quot;button-container&quot;&gt;\n        &lt;button onclick=&quot;listBooks()&quot;&gt;List Books&lt;\/button&gt;\n    &lt;\/div&gt;\n    &lt;div id=&quot;bookList&quot;&gt;&lt;\/div&gt;\n\n    &lt;script&gt;\n        function listBooks() {\n            fetch(&#039;\/books&#039;)\n                .then(response =&gt; response.json())\n                .then(data =&gt; {\n                    const bookList = document.getElementById(&#039;bookList&#039;);\n                    bookList.innerHTML = &#039;&#039;;\n\n                    data.forEach(book =&gt; {\n                        const bookInfo = document.createElement(&#039;p&#039;);\n                        bookInfo.textContent = `Book ID: ${book.id}, Title: ${book.title}, Novel Title: ${book.novel_title}, Author: ${book.author}, Publisher: ${book.publisher}`;\n\n                        const updateButton = document.createElement(&#039;button&#039;);\n                        updateButton.textContent = &#039;Update Book&#039;;\n                        updateButton.onclick = () =&gt; updateBook(book.id);\n\n                        const deleteButton = document.createElement(&#039;button&#039;);\n                        deleteButton.textContent = &#039;Delete Book&#039;;\n                        deleteButton.onclick = () =&gt; deleteBook(book.id);\n\n                        bookInfo.appendChild(updateButton);\n                        bookInfo.appendChild(deleteButton);\n                        bookList.appendChild(bookInfo);\n                    });\n                });\n        }\n\n        function updateBook(bookId) {\n            const title = prompt(&#039;Enter the new title:&#039;);\n            const author = prompt(&#039;Enter the new author:&#039;);\n            const publisher = prompt(&#039;Enter the new publisher:&#039;);\n            const novelTitle = prompt(&#039;Enter the new novel title:&#039;);\n\n            fetch(`\/books\/${bookId}`, {\n                method: &#039;PUT&#039;,\n                headers: {\n                    &#039;Content-Type&#039;: &#039;application\/x-www-form-urlencoded&#039;\n                },\n                body: `title=${encodeURIComponent(title)}&amp;author=${encodeURIComponent(author)}&amp;publisher=${encodeURIComponent(publisher)}&amp;novel_title=${encodeURIComponent(novelTitle)}`\n            })\n            .then(response =&gt; {\n                if (response.ok) {\n                    alert(&#039;Book updated successfully&#039;);\n                    listBooks();\n                } else {\n                    alert(&#039;Failed to update book&#039;);\n                }\n            });\n        }\n\n        function deleteBook(bookId) {\n            fetch(`\/books\/${bookId}`, {\n                method: &#039;DELETE&#039;\n            })\n            .then(response =&gt; {\n                if (response.ok) {\n                    alert(&#039;Book deleted successfully&#039;);\n                    listBooks();\n                } else {\n                    alert(&#039;Failed to delete book&#039;);\n                }\n            });\n        }\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre><\/div>\n\n\n<p>First, we will start the application, which can be done by executing the Python script as below:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\npython3 app.py\n<\/pre><\/div>\n\n\n<pre class=\"wp-block-code\"><code>\u279c python3 app.py\n\n * Serving Flask app 'app'\n * Debug mode: off\nWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.\n * Running on all addresses (0.0.0.0)\n * Running on http:\/\/127.0.0.1:8080\n * Running on http:\/\/10.*.*.*:8080\nPress CTRL+C to quit\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-does-it-work\">How does it work?<\/h2>\n\n\n\n<p>Once the application is started, you simply need to open a web page and enter the URL of your application, in our case it will be a local URL like <a href=\"http:\/\/127.0.0.1:8080\/\">http:\/\/127.0.0.1:8080<\/a>, the application should present itself as shown in the following picture:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1021\" height=\"240\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png\" alt=\"\" class=\"wp-image-26594\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png 1021w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1-300x71.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1-768x181.png 768w\" sizes=\"auto, (max-width: 1021px) 100vw, 1021px\" \/><figcaption class=\"wp-element-caption\"><em>This application will allow us to generate HTTP traffic using different types of request methods, simply by utilizing the application&#8217;s features.<\/em><\/figcaption><\/figure>\n\n\n\n<p><br>To start, click on the &#8220;List Books&#8221; button, which corresponds to the &#8220;GET&#8221; request for the &#8220;\/book&#8221; route and will return a list of books from &#8220;The Expanse.&#8221;<\/p>\n\n\n\n<p>As a side note, &#8220;The Expanse&#8221; is a series of science fiction novels set in a future where humanity explores and colonizes the solar system, following a group of characters involved in a conspiracy that jeopardizes the balance of power between planets and factions. I highly recommend it to science fiction enthusiasts.<\/p>\n\n\n\n<p>Now, let&#8217;s focus on our application. <br>Each button corresponds to a METHOD of request, this means that the:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>List Books corresponds to the GET request<\/li>\n\n\n\n<li>Add Book corresponds to the POST request<\/li>\n\n\n\n<li>Update Book corresponds to the PUT request<\/li>\n\n\n\n<li>Delete Book corresponds to the DELETE request<\/li>\n<\/ul>\n\n\n\n<p>If I translate this into an image, it would show the list of books when I click on &#8220;List Books&#8221; (GET method).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"389\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen2.png\" alt=\"\" class=\"wp-image-26597\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen2.png 1000w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen2-300x117.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen2-768x299.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.0.1 - - &#091;07\/Jul\/2023 11:38:24] \"GET \/books HTTP\/1.1\" 200 -<\/code><\/pre>\n\n\n\n<p>If I click on the &#8220;Delete Book&#8221; button for &#8220;Book ID: 6&#8221; (Babylon&#8217;s Ashes), the entry will be deleted (DELETE method).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"983\" height=\"339\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen3.png\" alt=\"\" class=\"wp-image-26598\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen3.png 983w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen3-300x103.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen3-768x265.png 768w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/figure>\n\n\n\n<p>If I fill in the empty fields to enter a new book, a new entry will be added (POST method).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"980\" height=\"108\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen4.png\" alt=\"\" class=\"wp-image-26599\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen4.png 980w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen4-300x33.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen4-768x85.png 768w\" sizes=\"auto, (max-width: 980px) 100vw, 980px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.0.1 - - &#091;07\/Jul\/2023 11:50:14] \"POST \/books HTTP\/1.1\" 302 -\n127.0.0.1 - - &#091;07\/Jul\/2023 11:50:14] \"GET \/ HTTP\/1.1\" 200 -<\/code><\/pre>\n\n\n\n<p><br>Please note that I intentionally introduce a mistake by switching the Author and Publisher fields.<br>To correct this error, all we need to do is edit the incorrect entry by clicking on the update button and re-enter the information in the appropriate corresponding fields (PUT Method).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"934\" height=\"70\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen5.png\" alt=\"\" class=\"wp-image-26600\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen5.png 934w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen5-300x22.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen5-768x58.png 768w\" sizes=\"auto, (max-width: 934px) 100vw, 934px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.0.1 - - &#091;07\/Jul\/2023 11:58:35] \"PUT \/books\/6 HTTP\/1.1\" 200 -\n127.0.0.1 - - &#091;07\/Jul\/2023 11:58:37] \"GET \/books HTTP\/1.1\" 200 -\n\n<\/code><\/pre>\n\n\n\n<p>We have seen how our application works and how to initiate different HTTP requests. <br>Now, it&#8217;s time to focus on the part that interests us, the instrumentation of our application, as so far we haven&#8217;t implemented anything related to Prometheus.<br><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-installation-and-configuration-of-metrics\">Installation and configuration of metrics.<\/h2>\n\n\n\n<p><br>Let&#8217;s start by installing the Prometheus client. To do this, we will execute the command <code>pip install prometheus-client<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install prometheus_client<\/code><\/pre>\n\n\n\n<p>This command will allow us to install the library so that we can access it in our Python code.<\/p>\n\n\n\n<p>Next, we need to import classes from the Prometheus client library that we are interested in. <\/p>\n\n\n\n<p>There are several classes available from the Prometheus client library, such as Counter, Gauge, Histogram, etc. We will start by importing the Counter class from Prometheus with the intention of implementing a counter-type metric.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom prometheus_client import Counter\n<\/pre><\/div>\n\n\n<p>Then, in our code, we will define a variable called <strong>REQUESTS<\/strong> to initialize the Counter object by providing the metric name (http_request_total) and its description (Total number of requests).<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nREQUESTS = Counter(&#039;http_request_total&#039;,\n                   &#039;Total number of requests&#039;)\n<\/pre><\/div>\n\n\n<p>The script should look like:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom flask import Flask, jsonify, request, render_template, redirect, url_for\n\nfrom prometheus_client import Counter\n\nREQUESTS = Counter(&#039;http_request_total&#039;,\n                   &#039;Total number of requests&#039;)\n\napp = Flask(__name__)\n\n(...)\n<\/pre><\/div>\n\n\n<p>Now that we have this counter object, the question remains: When do we want to increment our counter?<\/p>\n\n\n\n<p>Since this counter represents the total number of requests, we need to increment it whenever we receive a request (<strong>GET<\/strong> \/ <strong>PUT<\/strong> \/ <strong>POST<\/strong> \/ <strong>DELETE<\/strong>).<\/p>\n\n\n\n<p>In our code, requests are made to the endpoint : <br><sup>@app.route(&#8216;\/books&#8217;, methods=[&#8216;GET&#8217;|&#8217;POST&#8217;|&#8217;PUT&#8217;|&#8217;DELETE&#8217;]<\/sup><br> so we will place our counter increment <code>REQUESTS.inc()<\/code> every time our &#8220;<em>\/books<\/em>&#8221; route is called.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\n# Get all books\n@app.route(&#039;\/books&#039;, methods=&#x5B;&#039;GET&#039;])\ndef get_books():\n    REQUESTS.inc()\n    return jsonify(books)\n\n# Create a new book\n@app.route(&#039;\/books&#039;, methods=&#x5B;&#039;POST&#039;])\ndef create_book():\n    REQUESTS.inc()\n\n# Update a book\n@app.route(&#039;\/books\/&lt;int:book_id&gt;&#039;, methods=&#x5B;&#039;PUT&#039;])\ndef update_book(book_id):\n    REQUESTS.inc()\n\n# Delete a book\n@app.route(&#039;\/books\/&lt;int:book_id&gt;&#039;, methods=&#x5B;&#039;DELETE&#039;])\ndef delete_book(book_id):\n    REQUESTS.inc()\n<\/pre><\/div>\n\n\n<p>The incrementation method &#8220;.inc()&#8221; will increase the counter by one unit, but keep in mind that the increment value is customizable, and you can define it within the parentheses if incrementing by one unit does not suit your needs. <br>Your code should look like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom flask import Flask, jsonify, request, render_template, redirect, url_for\n\nfrom prometheus_client import Counter\n\nREQUESTS = Counter(&#039;http_request_total&#039;,\n                   &#039;Total number of requests&#039;)\n\n\napp = Flask(__name__)\n\n# Sample initial book data\nbooks = &#x5B;\n    {&quot;id&quot;: 1, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Leviathan Wakes&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 2, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Caliban&#039;s War&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 3, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Abaddon&#039;s Gate&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 4, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Cibola Burn&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 5, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Nemesis Games&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n    {&quot;id&quot;: 6, &quot;title&quot;: &quot;The Expanse&quot;, &quot;novel_title&quot;: &quot;Babylon&#039;s Ashes&quot;, &quot;author&quot;: &quot;James S. A. Corey&quot;, &quot;publisher&quot;: &quot;Orbit Book&quot;},\n]\n\n# Welcome route for the root URL (&quot;\/&quot;)\n@app.route(&#039;\/&#039;)\ndef home():\n    return render_template(&#039;index.html&#039;)\n\n# Get all books\n@app.route(&#039;\/books&#039;, methods=&#x5B;&#039;GET&#039;])\ndef get_books():\n    REQUESTS.inc()\n    return jsonify(books)\n\n# Create a new book\n@app.route(&#039;\/books&#039;, methods=&#x5B;&#039;POST&#039;])\ndef create_book():\n    REQUESTS.inc()\n    new_book = {\n        &#039;id&#039;: len(books) + 1,\n        &#039;title&#039;: request.form&#x5B;&#039;title&#039;],\n        &#039;author&#039;: request.form&#x5B;&#039;author&#039;],\n        &#039;publisher&#039;: request.form&#x5B;&#039;publisher&#039;],\n        &#039;novel_title&#039;: request.form&#x5B;&#039;novel_title&#039;]\n    }\n    books.append(new_book)\n    return redirect(url_for(&#039;home&#039;))\n\n# Update a book\n@app.route(&#039;\/books\/&lt;int:book_id&gt;&#039;, methods=&#x5B;&#039;PUT&#039;])\ndef update_book(book_id):\n    REQUESTS.inc()\n    book = next((book for book in books if book&#x5B;&#039;id&#039;] == book_id), None)\n    if book:\n        book&#x5B;&#039;title&#039;] = request.form.get(&#039;title&#039;, book&#x5B;&#039;title&#039;])\n        book&#x5B;&#039;novel_title&#039;] = request.form.get(&#039;novel_title&#039;, book&#x5B;&#039;novel_title&#039;])\n        book&#x5B;&#039;author&#039;] = request.form.get(&#039;author&#039;, book&#x5B;&#039;author&#039;])\n        book&#x5B;&#039;publisher&#039;] = request.form.get(&#039;publisher&#039;, book&#x5B;&#039;publisher&#039;])\n        return jsonify(book)\n    return jsonify({&quot;message&quot;: &quot;Book not found&quot;}), 404\n\n# Delete a book\n@app.route(&#039;\/books\/&lt;int:book_id&gt;&#039;, methods=&#x5B;&#039;DELETE&#039;])\ndef delete_book(book_id):\n    REQUESTS.inc()\n    book = next((book for book in books if book&#x5B;&#039;id&#039;] == book_id), None)\n    if book:\n        books.remove(book)\n        return jsonify({&quot;message&quot;: &quot;Book deleted&quot;})\n    return jsonify({&quot;message&quot;: &quot;Book not found&quot;}), 404\n\nif __name__ == &#039;__main__&#039;:\n    app.run(host=&#039;0.0.0.0&#039;, port=8080)\n<\/pre><\/div>\n\n\n<p>The configuration of our metric is in place, now we need to make sure it is accessible.<\/p>\n\n\n\n<p>So, how do we proceed? We simply call an HTTP service that will start a web server and expose all our metrics. To do this, we first need to import the <code>start_http_server<\/code> class from your Prometheus-Client library, and then start this server on an unused port of our choice.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nfrom flask import Flask, jsonify, request, render_template, redirect, url_for\n\nfrom prometheus_client import Counter, start_http_server\n\nREQUESTS = Counter(&#039;http_request_total&#039;,\n                   &#039;Total number of requests&#039;)\n\n(...)\n\nif __name__ == &#039;__main__&#039;:\n    start_http_server(9090)\n    app.run(host=&#039;0.0.0.0&#039;, port=8080)\n<\/pre><\/div>\n\n\n<p><br>In our example, the metrics will be exposed on port 9090. Once you have updated your script and restarted your application, you can curl &#8220;<code>curl http:\/\/127.0.0.1:9090<\/code>&#8221; your endpoint or simply access to the endpoint through a webrowser as below<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"483\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen6.png\" alt=\"\" class=\"wp-image-26602\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen6.png 884w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen6-300x164.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen6-768x420.png 768w\" sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><\/figure>\n\n\n\n<p>et&#8217;s test our counter, but before that, please note the value of our counter <code>http_request_total<\/code> in the previous screenshot, which is currently zero. Let&#8217;s proceed with a GET request to the API by clicking on the &#8220;List books&#8221; button.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"987\" height=\"379\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen7.png\" alt=\"\" class=\"wp-image-26603\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen7.png 987w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen7-300x115.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen7-768x295.png 768w\" sizes=\"auto, (max-width: 987px) 100vw, 987px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s check the value of our counter and we can see that it has been incremented by 1.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"486\" height=\"35\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen8.png\" alt=\"\" class=\"wp-image-26604\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen8.png 486w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen8-300x22.png 300w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/figure>\n\n\n\n<p><br>Now, if I delete the last 3 books (&#8220;Book ID: 4 | 5 | 6&#8221;), it corresponds to 3 DELETE requests and 3 GET requests to update the display after each deletion.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"996\" height=\"327\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen9-1.png\" alt=\"\" class=\"wp-image-26606\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen9-1.png 996w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen9-1-300x98.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen9-1-768x252.png 768w\" sizes=\"auto, (max-width: 996px) 100vw, 996px\" \/><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>127.0.0.1 - - &#091;07\/Jul\/2023 14:22:44] \"DELETE \/books\/6 HTTP\/1.1\" 200 -\n127.0.0.1 - - &#091;07\/Jul\/2023 14:22:46] \"GET \/books HTTP\/1.1\" 200 -\n127.0.0.1 - - &#091;07\/Jul\/2023 14:22:47] \"DELETE \/books\/5 HTTP\/1.1\" 200 -\n127.0.0.1 - - &#091;07\/Jul\/2023 14:22:48] \"GET \/books HTTP\/1.1\" 200 -\n127.0.0.1 - - &#091;07\/Jul\/2023 14:22:49] \"DELETE \/books\/4 HTTP\/1.1\" 200 -\n127.0.0.1 - - &#091;07\/Jul\/2023 14:22:50] \"GET \/books HTTP\/1.1\" 200 -<\/code><\/pre>\n\n\n\n<p>If I check my counter from my endpoint, I can see that my counter<code> http_request_total <\/code>shows &#8220;7&#8221; total requests, which corresponds to the initial 1 request from the first test, plus the 6 requests we just performed.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"821\" height=\"483\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen10.png\" alt=\"\" class=\"wp-image-26607\" srcset=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen10.png 821w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen10-300x176.png 300w, https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/Screen10-768x452.png 768w\" sizes=\"auto, (max-width: 821px) 100vw, 821px\" \/><\/figure>\n\n\n\n<p>Congratulations, you have just implemented your first metric in your application! I invite you to join me in part 2 of this blog, where I will show you how to use labels in your metrics. We will also take the opportunity to implement gauge and histogram-type metrics. <\/p>\n\n\n\n<p>See you soon!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We continue our blog series about Prometheus, today addressing a particularly interesting but often overlooked topic: Prometheus Instrumentation. What does that mean? I&#8217;m not telling you anything new when I say that Prometheus allows you to collect tons of metrics, assess the health of your systems, and keep an eye on everything that&#8217;s happening, thanks [&hellip;]<\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229,1320],"tags":[],"type_dbi":[],"class_list":["post-26583","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","category-devops"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Instrument your python application with Prometheus (Part1) - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Instrument your python application with Prometheus (Part1)\" \/>\n<meta property=\"og:description\" content=\"We continue our blog series about Prometheus, today addressing a particularly interesting but often overlooked topic: Prometheus Instrumentation. What does that mean? I&#8217;m not telling you anything new when I say that Prometheus allows you to collect tons of metrics, assess the health of your systems, and keep an eye on everything that&#8217;s happening, thanks [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-07T11:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-10T09:38:20+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png\" \/>\n<meta name=\"author\" content=\"Middleware Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Middleware Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\"},\"author\":{\"name\":\"Middleware Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\"},\"headline\":\"Instrument your python application with Prometheus (Part1)\",\"datePublished\":\"2023-07-07T11:00:00+00:00\",\"dateModified\":\"2023-07-10T09:38:20+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\"},\"wordCount\":1238,\"commentCount\":0,\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png\",\"articleSection\":[\"Database Administration &amp; Monitoring\",\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\",\"name\":\"Instrument your python application with Prometheus (Part1) - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png\",\"datePublished\":\"2023-07-07T11:00:00+00:00\",\"dateModified\":\"2023-07-10T09:38:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png\",\"contentUrl\":\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Instrument your python application with Prometheus (Part1)\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1\",\"name\":\"Middleware Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g\",\"caption\":\"Middleware Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Instrument your python application with Prometheus (Part1) - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/","og_locale":"en_US","og_type":"article","og_title":"Instrument your python application with Prometheus (Part1)","og_description":"We continue our blog series about Prometheus, today addressing a particularly interesting but often overlooked topic: Prometheus Instrumentation. What does that mean? I&#8217;m not telling you anything new when I say that Prometheus allows you to collect tons of metrics, assess the health of your systems, and keep an eye on everything that&#8217;s happening, thanks [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/","og_site_name":"dbi Blog","article_published_time":"2023-07-07T11:00:00+00:00","article_modified_time":"2023-07-10T09:38:20+00:00","og_image":[{"url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png","type":"","width":"","height":""}],"author":"Middleware Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Middleware Team","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/"},"author":{"name":"Middleware Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"headline":"Instrument your python application with Prometheus (Part1)","datePublished":"2023-07-07T11:00:00+00:00","dateModified":"2023-07-10T09:38:20+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/"},"wordCount":1238,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png","articleSection":["Database Administration &amp; Monitoring","DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/","url":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/","name":"Instrument your python application with Prometheus (Part1) - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png","datePublished":"2023-07-07T11:00:00+00:00","dateModified":"2023-07-10T09:38:20+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2023\/07\/screen1.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/instrument-your-application-with-prometheus_part1\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Instrument your python application with Prometheus (Part1)"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/8d8563acfc6e604cce6507f45bac0ea1","name":"Middleware Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ddcae7ba0f9d1a0e7ae707f0e689e4a9c95bb48ec49c8e6d9cc86d43f4121cb6?s=96&d=mm&r=g","caption":"Middleware Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/middleware-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/26583","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=26583"}],"version-history":[{"count":21,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/26583\/revisions"}],"predecessor-version":[{"id":26625,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/26583\/revisions\/26625"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=26583"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=26583"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=26583"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=26583"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}