<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ridoy Dey</title>
    <description>The latest articles on DEV Community by Ridoy Dey (@iamridoydey).</description>
    <link>https://dev.to/iamridoydey</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4048258%2Fa8faf11c-bb8f-4f41-98b3-8e1a43cbae1d.jpg</url>
      <title>DEV Community: Ridoy Dey</title>
      <link>https://dev.to/iamridoydey</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/iamridoydey"/>
    <language>en</language>
    <item>
      <title>Building KubeTokenWatch</title>
      <dc:creator>Ridoy Dey</dc:creator>
      <pubDate>Sun, 26 Jul 2026 17:58:26 +0000</pubDate>
      <link>https://dev.to/iamridoydey/building-kubetokenwatch-3lp8</link>
      <guid>https://dev.to/iamridoydey/building-kubetokenwatch-3lp8</guid>
      <description>&lt;h1&gt;
  
  
  I built an AI agent that debugs my Kubernetes cluster — and traces its own bill
&lt;/h1&gt;

&lt;p&gt;As a devops learner we see lots of error in the cluster when we deploy any kubernetes object . A pod is stuck. &lt;code&gt;kubectl get pods&lt;/code&gt; shows a status you don't fully trust. We start by running &lt;code&gt;describe&lt;/code&gt;,&lt;code&gt;Check logs&lt;/code&gt;, &lt;code&gt;Try to connect pieces together&lt;/code&gt;. It works, eventually. It's just slow, and it happens at the worst possible time.&lt;/p&gt;

&lt;p&gt;Here's the second scenario: you've built an AI agent that gonna find out the issues for you and listed them down one by one. It works great, until the bill arrives, and you realize you have no idea which request, which user, or which loop actually caused it.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;KubeTokenWatch&lt;/strong&gt; to fix both problems with one agent. It looks at your cluster, tells you what's broken and how to fix it that you can follow to resolve easily. Isn't it save you extra hour?&lt;/p&gt;

&lt;h2&gt;
  
  
  What it actually does
&lt;/h2&gt;

&lt;p&gt;You point it at a namespace. It scans for anything unhealthy, pods, deployments, statefulsets, daemonsets, jobs, PVCs, and give you the overview what causes these with list of improvement.&lt;/p&gt;

&lt;p&gt;The clever part isn't the LLM call, it's &lt;em&gt;what&lt;/em&gt; the agent looks at before making it. Kubernetes has 30-plus built-in resource kinds, plus an unbounded number of custom resources. I could have written a check for each one. I didn't, because that list never actually ends, and it breaks the moment someone's cluster has a CRD I never heard of.&lt;/p&gt;

&lt;p&gt;Since it is an ai agent. It will handed you a big bill that you can scared of. So I also implemented the cost tracer that you will find it in the &lt;a href="https://signoz.io" rel="noopener noreferrer"&gt;SigNoz&lt;/a&gt; dashboard. Oh I just need to let you know that I instrumented this ai agent with opentelemetry so that I can trace the budget along with related metrics and logs. &lt;/p&gt;

&lt;p&gt;Here singoz plays a big role. Previously what we need to do? We have to instrument our application using opentelemetry and then need separate backend along with visualization tools like grafana. Now singoz give you all at once. You don't need another backend and then another dashboard. You can just use SigNoz. So why any delay? Just follow along with my github repo. You will do it.&lt;/p&gt;

&lt;p&gt;Everything, setup, usage, project structure, lives in the repo:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;&lt;a href="https://github.com/iamridoydey/KubeTokenWatch" rel="noopener noreferrer"&gt;github.com/iamridoydey/KubeTokenWatch&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CLI (cli.py)  ─┐
               ├──▶  agent.py (shared core)
API (app.py)  ─┘            │
                             ▼
              Groq LLM decides to call get_failed_resources
                             │
                             ▼
         Kubernetes API (via active kubeconfig — any cluster type)
                             │
                             ▼
         Real object status + events returned to the LLM
                             │
                             ▼
         LLM writes diagnosis + fix list ── OTel span: model, user, tokens, cost
                             │
                             ▼
              OTel Collector (part of self-hosted SigNoz)
                             │
                             ▼
              SigNoz — dashboards + budget-spike alert
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;cli.py&lt;/code&gt; and &lt;code&gt;app.py&lt;/code&gt; are thin wrappers — all the real logic (calling the LLM, running the Kubernetes tool, tracing cost) lives once in &lt;code&gt;agent.py&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Python 3.10+&lt;/li&gt;
&lt;li&gt;A running self-hosted SigNoz instance (OTel collector reachable at &lt;code&gt;localhost:4317&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;A free Groq API key from &lt;a href="https://console.groq.com" rel="noopener noreferrer"&gt;console.groq.com&lt;/a&gt; — no credit card required&lt;/li&gt;
&lt;li&gt;Access to a Kubernetes cluster via a working kubeconfig (&lt;code&gt;kubectl get pods&lt;/code&gt; should already work — &lt;code&gt;kind&lt;/code&gt;, minikube, or any cloud cluster all work identically)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Install dependencies
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Configure environment
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
&lt;span class="c"&gt;# edit .env and add your GROQ_API_KEY&lt;/span&gt;
&lt;span class="nb"&gt;export&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; .env | xargs&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  SigNoz deployment
&lt;/h2&gt;

&lt;p&gt;This repo includes &lt;code&gt;casting.yaml&lt;/code&gt; and &lt;code&gt;casting.yaml.lock&lt;/code&gt;, the Foundry configuration used to deploy SigNoz for this project. To reproduce the exact same self-hosted SigNoz setup on another machine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://signoz.io/foundry.sh | bash
foundryctl cast &lt;span class="nt"&gt;-f&lt;/span&gt; casting.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;h3&gt;
  
  
  CLI
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python cli.py diagnose &lt;span class="nt"&gt;--namespace&lt;/span&gt; default
python cli.py diagnose &lt;span class="nt"&gt;--namespace&lt;/span&gt; kube-system &lt;span class="nt"&gt;--user-id&lt;/span&gt; alice
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  HTTP API
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python app.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST http://localhost:5000/diagnose &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"user_id": "u1", "namespace": "default"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  View traces in SigNoz
&lt;/h3&gt;

&lt;p&gt;Open your SigNoz dashboard (typically &lt;code&gt;http://localhost:8080&lt;/code&gt;)&lt;/p&gt;

&lt;h3&gt;
  
  
  Let's build A panel that will give you the idea how easy it is to use signoz as your observability platform
&lt;/h3&gt;

&lt;h3&gt;
  
  
  On the signoz left bar click on dashboards
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq7s47vm7iax3k2z0i4iq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fq7s47vm7iax3k2z0i4iq.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Click on &lt;code&gt;new dashboard&lt;/code&gt; and then click on &lt;code&gt;create dashboard&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fior5sup1nahetcu27srn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fior5sup1nahetcu27srn.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Set the dashboard title (ex: KubeTokenWatch Cost Tracer)
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5g8d46vmk5cyx1r88szh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F5g8d46vmk5cyx1r88szh.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzzx7yigr1g5fcuymoyg9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzzx7yigr1g5fcuymoyg9.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Click on &lt;code&gt;new panel&lt;/code&gt; and select &lt;code&gt;time series&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhajgdqua7ll2mphmyvgs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fhajgdqua7ll2mphmyvgs.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  In the input write filter and aggregation type as per image below
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcmpk60vbfidbkgyw6sxs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fcmpk60vbfidbkgyw6sxs.png" alt=" " width="799" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Give this panel a name and Save it.
&lt;/h3&gt;

&lt;h3&gt;
  
  
  Now create an alert based on threshold you define.
&lt;/h3&gt;

&lt;p&gt;Click on three dot to edit panel that you created now. Scroll to the right of your panel and you will see alert option. Click on that. Then set the threshold to 0.0005. After that you will see send to. You can configure it through documentation. Easy enough.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faciygx1nb8c7ogjk3ad5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Faciygx1nb8c7ogjk3ad5.png" alt=" " width="799" height="457"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Just like this you can create other dashboards like below.
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsg2u60yc66k73fa46e9w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fsg2u60yc66k73fa46e9w.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyaxm5vw5atyhoglz6lgv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fyaxm5vw5atyhoglz6lgv.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fel741m76asfyumywvqjd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fel741m76asfyumywvqjd.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm7vzl5cxlrjrgxgv08se.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fm7vzl5cxlrjrgxgv08se.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9p8ssyy4y82rmruh6t1d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9p8ssyy4y82rmruh6t1d.png" alt=" " width="800" height="436"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This project is part of  &lt;a href="https://www.wemakedevs.org/hackathons/signoz" rel="noopener noreferrer"&gt;Agents of SigNoz Hackathon&lt;/a&gt;, by &lt;a href="https://www.wemakedevs.org/" rel="noopener noreferrer"&gt;WeMakeDevs&lt;/a&gt; and &lt;a href="https://signoz.io/" rel="noopener noreferrer"&gt;SigNoz&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you learn something from this blog post then do loving it and subscribe me for latest tech blogs. Thank you&lt;/p&gt;

</description>
      <category>signoz</category>
      <category>wemakedevs</category>
      <category>ai</category>
      <category>agents</category>
    </item>
  </channel>
</rss>
