<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Thanos on Giedrius Statkevičius</title><link>https://giedrius.blog/categories/thanos/</link><description>Recent content in Thanos on Giedrius Statkevičius</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Sun, 22 Jun 2025 10:56:40 +0000</lastBuildDate><atom:link href="https://giedrius.blog/categories/thanos/feed.xml" rel="self" type="application/rss+xml"/><item><title>OpenTelemetry-go makes it hard to migrate to exponential histograms</title><link>https://giedrius.blog/2025/06/22/opentelemetry-go-makes-it-hard-to-migrate-to-exponential-histograms/</link><pubDate>Sun, 22 Jun 2025 10:56:40 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1240</guid><description>&lt;p&gt;&lt;em&gt;github.com/prometheus/client_golang&lt;/em&gt; has a nice feature where a histogram can simultaneously be both an exponential (native) histogram and a classic (explicit bucket) one. Then, depending on what formats are accepted by the scraper, either both the native histogram version and the classical one are exposed, or just the classical one (text format). There has been an initiative to expose native histograms in text format, but it hasn&amp;rsquo;t yet solidified.&lt;/p&gt;
&lt;p&gt;Unfortunately, in the OpenTelemetry standards, a histogram at any point can only have either explicit buckets or exponential buckets. From &lt;a href="https://opentelemetry.io/docs/specs/otel/metrics/data-model/#model-details"&gt;https://opentelemetry.io/docs/specs/otel/metrics/data-model/#model-details&lt;/a&gt;:&lt;/p&gt;</description></item><item><title>My gRPC Annoyances</title><link>https://giedrius.blog/2024/06/07/my-grpc-annoyances/</link><pubDate>Fri, 07 Jun 2024 14:18:01 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1182</guid><description>&lt;p&gt;We have been using gRPC in &lt;a href="https://thanos.io"&gt;Thanos&lt;/a&gt; since Thanos inception - it has served us great and it has a ton of useful functionality, it solves a lot of problems, it is easy to use, and so on. However, I feel like some stuff is lacking, especially performance that will most likely never be fixed (or, I should say, changed). The framework just does not solve 100% of the things that the Thanos project needs right now. Let&amp;rsquo;s go through the list of my pet peeves.&lt;/p&gt;</description></item><item><title>Dynamic hashrings with WAL in Thanos are bad</title><link>https://giedrius.blog/2024/05/24/dynamic-hashrings-with-wal-in-thanos-are-bad/</link><pubDate>Fri, 24 May 2024 14:30:01 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1186</guid><description>&lt;p&gt;Hashrings are everywhere in distributed systems. Combined with a write-ahead log that uses an unbounded amount of RAM during WAL replay, they are a terrible idea. If there is a constant stream of metrics coming into Thanos, you want to push back on the producers of those metrics in case of one or a few node&amp;rsquo;s downtime. Having a dynamic hashring i.e. a hashring that immediately updates as soon as it notices that one node is down, prevents that. The same stream is now going to fewer nodes. And so on until, most likely, your whole stack collapses. In practice, this means that you should not remove a node from the hashring if it is unhealthy or unready.&lt;/p&gt;</description></item><item><title>Vertical compaction + hashmod foot gun in Thanos Compactor</title><link>https://giedrius.blog/2024/05/07/vertical-compaction-hashmod-foot-gun-in-thanos-compactor/</link><pubDate>Tue, 07 May 2024 14:54:21 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1173</guid><description>&lt;p&gt;I recently ran into this &amp;ldquo;fun&amp;rdquo; problem where the Compactor was stuck compacting the same blocks repeatedly. Only after lots of trial and error, I have found out that sharding using &lt;code&gt;hashmod&lt;/code&gt; on some labels that are also dedup labels in vertical compaction was the culprit. Vertical compaction is like horizontal compaction but vertical compaction compacts blocks that have overlaps in time. And also vertical compaction removes the specified replica labels. Apparently, Thanos Compactor depends on having a &amp;ldquo;global&amp;rdquo; view of all blocks to filter out blocks that had been compacted into higher compaction level blocks. The interesting part is this filter: &lt;a href="https://github.com/thanos-io/thanos/blob/f7ba14066fc35095e13ca3f675915c509310f476/cmd/thanos/compact.go#L235"&gt;https://github.com/thanos-io/thanos/blob/f7ba14066fc35095e13ca3f675915c509310f476/cmd/thanos/compact.go#L235&lt;/a&gt;. It filters out blocks that can be formed from two or more overlapping blocks that fully matches the source blocks of the older blocks. It uses data in the &lt;code&gt;meta.json&lt;/code&gt; file of each block to understand what are the sources of each block.&lt;/p&gt;</description></item><item><title>Starting up GitHub sponsors and some recent postings work</title><link>https://giedrius.blog/2024/02/22/starting-up-github-sponsors-and-some-recent-postings-work/</link><pubDate>Thu, 22 Feb 2024 19:04:51 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1160</guid><description>&lt;p&gt;Hello everyone! I am happy to announce that I&amp;rsquo;ve set up GitHub sponsors on my &lt;a href="https://github.com/GiedriusS"&gt;profile&lt;/a&gt;. If you want to support my blog or my work on Thanos/Prometheus, and you have some free money then now you have a way to throw some money at these projects. Let&amp;rsquo;s see if I will even get one sponsor. I was thinking that maybe I should work on some custom features that could be behind a paywall. Let&amp;rsquo;s see when I will have some time to work on them.&lt;/p&gt;</description></item><item><title>Cheat Sheet Of How To Get Accepted Into LFX</title><link>https://giedrius.blog/2023/06/15/cheat-sheet-of-how-to-get-accepted-into-lfx/</link><pubDate>Thu, 15 Jun 2023 20:05:20 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1120</guid><description>&lt;p&gt;Hello everyone! I&amp;rsquo;ve been a mentor in the LFX program for quite a few semesters and I have been participating in it since the complete beginning, when it was still called community bridge. I also participated in GSoC once as a mentor. Since I get questions about how to get accepted into LFX, I thought about writing an article about this topic. Please note that even if you will follow everything to the letter, you still might not get accepted. There is some luck involved but I believe that my suggestions greatly increase your chance of getting accepted as a mentee.&lt;/p&gt;</description></item><item><title>Why Thanos Receive Will Almost Always Be Faster Than Thanos Sidecar</title><link>https://giedrius.blog/2023/03/13/why-thanos-receive-will-almost-always-be-faster-than-thanos-sidecar/</link><pubDate>Mon, 13 Mar 2023 21:19:51 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=1094</guid><description>&lt;p&gt;Just a few late-night musings from today. The last paragraph might not be true as these are scattered thoughts. Maybe someone will get some worth from this post.&lt;/p&gt;
&lt;p&gt;There are two main ways of deploying Thanos - as a Sidecar to Prometheus where it &amp;ldquo;steals&amp;rdquo; its blocks and uploads them to remote object storage whilst at the same time proxying metrics requests to Prometheus itself and then there is Receive which accepts incoming metrics data over remote_write and stores it with a few bells and whistles.&lt;/p&gt;</description></item><item><title>Distributed Systems Magic: K-way Merge in Thanos</title><link>https://giedrius.blog/2022/09/08/distributed-systems-magic-k-way-merge-in-thanos/</link><pubDate>Thu, 08 Sep 2022 15:59:56 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=975</guid><description>&lt;p&gt;Oops, it has been such a long time since I wrote a post that I even accidentally forgot to renew my site! That&amp;rsquo;s bad. I definitely owe you a few new posts. Thus, here is another post in the distributed systems magic series.&lt;/p&gt;
&lt;p&gt;Recently I undertook the &lt;a href="https://github.com/thanos-io/thanos/pull/5296"&gt;task of improving the proxying logic in Thanos&lt;/a&gt;. If you are not familiar with it, the Query component of Thanos sends out requests via gRPC to leaf nodes to retrieve needed data when it gets some kind of PromQL query from users. This article will show you how it worked previously, how it works now, and the learnings from doing this.&lt;/p&gt;</description></item><item><title>Distributed Systems Magic: Groupcache in Thanos</title><link>https://giedrius.blog/2022/03/04/distributed-systems-magic-groupcache-in-thanos/</link><pubDate>Fri, 04 Mar 2022 10:19:50 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=953</guid><description>&lt;p&gt;This is a sequel to my previous blog post about trying to migrate to a newer version of protocol buffer API. In this blog post, I will tell you how we&amp;rsquo;ve managed to get &lt;a href="https://github.com/golang/groupcache"&gt;groupcache&lt;/a&gt; into Thanos during the previous LFX mentorship. The team consisted of &lt;a href="https://github.com/akanshat"&gt;Akansha Tiwari&lt;/a&gt;, &lt;a href="https://onprem.dev/"&gt;Prem Saraswat&lt;/a&gt;, and me. It would not have been possible to implement this without the whole team.&lt;/p&gt;
&lt;p&gt;In the beginning, let&amp;rsquo;s quickly go over what is groupcache and why it solves a few important problems in Thanos.&lt;/p&gt;</description></item><item><title>Things Learned From Trying to Migrate To Protobuf V2 API from gogoprotobuf (So Far)</title><link>https://giedrius.blog/2022/02/04/things-learned-from-trying-to-migrate-to-protobuf-v2-api-from-gogoprotobuf-so-far/</link><pubDate>Fri, 04 Feb 2022 16:03:25 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=928</guid><description>&lt;p&gt;During the most recent LFX mentorship program&amp;rsquo;s iteration, I had the honor to work on trying to migrate to &lt;a href="https://go.dev/blog/protobuf-apiv2"&gt;version 2 of the protobuf API&lt;/a&gt; from gogoprotobuf on the Thanos project with my one and only awesome mentee &lt;a href="https://twitter.com/im_rsawra"&gt;Rahul Sawra&lt;/a&gt; and another mentor Lucas Serven who is also a co-maintainer of &lt;a href="https://thanos.io"&gt;Thanos&lt;/a&gt;. I wanted to share my technical learnings from this project.&lt;/p&gt;
&lt;figure&gt;
&lt;img loading="lazy" src="https://giedrius.blog/wp-content/uploads/2022/02/image-1.png"/&gt;
&lt;/figure&gt;
&lt;p&gt;First of all, let&amp;rsquo;s quickly look at what protocol buffers are and what is the meaning of the different words in the jargon. Protocol buffers are a way of serializing data. It was &lt;a href="https://developers.google.com/protocol-buffers/"&gt;first made by Google&lt;/a&gt;. It is a quite popular library that is used by Thanos really everywhere. Thanos also uses &lt;a href="https://grpc.io/"&gt;gRPC&lt;/a&gt; to talk between different components. gRPC is a remote procedure call framework. With it, your (micro-)services can implement methods that could be called by others.&lt;/p&gt;</description></item><item><title>Custom Metric Retention Periods on Thanos</title><link>https://giedrius.blog/2021/12/07/custom-metric-retention-periods-on-thanos/</link><pubDate>Tue, 07 Dec 2021 20:38:21 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=882</guid><description>&lt;p&gt;Setting custom metric retention periods on Thanos is one of the longest feature requests that we have had: &lt;a href="https://github.com/thanos-io/thanos/issues/903"&gt;https://github.com/thanos-io/thanos/issues/903&lt;/a&gt;. It seems like there is still no solution in sight but actually, it is already possible to have custom metrics retention periods. It is quite a simple idea but could be hard to implement if you do not have comfortable deployment tooling in place. You can achieve custom retention periods for different metrics in the following way:&lt;/p&gt;</description></item><item><title>What Is The Optimal Split Interval For query-frontend?</title><link>https://giedrius.blog/2021/10/11/what-is-the-optimal-split-interval-for-query-frontend/</link><pubDate>Mon, 11 Oct 2021 15:03:56 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=868</guid><description>&lt;p&gt;I ran into an interesting problem lately with the &lt;code&gt;query-frontend&lt;/code&gt; component of &lt;a href="https://thanos.io/"&gt;Thanos&lt;/a&gt;. Here is how &lt;code&gt;--query-range.split-interval&lt;/code&gt; is described in the &lt;code&gt;--help&lt;/code&gt; output:&lt;/p&gt;
&lt;figure&gt;
&lt;img loading="lazy" src="https://giedrius.blog/wp-content/uploads/2021/10/image.png"
alt="Part of query-frontend --help output showing what is the purpose of the split interval"/&gt; &lt;figcaption&gt;
&lt;p&gt;Part of query-frontend &amp;ndash;help output showing what is the purpose of the split interval&lt;/p&gt;
&lt;/figcaption&gt;
&lt;/figure&gt;
&lt;p&gt;Computer Science is full of trade-offs and this is one of them. Currently, the Prometheus engine executes each query in a separate goroutine as I have described &lt;a href="https://giedrius.blog/2019/01/13/choosing-maximum-concurrent-queries-in-prometheus-smartly/"&gt;here&lt;/a&gt; some time ago. This mechanism lets you kind of work around this problem because each PromQL query only looks for samples in the given range (unless you use the &lt;a href="https://prometheus.io/docs/prometheus/latest/feature_flags/#negative-offset-in-promql"&gt;negative offset feature flag&lt;/a&gt;). So, if the split interval is lower then you will be able to leverage the CPU power more but with more round-trips for retrieving the same data. If the split interval is higher, then fewer round-trips will be needed to execute those queries but fewer CPU cores will be used.&lt;/p&gt;</description></item><item><title>How to Visualize Prometheus TSDB With Thanos</title><link>https://giedrius.blog/2021/01/10/how-to-visualize-prometheus-tsdb-with-thanos/</link><pubDate>Sun, 10 Jan 2021 19:18:55 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=785</guid><description>&lt;p&gt;Have you ever tried to &lt;code&gt;ls&lt;/code&gt; the Prometheus TSDB data directory just to understand what kind of data you have from the perspective of time? Here is an example listing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-fallback" data-lang="fallback"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxrwxr-x 3 gstatkevicius gstatkevicius 4096 Jun 26 2020 01EBRP7DA9N67RTT9AFE0KMXFJ
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxrwxr-x 3 gstatkevicius gstatkevicius 4096 Jun 26 2020 01EBRP7DCM68X5SPQGK3T8NNER
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxrwxr-x 2 gstatkevicius gstatkevicius 4096 Jun 26 2020 chunks_head
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- 1 gstatkevicius gstatkevicius 0 Apr 17 2020 lock
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- 1 gstatkevicius gstatkevicius 20001 Jan 2 14:01 queries.active
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x 3 gstatkevicius gstatkevicius 4096 Jan 2 14:01 wal
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We could assume that each block is 2 hours long. However, they can be compacted i.e. &amp;ldquo;joined&amp;rdquo; into bigger ones if that is enabled. Then, the blocks would not line up in a sequential way. Plus, this output of &lt;code&gt;ls&lt;/code&gt; doesn&amp;rsquo;t even show the creation time of different blocks. We could theoretically get those timestamps with &lt;code&gt;stat(2)&lt;/code&gt;, &lt;code&gt;statx(2)&lt;/code&gt; and some shell magic but that&amp;rsquo;s cumbersome. Overall, this doesn&amp;rsquo;t seem too helpful and we can do better.&lt;/p&gt;</description></item><item><title>Load Testing Thanos Query (StoreAPI)</title><link>https://giedrius.blog/2020/05/10/load-testing-thanos-query-storeapi/</link><pubDate>Sun, 10 May 2020 11:05:27 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=437</guid><description>&lt;h2 id="intro"&gt;Intro&lt;/h2&gt;
&lt;p&gt;Thanos Query is the component of &lt;a href="https://thanos.io"&gt;Thanos&lt;/a&gt; that fans out a query to one or more nodes that implement the &lt;a href="https://thanos.io/integrations.md/#storeapi"&gt;StoreAPI&lt;/a&gt; and then it can deduplicate the results. It also implements the Prometheus API which lets you use it via Grafana.&lt;/p&gt;
&lt;p&gt;Any of the other components may be the receivers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Thanos Receive;&lt;/li&gt;
&lt;li&gt;Thanos Rule;&lt;/li&gt;
&lt;li&gt;Thanos Sidecar;&lt;/li&gt;
&lt;li&gt;Thanos Compact;&lt;/li&gt;
&lt;li&gt;Thanos Query itself.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is tricky to know how much resources you will need for any given deployment of Thanos Query because it depends on a lot of different criteria. So, to know that and to actually test the limits in practice, you ought to perform what is commonly called a load/stress test. We will use a tool called &lt;a href="https://github.com/thanos-io/thanosbench/"&gt;thanosbench&lt;/a&gt; to do that in this tutorial.&lt;/p&gt;</description></item><item><title>What Is New In Thanos 0.5.0</title><link>https://giedrius.blog/2019/06/03/what-is-new-in-thanos-0-5-0/</link><pubDate>Mon, 03 Jun 2019 16:52:32 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=480</guid><description>&lt;figure&gt;
&lt;img loading="lazy" src="https://giedrius.blog/wp-content/uploads/2019/06/97e49180-661b-11e9-9882-fdc44b74debd.png"/&gt;
&lt;/figure&gt;
&lt;p&gt;&lt;a href="https://thanos.io/"&gt;Thanos&lt;/a&gt; 0.5.0-rc.0 has been recently released and the final 0.5.0 version is just around the corner. It is a good opportunity to look back on what has changed since the last version. I hope that I will be able to present a good enough perspective since I have been recently appointed as a maintainer of the project. Thanks to everyone who has contributed pull requests and bug reports 💖This could not have been done without you.&lt;/p&gt;</description></item><item><title>Everything You Need To Know About The Index Cache Size in Thanos</title><link>https://giedrius.blog/2019/04/28/everything-you-need-to-know-about-the-index-cache-size-in-thanos/</link><pubDate>Sun, 28 Apr 2019 08:29:42 +0000</pubDate><guid isPermaLink="false">https://giedrius.blog/?p=471</guid><description>&lt;p&gt;&lt;img alt="Thanos Logo" loading="lazy" src="https://thanos.io/Thanos-logo_full.svg"&gt;Just like most pieces of software nowadays, &lt;a href="https://github.com/improbable-eng/thanos"&gt;Thanos&lt;/a&gt; is not an exception and there is some caching going on there. In particular, we will talk about the index cache and its&amp;rsquo; size in &lt;a href="https://thanos.io/components/store.md/"&gt;Thanos Store&lt;/a&gt;. After a certain bug was &lt;a href="https://github.com/improbable-eng/thanos/pull/873"&gt;fixed&lt;/a&gt;, a lot of problems came up to users who were running with the default size of 200MiB. This is because this limit started being enforced whereas it was not before.&lt;/p&gt;
&lt;p&gt;I feel that it would be the perfect opportunity to explain how it works and how to determine what would be the appropriate size in your deployment.&lt;/p&gt;</description></item></channel></rss>