<?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 Richa Varma on Medium]]></title>
        <description><![CDATA[Stories by Richa Varma on Medium]]></description>
        <link>https://medium.com/@varma.richavarma?source=rss-a3056b31111f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3FxRmG2fWmPox4XU.jpg</url>
            <title>Stories by Richa Varma on Medium</title>
            <link>https://medium.com/@varma.richavarma?source=rss-a3056b31111f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 10:58:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@varma.richavarma/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[Managing Prometheus Data in IBM Cloud Object Storage with Thanos]]></title>
            <link>https://medium.com/@varma.richavarma/managing-prometheus-data-in-ibm-cloud-object-storage-with-thanos-4f51a4bbd222?source=rss-a3056b31111f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f51a4bbd222</guid>
            <category><![CDATA[thanos]]></category>
            <category><![CDATA[ibm-cloud]]></category>
            <category><![CDATA[cloud-object-storage]]></category>
            <category><![CDATA[observability]]></category>
            <dc:creator><![CDATA[Richa Varma]]></dc:creator>
            <pubDate>Sun, 04 May 2025 16:59:20 GMT</pubDate>
            <atom:updated>2025-05-04T16:59:20.380Z</atom:updated>
            <content:encoded><![CDATA[<p>Lately, I’ve been checking out Prometheus, which is a popular open-source tool used by companies to keep an eye on their workloads, whether they’re running as containers in Kubernetes clusters or on bare-metal servers. While Prometheus does a great job with real-time monitoring, it can struggle when it comes to scaling storage, especially when there’s a lot of data or when you need to store things for longer periods. That’s where <strong>Thanos</strong> steps in — it’s like an upgrade to Prometheus that helps solve these storage and scalability issues, making it a better fit for big, long-term monitoring setups.</p><p>Prometheus just works — scrape → store → alert → query, all from a single box. It’s monolithic in design, meaning all of its components — scraping, storing, alerting, and querying — run together in one process. The metrics are scraped from various targets, stored in its time-series database, and then queried via an HTTP server.</p><p>When companies switch to microservices, monitoring ends up spread across a bunch of different Prometheus instances — one for frontend, another for backend, and maybe one for infrastructure too. That brings up two main concerns:</p><ul><li><strong>Messy queries</strong>: You’ve gotta pull data from multiple Prometheus setups just to get the full picture.</li><li><strong>Storage limits</strong>: Prometheus only keeps data locally for about 15 days. So if something crashes, you might lose data.</li></ul><p>That’s where Thanos becomes really useful — it solves these issues by providing external, long-term storage, backup capabilities, and querying across multiple Prometheus instances and clusters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gUOPztEJSI0mUGcklVRWqg.jpeg" /></figure><p>In this blog, I’ve set up Prometheus with a Thanos sidecar in a Minikube cluster, backing up metrics data to IBM Cloud Object Storage (COS).</p><p><em>Firstly, create a bucket in IBM Cloud Object Storage (COS) and generate HMAC credentials with Writer access, obtaining the access key, secret key, and S3 endpoint.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wt8xIasrWBP33X-Gu5PFlA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OR_w4yB8CZ8lRomdC186Yg.png" /></figure><p><em>In your cluster create a Kubernetes secret containing the configuration for the COS bucket. You can define the configurationin a YAML file and then create a kube secret from it.</em></p><pre>kubectl create secret generic objectstore \<br>  --from-file=objectstore.config=objectstore.yaml \<br>  --namespace=observe</pre><pre>type: s3<br>config:<br>  bucket: &quot;&lt;bucket_name&gt;&quot;<br>  endpoint: &quot;&lt;s3_endpoint&gt;&quot;<br>  access_key: &quot;&lt;access_key&gt;&quot;<br>  secret_key: &quot;&lt;secret_key&gt;&quot;<br>  insecure: false</pre><p><em>Here, we are using a Prometheus + Thanos sidecar setup to collect pod-level metrics. For this we have to create the necessary RBAC permissions that allow Prometheus to use Kubernetes service discovery. This enables Prometheus to automatically discover and scrape metrics from running pods, which the Thanos sidecar then backs up to IBM Cloud Object Storage (COS).</em></p><p><em>ServiceAccount → used by Prometheus → bound to </em><em>ClusterRole with permissions to read pods, nodes, services, etc. → via </em><em>ClusterRoleBinding → enabling service discovery in the </em><em>observe namespace.</em></p><pre>apiVersion: v1<br>kind: ServiceAccount<br>metadata:<br>  name: prometheus-server<br>  namespace: observe<br>---<br>apiVersion: rbac.authorization.k8s.io/v1<br>kind: ClusterRole<br>metadata:<br>  name: prometheus-server-cluster-role<br>rules:<br>  - apiGroups: [&quot;&quot;]<br>    resources:<br>      - nodes<br>      - nodes/proxy<br>      - services<br>      - endpoints<br>      - pods<br>      - namespaces<br>    verbs: [&quot;get&quot;, &quot;list&quot;, &quot;watch&quot;]<br>---<br>apiVersion: rbac.authorization.k8s.io/v1<br>kind: ClusterRoleBinding<br>metadata:<br>  name: prometheus-server-cluster-role-binding<br>roleRef:<br>  apiGroup: rbac.authorization.k8s.io<br>  kind: ClusterRole<br>  name: prometheus-server-cluster-role<br>subjects:<br>  - kind: ServiceAccount<br>    name: prometheus-server<br>    namespace: observe</pre><p><em>This </em><em>ConfigMap named </em><em>prometheus-config in the </em><em>observe namespace contains the configuration for Prometheus. It sets a global scrape interval of 15 seconds and defines external labels such as </em><em>cluster: &quot;minikube&quot; and </em><em>replica: &quot;a&quot; to help identify the source of metrics. The </em><em>scrape_configs section uses Kubernetes service discovery with the </em><em>role: pod setting, allowing Prometheus to automatically discover and scrape metrics from all pods in the cluster.</em></p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: prometheus-config<br>  namespace: observe<br>data:<br>  prometheus.yml: |<br>    global:<br>      scrape_interval: 15s<br>      external_labels:<br>        cluster: &quot;minikube&quot;<br>        replica: &quot;a&quot;<br>    scrape_configs:<br>      - job_name: &#39;kubernetes-pods&#39;<br>        kubernetes_sd_configs:<br>          - role: pod</pre><p><em>Here’s the basic configuration for setting up Prometheus with a Thanos sidecar. Below is an example of the configuration file:</em></p><pre>apiVersion: apps/v1<br>kind: StatefulSet<br>metadata:<br>  name: prometheus-thanos<br>  namespace: observe<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: prometheus-thanos<br>  serviceName: prometheus-thanos<br>  template:<br>    metadata:<br>      labels:<br>        app: prometheus-thanos<br>    spec:<br>      serviceAccountName: prometheus-server<br>      containers:<br>        - name: prometheus<br>          image: prom/prometheus:v2.51.0<br>          args:<br>            - &quot;--config.file=/etc/prometheus/prometheus.yml&quot;<br>            - &quot;--storage.tsdb.path=/prometheus&quot;<br>            - &quot;--web.enable-lifecycle&quot;<br>            - &quot;--storage.tsdb.min-block-duration=30m&quot;<br>            - &quot;--storage.tsdb.max-block-duration=30m&quot;<br>            - &quot;--storage.tsdb.retention.time=1h&quot;<br>          ports:<br>            - containerPort: 9090<br>              name: web<br>          volumeMounts:<br>            - name: prometheus-config<br>              mountPath: /etc/prometheus<br>            - name: prometheus-data<br>              mountPath: /prometheus<br><br>        - name: thanos-sidecar<br>          image: quay.io/thanos/thanos:v0.35.1<br>          securityContext:<br>            runAsUser: 0<br>          args:<br>            - &quot;sidecar&quot;<br>            - &quot;--tsdb.path=/prometheus&quot;<br>            - &quot;--prometheus.url=http://localhost:9090&quot;<br>            - &quot;--objstore.config-file=/etc/thanos/objectstore.config&quot;<br>            - &quot;--grpc-address=0.0.0.0:10901&quot;<br>            - &quot;--http-address=0.0.0.0:10902&quot;<br>          ports:<br>            - name: grpc<br>              containerPort: 10901<br>            - name: http<br>              containerPort: 10902<br>          volumeMounts:<br>            - name: prometheus-data<br>              mountPath: /prometheus<br>            - name: objstore-config<br>              mountPath: /etc/thanos<br>              readOnly: true<br><br>      volumes:<br>        - name: prometheus-config<br>          configMap:<br>            name: prometheus-config<br>        - name: objstore-config<br>          secret:<br>            secretName: objectstore<br><br>  volumeClaimTemplates:<br>    - metadata:<br>        name: prometheus-data<br>      spec:<br>        accessModes: [&quot;ReadWriteOnce&quot;]<br>        resources:<br>          requests:<br>            storage: 10Gi</pre><p><strong><em>Prometheus</em></strong><em> scrapes metrics every 15s and stores them in </em><em>/prometheus, which is backed by a </em><strong><em>persistent volume (PVC)</em></strong><em>.It </em><strong><em>retains only 1 hour</em></strong><em> of data using </em><em>--storage.tsdb.retention.time=1h.Every 30 minutes, data is compacted into a </em><strong><em>block</em></strong><em>, and older blocks beyond 1 hour are deleted by Prometheus automatically.</em></p><p><em>The Thanos container mounts the same </em><em>/prometheus directory.It watches for new blocks created by Prometheus.Before Prometheus deletes old blocks (past 1h), </em><strong><em>Thanos creates a hard link</em></strong><em> to them so it can upload without data loss.Once uploaded, Thanos deletes the link — it’s a clean handoff.It also exposes a </em><strong><em>gRPC endpoint on port 10901</em></strong><em> for other Thanos components (like Query or Store) to fetch local Prometheus data.</em></p><p><em>To ensure that your data is being uploaded successfully, look for the following message in the Thanos sidecar logs- ‘Upload new block’</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbEVCN53OapoW8L1Hp2ttw.png" /></figure><p><em>You can also search for the chunk id in the bucket to verify upload.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVawzNxWW6fOpBXYqtHO7w.png" /></figure><p><em>To view the Prometheus graph in your browser, you need to create a service for Prometheus and then port-forward it locally. In our Minikube cluster, CoreDNS is running and exposing metrics, which are scraped by Prometheus and can be viewed through the Prometheus UI.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BVFEJkM6KyTAFetigTbRLA.png" /></figure><p>This configuration can be scaled out to multiple Prometheus instances, each with its own Thanos sidecar, all uploading data to the <strong>same COS bucket</strong>. Each instance is separated logically by assigning a unique --label in the sidecar config (like cluster, env, or prometheus_instance).</p><p>Then, using Thanos Querier, you can query data from <strong>all</strong> the Prometheus instances at once, across regions or clusters, as if it’s one unified data source.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f51a4bbd222" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>