<?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"><channel><title><![CDATA[Observability Unlocked with OCP]]></title><description><![CDATA[Observability Unlocked with OCP]]></description><link>https://monitoringocp.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 20:30:25 GMT</lastBuildDate><atom:link href="https://monitoringocp.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Centralized Monitoring for Multi-Cluster OpenShift with Prometheus, Thanos & Grafana]]></title><description><![CDATA[Monitoring OpenShift clusters is critical for visibility, reliability, and performance. OpenShift includes Prometheus and Thanos out-of-the-box, which can…]]></description><link>https://monitoringocp.hashnode.dev/centralized-monitoring-for-multi-cluster-openshift-with-prometheus-thanos-and-grafana</link><guid isPermaLink="true">https://monitoringocp.hashnode.dev/centralized-monitoring-for-multi-cluster-openshift-with-prometheus-thanos-and-grafana</guid><category><![CDATA[thanos quetier]]></category><category><![CDATA[OCP]]></category><category><![CDATA[monitoring tool]]></category><category><![CDATA[Grafana]]></category><category><![CDATA[#prometheus]]></category><dc:creator><![CDATA[AKSHAY SIV]]></dc:creator><pubDate>Thu, 19 Jun 2025 08:04:58 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-overview">🚀 Overview</h2>
<p>Monitoring OpenShift clusters is critical for visibility, reliability, and performance. OpenShift includes Prometheus and Thanos out-of-the-box, which can be leveraged to create a powerful <strong>multi-cluster monitoring dashboard</strong> using <strong>Grafana</strong>.</p>
<p>This guide walks you through <strong>step-by-step</strong>, from exposing Thanos to building a centralized Grafana dashboard.</p>
<hr />
<h2 id="heading-architecture-diagram">🧱 Architecture Diagram</h2>
<pre><code class="lang-bash">Cluster A         Cluster B         Cluster C
┌────────────┐    ┌────────────┐    ┌────────────┐
│ Thanos Querier│  │ Thanos Querier│  │ Thanos Querier│
└──────┬───────┘    └──────┬───────┘    └──────┬───────┘
       ▼                  ▼                  ▼
   HTTPS Route A      HTTPS Route B      HTTPS Route C
        \                |                /
         \               |               /
          \              ▼              /
               🌐 External Grafana Dashboard
</code></pre>
<hr />
<h2 id="heading-prerequisites">🔧 Prerequisites</h2>
<ul>
<li><p>OpenShift clusters with monitoring enabled (<code>openshift-monitoring</code> namespace present)</p>
</li>
<li><p>Access to each cluster via <code>oc</code></p>
</li>
<li><p>External Grafana instance (VM or container)</p>
</li>
<li><p>Cluster-admin or monitoring-view access on OpenShift</p>
</li>
</ul>
<hr />
<h2 id="heading-step-1-expose-thanos-querier-in-each-cluster">✅ Step 1: Expose Thanos Querier in Each Cluster</h2>
<p>Check if the Thanos route exists:</p>
<pre><code class="lang-bash">oc get route thanos-querier -n openshift-monitoring
</code></pre>
<p>If missing, create one:</p>
<pre><code class="lang-bash">oc expose svc thanos-querier -n openshift-monitoring --name=thanos-querier-route
</code></pre>
<p>Ensure TLS is set to <code>reencrypt</code>:</p>
<pre><code class="lang-bash">oc patch route thanos-querier-route -n openshift-monitoring \
  -p <span class="hljs-string">'{"spec":{"tls":{"termination":"reencrypt"}}}'</span>
</code></pre>
<hr />
<h2 id="heading-step-2-create-a-service-account-with-access">🔐 Step 2: Create a Service Account with Access</h2>
<p>Create a minimal-privilege service account:</p>
<pre><code class="lang-bash">oc create sa grafana-sa -n openshift-monitoring
oc adm policy add-cluster-role-to-user cluster-monitoring-view -z grafana-sa
</code></pre>
<p>Generate token:</p>
<pre><code class="lang-bash">oc create token grafana-sa -n openshift-monitoring
</code></pre>
<p>Save this token — you’ll use it in Grafana.</p>
<hr />
<h2 id="heading-step-3-set-up-grafana-and-add-thanos-as-data-sources">📡 Step 3: Set Up Grafana and Add Thanos as Data Sources</h2>
<p>In <strong>Grafana UI &gt; Configuration &gt; Data Sources &gt; Add Prometheus</strong>:</p>
<p>Repeat for each cluster:</p>
<ul>
<li><p><strong>Name</strong>: <code>Thanos - Cluster X</code></p>
</li>
<li><p><strong>URL</strong>: <code>https://thanos-querier-openshift-monitoring.apps.&lt;cluster&gt;.com</code></p>
</li>
<li><p><strong>Auth</strong>: Bearer Token (paste token)</p>
</li>
<li><p><strong>Skip TLS Verify</strong>: ✅ if using self-signed certs</p>
</li>
</ul>
<hr />
<h2 id="heading-step-4-create-a-dynamic-multi-cluster-dashboard">📊 Step 4: Create a Dynamic Multi-Cluster Dashboard</h2>
<p>Create a <strong>template variable</strong>:</p>
<p><strong>Dashboard Settings &gt; Variables &gt; Add Variable</strong>:</p>
<pre><code class="lang-bash">Name: datasource
Type: Datasource
Datasource <span class="hljs-built_in">type</span>: Prometheus
</code></pre>
<p>Then, in each panel:</p>
<ul>
<li><p>Use <code>${datasource}</code> as the data source.</p>
</li>
<li><p>Query example: <code>up{job="kubelet"}</code></p>
</li>
<li><p>Add label filters like <code>cluster</code>, <code>namespace</code>, <code>pod</code></p>
</li>
</ul>
<p>Now the dashboard dynamically switches clusters from a dropdown.</p>
<hr />
<h2 id="heading-bonus-use-label-filters-for-cluster-specific-views">🧠 Bonus: Use Label Filters for Cluster-Specific Views</h2>
<p>Many metrics include <code>cluster</code> label by default. Use it in PromQL:</p>
<pre><code class="lang-bash">sum(up{job=<span class="hljs-string">"kubelet"</span>}) by (cluster)
</code></pre>
<p>You can also add namespace or workload-level filters.</p>
<hr />
<h2 id="heading-security-tips">🔒 Security Tips</h2>
<ul>
<li><p>Use dedicated <code>grafana-sa</code> with only <code>cluster-monitoring-view</code> role</p>
</li>
<li><p>Store tokens securely (e.g., in secrets manager)</p>
</li>
<li><p>Use HTTPS for all endpoints</p>
</li>
<li><p>Monitor for expired tokens</p>
</li>
</ul>
<hr />
<h2 id="heading-conclusion">🎉 Conclusion</h2>
<p>With Thanos and Grafana, you can monitor <strong>all OpenShift clusters from a single pane of glass</strong>. This solution is secure, scalable, and highly customizable.</p>
<hr />
<p>✅ Follow me for more OpenShift + DevOps content.</p>
<p>💬 Questions? Drop them in the comments!</p>
]]></content:encoded></item></channel></rss>