<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Sagiv Zafrani on Medium]]></title>
        <description><![CDATA[Stories by Sagiv Zafrani on Medium]]></description>
        <link>https://medium.com/@sagivsza?source=rss-1ca4e54c4e93------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*retb0zPcoeN_FizA</url>
            <title>Stories by Sagiv Zafrani on Medium</title>
            <link>https://medium.com/@sagivsza?source=rss-1ca4e54c4e93------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:53:58 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sagivsza/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Prometheus and Thanos: An Ultimate Alliance for Scalable Metrics]]></title>
            <link>https://medium.com/@sagivsza/prometheus-and-thanos-an-ultimate-alliance-for-scalable-metrics-9a1cb911abf5?source=rss-1ca4e54c4e93------2</link>
            <guid isPermaLink="false">https://medium.com/p/9a1cb911abf5</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[observability]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[infrastructure]]></category>
            <dc:creator><![CDATA[Sagiv Zafrani]]></dc:creator>
            <pubDate>Mon, 10 Jul 2023 23:55:28 GMT</pubDate>
            <atom:updated>2023-07-16T17:35:35.723Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will walk you through a thrilling journey of Prometheus scaling issues and how Thanos can help scale Prometheus to infinity (and beyond!).</p><h3>Prometheus Introduction</h3><p>Prometheus collects and stores metrics as time-series data locally on disk, i.e. metrics information is stored with the timestamp at which it was recorded alongside optional key-value pairs which are called labels.</p><p>Following a demand for adding additional exporters, instrumenting metrics for additional services, and an ever-increasing number of targets needed to be scraped, the velocity of metrics being collected by Prometheus has increased rapidly.</p><p>We noticed that the Prometheus server consumes more memory over time (a direct correlation of higher time series data being ingested) and a higher disk utilization (more targets producing more metrics, more metrics meaning more data stored on a persistent disk).</p><p>Despite its strength and agility, it faltered when scaling horizontally became necessary. As the environments connecting to the centralized Prometheus server increased, it began to crack under pressure and we came to the conclusion that Prometheus will reach a certain limit, and that it’s not designed to be scaled horizontally, even dedicated nodes with higher memory and bigger disks will only get us so far, and once we will hit the limit of vertical scaling, that’s it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1020/1*f7oxyneFkoHvxYc65QQQ2Q.png" /><figcaption>Thanos and Prometheus</figcaption></figure><p><strong>Why Thanos?</strong></p><p>At Rapid, we used a Prometheus federation topology resembling a tree, with a high-level Prometheus server collecting aggregated time-series data from numerous subordinate servers. When the load became too much for Prometheus, Thanos stepped in, enabling the construction of high-availability metric systems with practically unlimited storage.</p><p><strong>What is Thanos?</strong></p><p>As an Incubating project under CNCF, Thanos lends Prometheus a hand, employing its 2.0 storage format to store historical metric data cost-effectively in any object storage, while keeping query latencies quick. With global query view, high availability, and data backup, Thanos swoops in, delivering easy deployment and maintenance. All it needs is a Prometheus v2.2.1+ installation and optional object storage.</p><h3><strong>Thanos Components: The Infinity Stones of Metrics</strong></h3><p>1. <strong>Thanos Sidecar</strong>: This component resides alongside Prometheus, becoming its closest ally. It has several key functions:</p><p>— It uploads TSDB blocks to an object store as they are created every two hours.</p><p>2. <strong>Thanos Store (Store Gateway):</strong> This component acts as a bridge between the long-term storage and the Thanos Query. Key attributes are:</p><p>— It implements the StoreAPI on top of historical data present in an object storage bucket.</p><p>— It keeps a small amount of information about all remote blocks on the local disk to keep in sync with the bucket.</p><p>3. <strong>Thanos Query:</strong> This component is like a translator and aggregator of data. Here’s what it does:</p><p>— It listens on HTTP and translates incoming queries to the gRPC format.</p><p>— It’s capable of deduplicating, merging, and downsampling data fetched from its stores.</p><p>— The Thanos Query component needs to know about all its stores (Sidecars, Rulers, Store Gateways, etc.), and it can discover them through service discovery.</p><p>— It acts as a proxy for queries over the gRPC StoreAPI, letting you access “local” data alongside historical data in object storage.</p><p>4. <strong>Thanos Query Frontend (optional):</strong> Just as Thanos used the Infinity Stones to alter reality, the Query Frontend enhances the way users interact with data.</p><p>— It can be placed in front of Thanos Query to improve the read path’s latency and throughput.</p><p>— This component is entirely optional and doesn’t store any data. Instead, it delegates work to Thanos Query and adjusts how the client (e.g., Grafana) schedules and retries failed requests.</p><h3><strong>Thanos Architecture: The Cosmos of Metrics</strong></h3><p>With the components defined, it’s time to assemble them in our architecture, just as Thanos assembled his Infinity Gauntlet.<br>- Deployment: Your Prometheus instance, along with Thanos Sidecar, is deployed on every Kubernetes cluster. The sidecar has two main jobs: to upload the Prometheus TSDB blocks to object storage for long-term storage and to serve as an access point for real-time data for the Thanos Query.<br> <br>- Communication: The Thanos Query gathers data from both the Thanos Store and the Thanos Sidecar. It uses the gRPC protocol to talk to the Thanos Store, pulling in historic metric data, and also communicates with the Thanos Sidecar to pull real-time data directly from the Prometheus instance.<br> <br>- Query Frontend: When deployed, it sits before the Thanos Query. The user (which can also set it as a data source within Grafana) communicates with the Query Frontend which, in turn, communicates with the Thanos Query to gather and return the requested data.<br> <br>- Data Flow: Real-time data flows from the Prometheus instance to the Thanos Sidecar and onto the Thanos Query. Historic data is saved from the Thanos Sidecar to the object storage, and from there, it can be pulled by the Thanos Store and queried by the Thanos Query.<br>This architecture forms a balanced universe of metrics, where Prometheus handles real-time data collection, and Thanos steps in to solve the long-term storage puzzle. Thanos ensures that all the valuable metrics are stored safely in the object storage (Infinity Gauntlet) and are also easily accessible for querying.<br>But enough with the anticipation. Let’s unveil the blueprint of this masterful structure. Allow me to present to you the architecture of our mighty Prometheus-Thanos alliance…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vj5TLoZwacGFYIIABIbiHA.png" /></figure><h3>And Remember These Golden Nuggets!</h3><ul><li><strong>Data Retention:</strong> Balance cost and time for metrics retention — it’s a matter of perfect balance, as all things should be!</li><li><strong>Prometheus Server Availability:</strong> Monitor the uptime of the Prometheus server. If your Prometheus server is down, it impacts the entire monitoring pipeline. Alerts should be configured to notify you immediately in case of server unavailability.</li><li><strong>Data Ingestion Rate:</strong> Keep track of the rate at which Prometheus is ingesting data. Any drastic changes in this rate could indicate an issue with your metric sources, or even an anomaly in your system that might require attention.</li><li><strong>Thanos Sidecar Reachability:</strong> Monitor the connection between Prometheus and the Thanos Sidecar. The Sidecar is vital for forwarding the data from Prometheus to your long-term storage, hence its availability is crucial.</li><li><strong>Thanos Store API Latency:</strong> Keep an eye on the latency of requests made to the Thanos Store API. Any increase in latency can lead to slower response times and affect the overall efficiency of your monitoring system.</li><li><strong>Query Execution Time:</strong> Monitor the execution time of Thanos Querier. An increase in query execution time might indicate an overload or performance issue that needs immediate attention.</li></ul><p>Remember, in this universe, balance isn’t a thing you hope for. It’s something you build, piece by piece, Infinity Stone by Infinity Stone.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9a1cb911abf5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>