<?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[Monitoring - openobserve]]></title><description><![CDATA[Monitoring - openobserve]]></description><link>https://monitoring-openobserve.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 09 Sep 2026 07:38:41 GMT</lastBuildDate><atom:link href="https://monitoring-openobserve.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Real-Time Kubernetes Monitoring with OpenObserve, Prometheus, and Python]]></title><description><![CDATA[🧩 Introduction
In today’s cloud-native ecosystem, observability is a must. While tools like Grafana and Loki are widely used, I recently explored a different approach using OpenObserve, a high-performance, low-cost observability platform.
In this po...]]></description><link>https://monitoring-openobserve.hashnode.dev/real-time-kubernetes-monitoring-with-openobserve-prometheus-and-python</link><guid isPermaLink="true">https://monitoring-openobserve.hashnode.dev/real-time-kubernetes-monitoring-with-openobserve-prometheus-and-python</guid><category><![CDATA[#OpenObserve]]></category><category><![CDATA[AWS]]></category><category><![CDATA[Kubernetes]]></category><category><![CDATA[observability]]></category><category><![CDATA[Devops]]></category><category><![CDATA[#prometheus]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[Python]]></category><category><![CDATA[cloud native]]></category><category><![CDATA[Cloud Computing]]></category><category><![CDATA[opensource]]></category><dc:creator><![CDATA[Pavithra]]></dc:creator><pubDate>Sun, 15 Jun 2025 17:10:42 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-introduction">🧩 Introduction</h2>
<p>In today’s <strong>cloud-native ecosystem</strong>, observability is a must. While tools like <strong>Grafana</strong> and <strong>Loki</strong> are widely used, I recently explored a different approach using <strong>OpenObserve</strong>, a high-performance, low-cost observability platform.</p>
<p>In this post, I’ll walk you through how we monitored <strong>Kubernetes pods</strong>—capturing <strong>pod status</strong>, <strong>logs</strong>, <strong>age</strong>, and <strong>log counts</strong>—using <strong>OpenObserve</strong>, <strong>Prometheus</strong>, and <strong>Python scripts</strong>, with an addition of <strong>Vector</strong> for log forwarding.</p>
<h2 id="heading-tech-stack">🛠️ Tech Stack</h2>
<ul>
<li><p><strong>Kubernetes</strong> (Minikube running on an AWS EC2 instance)</p>
</li>
<li><p><strong>Prometheus</strong> – for scraping application and pod-level metrics</p>
</li>
<li><p><strong>Python</strong> – for collecting Kubernetes metadata and logs</p>
</li>
<li><p><strong>Vector</strong> (optional) – for forwarding logs</p>
</li>
<li><p><strong>OpenObserve</strong> – for storing and visualizing logs and metrics</p>
</li>
</ul>
<h2 id="heading-use-case-overview">📌 Use Case Overview</h2>
<p>Our observability goals included:</p>
<ul>
<li><p>Monitoring <strong>pod lifecycle</strong>: status, restarts, and age</p>
</li>
<li><p>Collecting and <strong>centralizing pod logs</strong> from all namespaces</p>
</li>
<li><p><strong>Dynamically tracking</strong> pod age and restart patterns</p>
</li>
<li><p>Generating custom <strong>request count metrics</strong> using Prometheus actuator endpoints</p>
</li>
<li><p>Creating <strong>dashboards and alerts</strong> in OpenObserve for real-time insights</p>
</li>
</ul>
<h2 id="heading-step-by-step-procedure">🧭 Step-by-Step Procedure</h2>
<p>Here’s a structured breakdown of how we implemented the observability stack:</p>
<h3 id="heading-step-1-set-up-kubernetes-environment">🔹 Step 1: Set Up Kubernetes Environment</h3>
<p>We began by creating a <strong>Minikube cluster</strong> on an <strong>AWS EC2 instance</strong>.</p>
<ul>
<li><p>Installed Minikube on an <strong>Amazon Linux 2</strong> EC2 instance</p>
</li>
<li><p>Installed and configured <code>kubectl</code></p>
</li>
<li><p>Deployed sample applications and services to simulate workloads</p>
</li>
<li><p>Ensured network access and DNS resolution for external observability tools</p>
</li>
</ul>
<h3 id="heading-step-2-deploy-and-configure-openobserve-external-to-kubernetes">🔹 Step 2: Deploy and Configure OpenObserve (External to Kubernetes)</h3>
<p>Instead of deploying OpenObserve inside the Kubernetes cluster, we ran it on a <strong>separate EC2 instance using Docker</strong>.</p>
<h4 id="heading-deployment-highlights">Deployment Highlights:</h4>
<ul>
<li><p><strong>Docker-based setup</strong>: Pulled and ran OpenObserve as a container</p>
</li>
<li><p><strong>Public access</strong>: The container’s default port (<code>5080</code>) was exposed</p>
</li>
<li><p><strong>Security groups</strong> were adjusted to allow ingress traffic</p>
</li>
<li><p>Accessed the web UI via <code>http://&lt;ec2-public-ip&gt;:5080</code></p>
</li>
</ul>
<h4 id="heading-ingestion">Ingestion:</h4>
<ul>
<li><p><strong>Logs were pushed</strong> via OpenObserve’s HTTP API using Python scripts (or optionally Vector)</p>
</li>
<li><p>Logs were <strong>tagged with metadata</strong> like namespace, pod name, and timestamp</p>
</li>
<li><p>Retention and indexing policies were configured for performance and cost control</p>
</li>
</ul>
<h3 id="heading-step-3-configure-prometheus-to-scrape-metrics">🔹 Step 3: Configure Prometheus to Scrape Metrics</h3>
<p>We configured <strong>Prometheus</strong> to collect metrics from the applications:</p>
<ul>
<li><p>Enabled <code>/actuator/prometheus</code> endpoint (for Spring Boot apps)</p>
</li>
<li><p>Exposed relevant <strong>custom metrics</strong> (like log count or request volume)</p>
</li>
<li><p>Configured Prometheus to <strong>auto-discover</strong> application pods via Kubernetes service discovery</p>
</li>
<li><p>Ensured Prometheus was running either inside Minikube or externally, as required</p>
</li>
</ul>
<h3 id="heading-step-4-collect-pod-metadata-using-python">🔹 Step 4: Collect Pod Metadata Using Python</h3>
<p>A custom <strong>Python script</strong> was developed to interface with the Kubernetes API and extract:</p>
<ul>
<li><p><strong>Pod status</strong>: Running, Pending, CrashLoopBackOff, etc.</p>
</li>
<li><p><strong>Pod age</strong>: By calculating the time since creation timestamp</p>
</li>
<li><p><strong>Restart count</strong>: To identify instability in applications</p>
</li>
<li><p><strong>Other metadata</strong>: Such as pod name, namespace, node name, etc.</p>
</li>
</ul>
<p>This script helped us build a dynamic and real-time picture of pod health.</p>
<h3 id="heading-step-5-push-logs-to-openobserve">🔹 Step 5: Push Logs to OpenObserve</h3>
<p>Using the same Python script (or optionally <strong>Vector</strong>):</p>
<ul>
<li><p>Logs were <strong>collected from each pod</strong> using the Kubernetes logs API</p>
</li>
<li><p>Each log line was <strong>enriched</strong> with custom fields (e.g., pod name, level, timestamp)</p>
</li>
<li><p>Logs were pushed to <strong>OpenObserve’s ingestion endpoint</strong> over HTTP/HTTPS</p>
</li>
<li><p>This enabled <strong>centralized log search and visualization</strong></p>
</li>
</ul>
<h3 id="heading-step-6-generate-custom-metrics">🔹 Step 6: Generate Custom Metrics</h3>
<p>We also tracked metrics derived from log data:</p>
<ul>
<li><p><strong>Log volume per pod</strong> (count of logs over time)</p>
</li>
<li><p>Breakdown by <strong>log severity</strong>: info, warn, error</p>
</li>
<li><p><strong>Application-level metrics</strong> like total requests, error rate, etc.</p>
</li>
</ul>
<p>These metrics were exposed via HTTP endpoints and scraped by Prometheus.</p>
<h3 id="heading-step-7-visualize-data-in-openobserve">🔹 Step 7: Visualize Data in OpenObserve</h3>
<p>Once data was flowing into OpenObserve, we created <strong>dashboards</strong> to bring insights to life:</p>
<ul>
<li><p><strong>Time-series graphs</strong> for log counts and error spikes</p>
</li>
<li><p><strong>Health dashboards</strong> for pod status, age, and restart frequency</p>
</li>
<li><p><strong>Search filters</strong> to isolate logs per namespace, pod, or severity</p>
</li>
<li><p>Set up <strong>alerts and thresholds</strong> (e.g., error rate per minute)</p>
<h1 id="heading-ia"> </h1>
<p>  <strong>Architecture Overview:  
  </strong></p>
</li>
</ul>
<p><img src="https://sdmntprsouthcentralus.oaiusercontent.com/files/00000000-99cc-61f7-b008-3a0f29ccfc5c/raw?se=2025-06-15T18%3A02%3A17Z&amp;sp=r&amp;sv=2024-08-04&amp;sr=b&amp;scid=21c6ff72-2591-5e1c-b685-da58fff65efb&amp;skoid=c953efd6-2ae8-41b4-a6d6-34b1475ac07c&amp;sktid=a48cca56-e6da-484e-a814-9c849652bcb3&amp;skt=2025-06-14T21%3A43%3A50Z&amp;ske=2025-06-15T21%3A43%3A50Z&amp;sks=b&amp;skv=2024-08-04&amp;sig=G5ORdgOSM7GeChKXqajIXqV4aT5Lf2f6%2BDRIkoFGpdM%3D" alt /></p>
<h2 id="heading-ia-1"> </h2>
<p>✅ Conclusion</p>
<p>This observability setup using <strong>OpenObserve</strong>, <strong>Prometheus</strong>, and <strong>Python automation</strong> proved to be:</p>
<ul>
<li><p><strong>Lightweight</strong>: No heavy agents or resource-intensive components</p>
</li>
<li><p><strong>Flexible</strong>: Easily customizable for any Kubernetes setup</p>
</li>
<li><p><strong>Cost-effective</strong>: Fully open-source and easy to scale</p>
</li>
<li><p><strong>DevOps-friendly</strong>: Integrates seamlessly into modern pipelines</p>
</li>
</ul>
]]></content:encoded></item></channel></rss>