<?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 Clarissa B. Vega on Medium]]></title>
        <description><![CDATA[Stories by Clarissa B. Vega on Medium]]></description>
        <link>https://medium.com/@issayvega?source=rss-fae55e935a8a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*v2cG2_JilYtA1sJX</url>
            <title>Stories by Clarissa B. Vega on Medium</title>
            <link>https://medium.com/@issayvega?source=rss-fae55e935a8a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:49:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@issayvega/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[From Accidental Architecture to AI-Powered SRE: How We Tamed 6 Microservices]]></title>
            <link>https://medium.com/@issayvega/from-accidental-architecture-to-ai-powered-sre-how-we-tamed-6-microservices-35c2a6305fb7?source=rss-fae55e935a8a------2</link>
            <guid isPermaLink="false">https://medium.com/p/35c2a6305fb7</guid>
            <category><![CDATA[grafana-loki]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[grafana-prometheus]]></category>
            <category><![CDATA[grafana-tempo]]></category>
            <dc:creator><![CDATA[Clarissa B. Vega]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 05:45:10 GMT</pubDate>
            <atom:updated>2026-09-18T05:46:37.434Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A candid post-mortem on monkey-patched DNS bugs, accidental server setups, and building an automated triage pipeline with Prometheus, Loki, Tempo, OpenTelemetry, and Groq.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AafO9TTFQ6Lv5EI3Cqv4VA.png" /></figure><p>Every backend engineer knows the 2:00 AM panic.</p><p>You run six interconnected NestJS microservices in Docker. One service stalls, another throws generic 500s, and you’re juggling six terminal tabs running docker logs --tail 200 -f, trying to manually correlate timestamps across servers while production burns.</p><p>We call this <strong>Observability by Prayer</strong>.</p><p>A few months ago, our team at EmpowerX decided we were done praying. We set out to build a unified observability stack: <strong>Prometheus</strong> (metrics), <strong>Loki</strong> (logs), <strong>Tempo</strong> &amp; <strong>OpenTelemetry</strong> (traces), and an <strong>AI Alert Service</strong> powered by Groq and Llama 3.3 70B that diagnoses incidents in Discord before we even open a laptop.</p><p>Along the way, we broke DNS, battled port collisions, and accidentally created our best architecture by mistake. Here is what we learned.</p><h3>1. The “Wrong Server” Mistake That Saved Our Architecture</h3><p>Our original dev instance ran everything: six APIs, PostgreSQL and Mongo databases, Redis, and an Nginx reverse proxy. Running Prometheus, Grafana, and Loki alongside them created a critical flaw: when the apps spiked, the monitoring choked.</p><p>We provisioned a separate t3.small EC2 instance (xxx.xx.xx.xxx) to isolate monitoring from our applications (xxx.xx.xx.xxx).</p><p>Late one night, we mistakenly installed and started Loki on the <em>monitoring</em> box instead of the dev box. We kicked ourselves — until we stepped back and realized: <strong>this mistake was the right architecture.</strong></p><p>Why run log storage on the dev host? By running Loki natively on the monitoring server and pushing logs remotely from NestJS via pino-loki, log ingestion survived even if the application host went down.</p><blockquote><strong><em>VPC Lesson:</em></strong><em> When routing internal telemetry between AWS instances, lock security groups with strict </em><em>/32 CIDRs (e.g., </em><em>xxx.xx.xx.xxx/32). Only the scraper and the log receiver should talk to each other—no open internal networks.</em></blockquote><h3>2. The Nightmare: When OpenTelemetry Broke Docker DNS</h3><p>With metrics and logs in place, we introduced distributed tracing for our core API, which runs up to 12 parallel database queries per request.</p><p>We installed the popular meta-package:</p><pre>npm install @opentelemetry/auto-instrumentations-node</pre><p>We restarted our containers, and the app instantly crashed:</p><pre>MongooseServerSelectionError: connect ECONNREFUSED empowerx-requests-db:27017</pre><p>Mongoose could no longer resolve internal Docker hostnames. Raw IPs worked, but container names hung indefinitely.</p><h3>The Culprit</h3><p>Under the hood, @opentelemetry/auto-instrumentations-node aggressively monkey-patches Node&#39;s native C++ bindings for dns, net, and socket to measure resolution times. Inside Docker, this patched resolver failed against Docker’s internal DNS (127.0.0.xx).</p><h3>The Fix</h3><p>We stripped out the meta-package and configured only explicit, non-invasive instrumentations:</p><pre>import { NodeSDK } from &#39;@opentelemetry/sdk-node&#39;;<br>import { HttpInstrumentation } from &#39;@opentelemetry/instrumentation-http&#39;;<br>import { ExpressInstrumentation } from &#39;@opentelemetry/instrumentation-express&#39;;<br><br>const sdk = new NodeSDK({<br>  instrumentations: [<br>    new HttpInstrumentation(),<br>    new ExpressInstrumentation(),<br>  ],<br>});<br>sdk.start();</pre><p>Native DNS returned to normal, Mongoose reconnected in 2ms, and the service booted cleanly.</p><h3>3. When the Alert Becomes the Incident</h3><p>We wanted Infrastructure as Code, so we provisioned our Grafana alert rules via YAML (/etc/grafana/provisioning/alerting/fsds-alerts.yml).</p><p>Then our Discord exploded with dozens of alerts: Health: error (ExecError).</p><p>When Grafana restarted, its internal data source UID shifted, breaking the hardcoded UID in our YAML. In Grafana, an execution failure counts as a firing alert. Worse, deleting the YAML file didn’t remove the alerts — Grafana tags provisioned rules with provenance: file and preserves them in its internal database.</p><p>The only fix was writing a dedicated fsds-delete.yml with a deleteRules directive:</p><pre>apiVersion: 1<br>deleteRules:<br>  - orgId: 1<br>    uid: fsds-high-error-rate</pre><p><strong>Our rule moving forward:</strong> For evolving data sources, build alert rules in the Grafana UI (which auto-binds to the active UID) or manage them strictly via Terraform.</p><h3>4. The Secret Weapon: Context-Rich AI Alerting</h3><p>A generic alert saying Error Rate &gt; 5% causes alert fatigue. We wanted an alert that explained <em>why</em> it fired.</p><p>We built a lightweight Node.js service (:3001) that intercepts Grafana alert webhooks, queries Loki for recent logs, and uses <strong>Groq (Llama 3.3 70B)</strong> to triage the incident in real time.</p><p>[Grafana Alert] ──► [AI Service :3001]<br> │<br> ├─► 1. Query Loki for 5xx logs, top IPs &amp; routes<br> └─► 2. Send payload to Groq (Llama 3.3 70B)<br> │<br> ▼<br> [Actionable Discord Report]</p><p>Instead of a vague alert, our team receives this in Discord within a second:</p><p><strong>🚨 High Error Rate on empowerx-fsds-api</strong><br>• <strong>Top Route:</strong> POST /api/v1/auth/verify-otp (92% of traffic)<br>• <strong>Top Source IP:</strong> xxx.xx.xxx.x via x-forwarded-for<br>• <strong>AI Diagnosis:</strong> Credential-stuffing spike saturating Redis connection pools and causing downstream 504 timeouts.<br>• <strong>Action:</strong> Apply Nginx rate limit to /verify-otp and block IP at security group.</p><h3>3 Hard-Won Lessons</h3><ol><li><strong>Beware “automagic” instrumentation:</strong> Meta-packages that monkey-patch Node.js internals can break container networking in subtle ways. Target specific libraries instead.</li><li><strong>Link traces to logs immediately:</strong> Inject your active OpenTelemetry trace_id into your logger (pinoHttp.mixin). A trace tells you <em>where</em> time was lost; the correlated log tells you <em>why</em>.</li><li><strong>Alerts need context, not just thresholds:</strong> An alert that doesn’t include the culprit route, source IP, and stack trace just shifts the investigation work to a tired human. Automate the first 5 minutes of triage.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35c2a6305fb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>