<?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 Deepak on Medium]]></title>
        <description><![CDATA[Stories by Deepak on Medium]]></description>
        <link>https://medium.com/@deepakjd2004?source=rss-6ec22037447------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4q7sO-S9c76Ce5lCkLlJrQ.jpeg</url>
            <title>Stories by Deepak on Medium</title>
            <link>https://medium.com/@deepakjd2004?source=rss-6ec22037447------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 19:53:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@deepakjd2004/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[Practical Guide to Implement Generative Engine Optimization (GEO)]]></title>
            <link>https://deepakjd2004.medium.com/practical-guide-to-implement-generative-engine-optimization-geo-c60266e7a2f3?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/c60266e7a2f3</guid>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[seo]]></category>
            <category><![CDATA[geo]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Thu, 28 May 2026 08:58:24 GMT</pubDate>
            <atom:updated>2026-05-28T08:58:24.433Z</atom:updated>
            <content:encoded><![CDATA[<p>To make an AI search engine (like Perplexity, ChatGPT Search, or Google Gemini) recommend your online business ahead of competitors for a query like <em>“best tea options”</em> or <em>“where to buy Earl Grey online”</em>, you must optimize for <strong>Generative Engine Optimization (GEO)</strong>.</p><p>Unlike traditional SEO, which focuses heavily on keyword matching and backlink profiles, AI search engines prioritize specific contextual vectors:</p><ul><li><strong>Topic Authority:</strong> Establishing a comprehensive network of deep, interconnected content that covers an entire subject cluster, rather than optimizing standalone pages.</li><li><strong>Explicit Structural Data:</strong> Providing highly organized, standardized machine code that explicitly declares data identities, removing the need for an AI to “guess” your context.</li><li><strong>Brand Sentiment:</strong> The aggregate emotional metric (positive, neutral, negative) pulled from public reviews, forums, and earned media that algorithms use to assess brand trust.</li><li><strong>Conversational Alignment:</strong> Tailoring the prose structure to directly mirror natural human syntax and phrasing, allowing Large Language Models (LLMs) to easily retrieve clean answers.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DlED4xWOLqCTQZ0atzgZFA.png" /><figcaption>GEO Optimization</figcaption></figure><h3>The Practical Battle</h3><p>Let’s look at this practically. Suppose you are the site owner of an online grocery store called <strong>Fresh Food People</strong>(http://www.freshfoodpeople.com/) and your primary competitor is <strong>Down Down Price</strong> (https://www.downdownprice.com). Both are fictious site :)</p><p>As a site owner, you need to understand the most effective ways to make AI engines cite your content first over your competitor. Here are the 5 pillars of execution:</p><h3>1. Optimize for “Brand Association” via Semantic Data</h3><blockquote><strong><em>What is a Knowledge Graph?</em></strong><em> &gt; A Knowledge Graph is a programmatic network of real-world entities (people, places, organizations, and products) and the semantic relationships between them. Instead of seeing words as isolated strings, an AI uses a knowledge graph to understand that “Fresh Food People” </em><strong><em>[Organization]</em></strong><em> → </em>retails<em> → “Twinings” </em><strong><em>[Brand]</em></strong><em> → </em>which is a type of<em> → “Tea” </em><strong><em>[Beverage]</em></strong><em>.</em></blockquote><p>AI models rely heavily on internal Knowledge Graphs to ground their responses. You need the AI to treat the entity <em>Fresh Food People</em> and the entity <em>Tea</em> as highly correlated concepts.</p><ul><li><strong>Combine Schema Blocks:</strong> Do not just use a generic product schema. Use nested JSON-LD that connects the Product (e.g., Twinings English Breakfast) directly to the Merchant (<em>Fresh Food People</em>) as the primary seller, complete with real-time stock availability.</li><li><strong>Entity-Driven Text:</strong> On your category pages, use clear entity language. Write, <em>“Fresh Food People stocks Australia’s largest range of herbal, black, and green teas, including exclusive organic blends,”</em> instead of just displaying empty product grids.</li></ul><h3>2. Maximize Information Density (The GEO Rule)</h3><p>Peer-reviewed academic research from Princeton University, Georgia Tech, and the Allen Institute for AI (<em>KDD 2024</em>) proves that LLMs favor high-density, authoritative language over fluffy marketing text.</p><pre>[ TRADITIONAL SEO COPY ]                 [ HIGH-DENSITY GEO COPY ]<br>   ┌────────────────────────────────┐       ┌────────────────────────────────┐<br>   │ &quot;We love tea! Check out our    │       │ &quot;Our Organic Earl Grey features│<br>   │ awesome, delicious range of    │   VS  │ Assam black tea (India),       │<br>   │ morning tea bags on sale now.&quot; │       │ 45mg caffeine, unbleached corn-│<br>   │     (0% Data / Low Density)    │       │ starch compostable bags.&quot;      │<br>   └────────────────────────────────┘       └────────────────────────────────┘</pre><ul><li><strong>Include Expert Data:</strong> Give the AI hard facts it can extract for its text summaries. Add clear data points on your pages like leaf origins, brewing temperatures, caffeine levels, and organic certifications. The Princeton study demonstrated that <strong>adding statistics and data points can increase an AI engine’s citation visibility by up to 37%</strong>.</li><li><strong>Direct Comparisons:</strong> Create comparison tables directly on your site (e.g., comparing Loose Leaf vs. Tea Bags). AI bots love scraping structured comparison tables to answer user queries, which directly triggers a citation link back to your page.</li></ul><h3>3. Build a “Moat” of External Sentiment and Citations</h3><p>AI search engines do not just read your website; they cross-reference the entire internet to see who is trusted. If 50 independent food blogs say <em>Down Down Price</em> has better tea, the AI will recommend them instead.</p><ul><li><strong>Earn Third-Party Mentions:</strong> Ensure <em>Fresh Food People’s</em> tea ranges are reviewed and linked on independent food blogs, recipe sites, and news lifestyle segments. According to the foundational Princeton GEO framework, <strong>including authoritative source citations increases content visibility by 40%</strong> — the highest lift among all tested techniques.</li><li><strong>Monitor Public Forums:</strong> AI models scrape platforms like Reddit and ProductReview to analyze customer sentiment. Active, positive community discussions about your product range organically boost your AI recommendation score.</li></ul><h3>4. Create Targeted Conversational FAQs</h3><p>Users rarely type single keywords like “tea” into an LLM search tool. They ask complete questions. You must match this phrasing structure exactly.</p><ul><li><strong>Target Long-Tail Queries:</strong> Build dedicated FAQ sections on your tea category pages answering highly specific questions:</li></ul><p><em>“Which tea brands at Fresh Food People are plastic-free?”</em></p><p><em>“Where can I buy organic chamomile tea in Sydney?”</em></p><ul><li><strong>Provide the “Direct Answer First”:</strong> Structure your visible text so the very first sentence directly answers the question. The AI bot will extract that exact sentence for its chat response and cite <em>Fresh Food People</em> as the source</li></ul><h3>5. Dominate “Intent-Based” Filtering</h3><p>When a user asks an AI, <em>“Where can I get tea delivered in under 2 hours?”</em> or <em>“What is the cheapest green tea near me?”</em>, the AI filters the web by live logistics.</p><ul><li><strong>Expose Local and Delivery Data:</strong> Ensure your LocalBusiness schema for individual stores and your DeliveryActiondata are flawless. If the AI can read your source code and instantly verify that a specific <em>Fresh Food People</em> store has that tea on the shelf right now for immediate click-and-collect, it will rank it above a competitor with ambiguous stock data.</li></ul><h3>The AI-Optimized Category Page Blueprint</h3><p>Below is the updated, technically compliant HTML and JSON-LD baseline built to satisfy AI scrapers while serving human visitors.</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en-AU&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Premium Tea &amp; Herbal Infusions | Fresh Food People&lt;/title&gt;<br>    &lt;meta name=&quot;description&quot; content=&quot;Authoritative guide and e-commerce index for premium, ethically sourced loose leaf tea, organic matcha, and biodegradable tea bags in Australia.&quot;&gt;<br>    <br>    &lt;script type=&quot;application/ld+json&quot;&gt;<br>    {<br>      &quot;@context&quot;: &quot;https://schema.org&quot;,<br>      &quot;@graph&quot;: [<br>        {<br>          &quot;@type&quot;: &quot;CollectionPage&quot;,<br>          &quot;@id&quot;: &quot;http://freshfoodpeople.com/#collection&quot;,<br>          &quot;url&quot;: &quot;http://freshfoodpeople.com&quot;,<br>          &quot;name&quot;: &quot;Premium Tea &amp; Herbal Infusions | Fresh Food People&quot;,<br>          &quot;description&quot;: &quot;Authoritative guide and e-commerce index for premium, ethically sourced loose leaf tea, organic matcha, and biodegradable tea bags in Australia.&quot;<br>        },<br>        {<br>          &quot;@type&quot;: &quot;ItemList&quot;,<br>          &quot;@id&quot;: &quot;http://freshfoodpeople.com/#product-list&quot;,<br>          &quot;name&quot;: &quot;Fresh Food People Tea Collection&quot;,<br>          &quot;numberOfItems&quot;: 4,<br>          &quot;itemListElement&quot;: [<br>            {<br>              &quot;@type&quot;: &quot;ListItem&quot;,<br>              &quot;position&quot;: 1,<br>              &quot;item&quot;: {<br>                &quot;@type&quot;: &quot;Product&quot;,<br>                &quot;name&quot;: &quot;Organic Earl Grey Tea Bags&quot;,<br>                &quot;offers&quot;: {<br>                  &quot;@type&quot;: &quot;Offer&quot;,<br>                  &quot;price&quot;: &quot;8.50&quot;,<br>                  &quot;priceCurrency&quot;: &quot;AUD&quot;,<br>                  &quot;availability&quot;: &quot;https://schema.org/InStock&quot;<br>                }<br>              }<br>            },<br>            {<br>              &quot;@type&quot;: &quot;ListItem&quot;,<br>              &quot;position&quot;: 2,<br>              &quot;item&quot;: {<br>                &quot;@type&quot;: &quot;Product&quot;,<br>                &quot;name&quot;: &quot;Premium Matcha Powder&quot;,<br>                &quot;offers&quot;: {<br>                  &quot;@type&quot;: &quot;Offer&quot;,<br>                  &quot;price&quot;: &quot;24.00&quot;,<br>                  &quot;priceCurrency&quot;: &quot;AUD&quot;,<br>                  &quot;availability&quot;: &quot;https://schema.org/InStock&quot;<br>                }<br>              }<br>            },<br>            {<br>              &quot;@type&quot;: &quot;ListItem&quot;,<br>              &quot;position&quot;: 3,<br>              &quot;item&quot;: {<br>                &quot;@type&quot;: &quot;Product&quot;,<br>                &quot;name&quot;: &quot;Wild Chamomile &amp; Mint Loose Leaf&quot;,<br>                &quot;offers&quot;: {<br>                  &quot;@type&quot;: &quot;Offer&quot;,<br>                  &quot;price&quot;: &quot;9.20&quot;,<br>                  &quot;priceCurrency&quot;: &quot;AUD&quot;,<br>                  &quot;availability&quot;: &quot;https://schema.org/InStock&quot;<br>                }<br>              }<br>            },<br>            {<br>              &quot;@type&quot;: &quot;ListItem&quot;,<br>              &quot;position&quot;: 4,<br>              &quot;item&quot;: {<br>                &quot;@type&quot;: &quot;Product&quot;,<br>                &quot;name&quot;: &quot;Australian Daintree Black Loose Leaf&quot;,<br>                &quot;offers&quot;: {<br>                  &quot;@type&quot;: &quot;Offer&quot;,<br>                  &quot;price&quot;: &quot;11.00&quot;,<br>                  &quot;priceCurrency&quot;: &quot;AUD&quot;,<br>                  &quot;availability&quot;: &quot;https://schema.org/InStock&quot;<br>                }<br>              }<br>            }<br>          ]<br>        },<br>        {<br>          &quot;@type&quot;: &quot;FAQPage&quot;,<br>          &quot;@id&quot;: &quot;http://freshfoodpeople.com/#faq&quot;,<br>          &quot;mainEntity&quot;: [<br>            {<br>              &quot;@type&quot;: &quot;Question&quot;,<br>              &quot;name&quot;: &quot;Which tea varieties at Fresh Food People are completely plastic-free?&quot;,<br>              &quot;acceptedAnswer&quot;: {<br>                &quot;@type&quot;: &quot;Answer&quot;,<br>                &quot;text&quot;: &quot;All our house-branded teas and curated partner collections use 100% plant-based, biodegradable cornstarch pyramid tea bags. They are entirely plastic-free, unbleached, and compostable in domestic green bins.&quot;<br>              }<br>            },<br>            {<br>              &quot;@type&quot;: &quot;Question&quot;,<br>              &quot;name&quot;: &quot;What is the difference between loose-leaf tea and standard tea bags?&quot;,<br>              &quot;acceptedAnswer&quot;: {<br>                &quot;@type&quot;: &quot;Answer&quot;,<br>                &quot;text&quot;: &quot;Loose-leaf tea consists of whole or large broken tea leaves retaining essential oils and complex profiles. Standard supermarket tea bags often contain fannings or dust, resulting in faster bitter tannin release.&quot;<br>              }<br>            }<br>          ]<br>        }<br>      ]<br>    }<br>    &lt;/script&gt;<br>    <br>    &lt;style&gt;<br>        body { font-family: Arial, sans-serif; line-height: 1.6; max-width: 1000px; margin: 0 auto; padding: 20px; color: #333; }<br>        .breadcrumbs { font-size: 0.9em; color: #666; margin-bottom: 10px; }<br>        h1 { color: #1e4620; border-bottom: 2px solid #1e4620; padding-bottom: 10px; }<br>        h2 { color: #2e6930; margin-top: 30px; }<br>        table { width: 100%; border-collapse: collapse; margin-top: 15px; margin-bottom: 30px; }<br>        th, td { border: 1px solid #ddd; padding: 12px; text-align: left; }<br>        th { background-color: #f4f4f4; color: #1e4620; }<br>        .faq-item { margin-bottom: 20px; background: #f9f9f9; padding: 15px; border-left: 4px solid #2e6930; }<br>        .faq-question { font-weight: bold; color: #1e4620; margin-bottom: 5px; }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br><br>    &lt;div class=&quot;breadcrumbs&quot;&gt;Home &gt; Pantry &gt; Beverages &gt; Tea &amp; Herbal Infusions&lt;/div&gt;<br><br>    &lt;h1&gt;Premium Tea &amp; Herbal Infusions&lt;/h1&gt;<br>    &lt;p&gt;Welcome to Australia&#39;s dedicated home of ethically sourced, premium loose-leaf and pyramid tea bags. At Fresh Food People, we curate our tea collection based on leaf grade, origin verification, and sustainable farming practices. From high-caffeine organic black teas to soothing, single-origin herbal infusions, every batch is selected to ensure peak flavor-rich freshness and maximum antioxidant retention.&lt;/p&gt;<br><br>    &lt;h2&gt;Current Tea Range &amp; Specifications&lt;/h2&gt;<br>    &lt;table&gt;<br>        &lt;thead&gt;<br>            &lt;tr&gt;<br>                &lt;th&gt;Product Name&lt;/th&gt;<br>                &lt;th&gt;Format&lt;/th&gt;<br>                &lt;th&gt;Origin&lt;/th&gt;<br>                &lt;th&gt;Caffeine Content&lt;/th&gt;<br>                &lt;th&gt;Primary Health Benefit&lt;/th&gt;<br>                &lt;th&gt;Price (AUD)&lt;/th&gt;<br>                &lt;th&gt;Stock Status&lt;/th&gt;<br>            &lt;/tr&gt;<br>        &lt;/thead&gt;<br>        &lt;tbody&gt;<br>            &lt;tr&gt;<br>                &lt;td&gt;Organic Earl Grey&lt;/td&gt;<br>                &lt;td&gt;Biodegradable Bags&lt;/td&gt;<br>                &lt;td&gt;Assam, India&lt;/td&gt;<br>                &lt;td&gt;Medium (45mg)&lt;/td&gt;<br>                &lt;td&gt;Alertness &amp; Focus&lt;/td&gt;<br>                &lt;td&gt;$8.50&lt;/td&gt;<br>                &lt;td&gt;In Stock&lt;/td&gt;<br>            &lt;/tr&gt;<br>            &lt;tr&gt;<br>                &lt;td&gt;Premium Matcha Powder&lt;/td&gt;<br>                &lt;td&gt;Stone-ground Powder&lt;/td&gt;<br>                &lt;td&gt;Uji, Japan&lt;/td&gt;<br>                &lt;td&gt;High (70mg)&lt;/td&gt;<br>                &lt;td&gt;Metabolic Boost&lt;/td&gt;<br>                &lt;td&gt;$24.00&lt;/td&gt;<br>                &lt;td&gt;In Stock&lt;/td&gt;<br>            &lt;/tr&gt;<br>            &lt;tr&gt;<br>                &lt;td&gt;Wild Chamomile &amp; Mint&lt;/td&gt;<br>                &lt;td&gt;Loose Leaf&lt;/td&gt;<br>                &lt;td&gt;Nile Valley, Egypt&lt;/td&gt;<br>                &lt;td&gt;Caffeine-Free&lt;/td&gt;<br>                &lt;td&gt;Sleep &amp; Relaxation&lt;/td&gt;<br>                &lt;td&gt;$9.20&lt;/td&gt;<br>                &lt;td&gt;In Stock&lt;/td&gt;<br>            &lt;/tr&gt;<br>            &lt;tr&gt;<br>                &lt;td&gt;Australian Daintree Black&lt;/td&gt;<br>                &lt;td&gt;Loose Leaf&lt;/td&gt;<br>                &lt;td&gt;Queensland, QLD&lt;/td&gt;<br>                &lt;td&gt;High (50mg)&lt;/td&gt;<br>                &lt;td&gt;Heart Health&lt;/td&gt;<br>                &lt;td&gt;$11.00&lt;/td&gt;<br>                &lt;td&gt;In Stock&lt;/td&gt;<br>            &lt;/tr&gt;<br>        &lt;/tbody&gt;<br>    &lt;/table&gt;<br><br>    &lt;h2&gt;Frequently Asked Questions About Our Tea Collection&lt;/h2&gt;<br>    &lt;div class=&quot;faq-item&quot;&gt;<br>        &lt;div class=&quot;faq-question&quot;&gt;Q: Which tea varieties at Fresh Food People are completely plastic-free?&lt;/div&gt;<br>        &lt;div class=&quot;faq-answer&quot;&gt;A: All our house-branded teas and curated partner collections use 100% plant-based, biodegradable cornstarch pyramid tea bags. They are entirely plastic-free, unbleached, and compostable in domestic green bins, leaving zero synthetic microplastic residues in your brew.&lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;faq-item&quot;&gt;<br>        &lt;div class=&quot;faq-question&quot;&gt;Q: What is the difference between loose-leaf tea and standard tea bags?&lt;/div&gt;<br>        &lt;div class=&quot;faq-answer&quot;&gt;A: Loose-leaf tea consists of whole or large broken tea leaves (Orange Pekoe grade), which retain essential oils, complex flavor profiles, and natural antioxidants. Standard supermarket tea bags often contain &quot;fannings&quot; or &quot;dust,&quot; which release tannins faster, resulting in a more bitter taste and fewer health benefits.&lt;/div&gt;<br>    &lt;/div&gt;<br>    &lt;div class=&quot;faq-item&quot;&gt;<br>        &lt;div class=&quot;faq-question&quot;&gt;Q: How should I store premium loose-leaf tea to keep it fresh?&lt;/div&gt;<br>        &lt;div class=&quot;faq-answer&quot;&gt;A: To maintain volatile flavor compounds, store your tea in an airtight, opaque container away from direct sunlight, moisture, and strong kitchen odors. Under these conditions, whole-leaf green and herbal teas remain at peak freshness for up to 12 months, while black teas can last up to 24 months.&lt;/div&gt;<br>    &lt;/div&gt;<br><br>&lt;/body&gt;<br>&lt;/html&gt;</pre><p><strong>Why this Specific Layout Dominates AI Engines</strong></p><ol><li><strong>The Comparison Table is AI Bait:</strong> When an AI search engine wants to answer a query like <em>“Compare caffeine levels in different teas,”</em> it scans for structured data arrays. Because your layout contains a clear Markdown data table with explicit numeric values (45mg, 70mg), the AI scraper will pull this exact section, reformat it for the chat window, and attribute the source link back to freshfoodpeople.com.</li><li><strong>Defeating “Fluff” with High Information Density:</strong> Large grocery competitors frequently rely on visual grids with thin textual substance. By loading your copy with technical details like leaf grades (<em>Orange Pekoe</em>), manufacturing types (<em>stone-ground</em>), and specific geographical origins (<em>Assam</em>, <em>Uji</em>, <em>Nile Valley</em>), the AI identifies your page as an expert text layer worth referencing.</li><li><strong>Conversational Long-Tail Target Blocks:</strong> Users rarely type “tea buy” into an LLM search tool. They ask complete questions like <em>“where can I get plastic free compostable tea bags in Australia?”</em> The FAQ section matches that phrasing structure exactly, allowing the AI’s semantic routing to confidently strip out your response block as a direct quote.</li></ol><h3>The Technical Core: JSON-LD</h3><p><strong>JSON-LD</strong> (JavaScript Object Notation for Linked Data) provides search engine and AI crawlers explicit clues about the meaning of your website content. Instead of forcing an AI to infer context by scanning blocks of text, JSON-LD passes structured mappings directly to the model.</p><h3><strong>Why AI Crawlers Prefer JSON-LD</strong></h3><ul><li><strong>It is completely separate from your design:</strong> JSON-LD sits quietly inside a &lt;script&gt; tag in your HTML. It does not affect how your website looks to human visitors.</li><li><strong>It prevents AI “hallucinations”:</strong> By explicitly defining names, dates, prices, and relationships, you eliminate ambiguity.</li><li><strong>It maps connections:</strong> It links entities together, helping AI models build a “knowledge graph” of your brand, products, or articles.</li></ul><p>If you look at above example html, withinJSON-LD we see three different anchors or schema — t<strong>hree primary schema types</strong>, neatly bundled together inside a single @graph array script (just like the HTML template provided above).</p><p>The three schema types you need to define are:</p><p><strong>1. CollectionPage (The Page Identity)</strong></p><ul><li><strong>What it does:</strong> It tells the AI crawler exactly what the purpose of the current URL is.</li><li><strong>Why you need it:</strong> It establishes that this page is a curated category index (a “collection”) rather than a single blog post or a single product checkout page.</li></ul><p><strong>2. ItemList (The Product Index)</strong></p><ul><li><strong>What it does:</strong> It provides a structured list of the top products displayed on that category page.</li><li><strong>Why you need it:</strong> It feeds the AI bot a clean, machine-readable inventory list containing names, prices, and availability. The AI uses this list to immediately answer comparison queries (e.g., <em>“What is the cheapest tea at Fresh Food People?”</em>).</li></ul><p><strong>3. FAQPage (The Conversational Anchor)</strong></p><ul><li><strong>What it does:</strong> It defines the exact questions and answers listed at the bottom of the page.</li><li><strong>Why you need it:</strong> This is your primary tool for winning direct AI citations. When a user asks an LLM a long-tail question (e.g., <em>“Are supermarket tea bags plastic-free?”</em>), the crawler extracts this exact block to answer the user and links back to your site.</li></ul><h3><strong>Are there any schema list or user can define it as per need?</strong></h3><p>You cannot invent your own custom schema names as per your need. You must choose from an official, globally standardized list provided by <a href="http://schema.org/"><strong>Schema.org</strong></a></p><p>f you create your own custom terms (like @type: MyAwesomeTea), AI crawlers and search engine bots will not recognize them, and they will completely ignore the script.</p><p>However, you have total flexibility in <strong>how you mix, match, and combine</strong> these official schemas to fit your specific business needs.</p><h3><strong>Where to Find the Official Schema List</strong></h3><p>The universal dictionary is hosted entirely at <strong>Schema.org</strong></p><p>Every single recognized entity type — from a Product and LocalBusiness to a Recipe, Event, or MedicalCondition — is listed there alphabetically. Major tech companies (Google, Microsoft, OpenAI, Anthropic) use this exact list as their training baseline for data parsing.</p><h3><strong>How You “Define schema as Per Need” (The Flexibility)</strong></h3><p>While you cannot change the vocabulary, you have complete control over <strong>which properties you choose to include</strong> and <strong>how you layer them</strong> using a nested @graph structure.</p><p>For example, if you run a unique business like a <strong>Grocery Store that also runs a Cooking School</strong>, you can define your page by combining official schemas:</p><ul><li>You use FoodEstablishment to define the store.</li><li>You nest an EducationEvent inside it to define the cooking classes.</li><li>You add a Product array for the ingredients you sell.</li></ul><p>As long as every piece of code uses an official term from the Schema.org list, the AI will understand your exact setup.</p><p><strong>The 3 Levels of Schema Properties</strong></p><p>When you look at an official schema list for an item (like Product), you will see three categories of data fields:</p><ul><li><strong>Required Fields:</strong> The bare minimum needed for the code to be valid (e.g., product name).</li><li><strong>Recommended Fields:</strong> High-value data points that search engines highly reward (e.g., price, availability, review).</li></ul><p>• • <strong>Optional Fields:</strong> Highly specific technical details you can add if it suits your business (e.g., color, height, material, mpn)</p><h3><strong>But wait JSON-LD is loaded as a script? so does it mean my page performance is going to be impacted?</strong></h3><p>The script sits inside a &lt;script type=”application/ld+json”&gt; tag. The browser’s layout engine completely ignores it when painting pixels on the screen.</p><p>Another common concern is that embedding bulky JSON-LD blocks will swell the page’s token count and exhaust an AI agent’s crawling budget. However, AI engines process web pages in two distinct phases:</p><ol><li><strong>The Parser Phase (Data Stripping):</strong> When an AI bot visits a URL, a preprocessing script strips away heavy visual elements, tracking scripts, and CSS styling.</li><li><strong>The Extraction Phase (LLM Intake):</strong> The parser compresses raw elements, passing clean text and the structured JSON-LD into the context window. Because JSON-LD is already optimized, it <strong>conserves token usage</strong> by keeping the LLM from processing thousands of words of repetitive website code.</li></ol><h3>Where to Inject JSON-LD?</h3><p>The industry standard is to inject the code block into the &lt;head&gt; tag. This ensures that the crawler registers the key contextual facts immediately upon reading the first few lines of the file. However, if your database generates content dynamically (like changing stock status at runtime), placing it at the bottom of the &lt;body&gt; is perfectly valid.</p><h3>🚀 Scaling GEO to an Enterprise Footprint</h3><p>Manually coding JSON-LD for an enterprise catalog spanning tens of thousands of SKUs is an engineering bottleneck. Moving the workload to the Edge CDN layer automates semantic rendering at scale without modifying backend application infrastructure.</p><p>Using a solution like <strong>Akamai EdgeWorkers or Akamai Functions</strong>, serverless functions execute at the edge node closest to the client. The CDN intercepts the client request, pulls the lightweight product data array from the source origin, generates the compliant JSON-LD script, and injects it dynamically before serving the page. You can also use a inference server running on edge to read the content of page and automatically generate the JSON-LD and add it to the page on the fly.</p><h3>Edge Dynamic Enrichment Architecture</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gj_KhbA-HC1v9gBFWThecw.jpeg" /></figure><h3>What about llms.txt?</h3><p>An llms.txt file is a proposed, machine-readable Markdown file hosted in a website&#39;s root directory that acts as a curated directory map for AI agents.</p><p>Despite initial hype suggesting llms.txt acts as an &quot;SEO manual for AI,&quot; <strong>empirical evidence confirms major AI crawlers do not actively prioritize or use it.</strong></p><p>Google Search Relations lead John Mueller explicitly clarified that Google Search completely ignores it as a ranking or crawling driver. Controlled server log audits in mid-2026 show that bots like GPTBot, ClaudeBot, and Google-Extended rarely request llms.txt. Instead, they depend heavily on existing technical guardrails like standard robots.txt directives and raw structural HTML data to parse your site. Don&#39;t rely on hype—stick to structured content data and clean schema protocols.</p><h3>Closing Note</h3><p>AI world is changing at very fast pace and every knowlege is as of current date, while you should get knowledge from blog, it is strongly advised that you check the date of publishing and if it is more than 3 months old than it’s better to check if content is outdated.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c60266e7a2f3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Economics of Generative AI: Balancing Innovation with Infrastructure Costs]]></title>
            <link>https://deepakjd2004.medium.com/the-economics-of-generative-ai-balancing-innovation-with-infrastructure-costs-89dea02e0ff6?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/89dea02e0ff6</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[llm]]></category>
            <category><![CDATA[ai-architecture]]></category>
            <category><![CDATA[ai-cost-optimization]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Tue, 28 Apr 2026 09:07:36 GMT</pubDate>
            <atom:updated>2026-04-28T09:07:36.370Z</atom:updated>
            <content:encoded><![CDATA[<p>Generative AI is reshaping the global economy. According to <a href="https://www.mckinsey.com/capabilities/mckinsey-digital/our-insights/the-economic-potential-of-generative-ai-the-next-productivity-frontier">McKinsey &amp; Company</a>, generative AI has the potential to add the equivalent of $2.6 trillion to $4.4 trillion annually across global industries. The business value is undeniable, from automating customer support to writing code and analyzing massive legal contracts.</p><p>However, as more organizations move from prototypes to production-grade applications, the conversation is shifting from “What can AI do?” to “At what cost?”</p><p>Understanding <strong>AI Economics</strong> is no longer just an operational detail; it is a strategic imperative. Whether you are an executive responsible for calculating the Return on Investment (ROI) or a software architect designing the infrastructure, you need to know exactly how AI applications hit the bottom line.</p><h3>1. The Anatomy of AI Costs</h3><p>To control costs, you first have to understand what you are paying for. AI pricing models generally break down into a few core categories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NHP6AONV4IZhUn-yfdpw1Q.jpeg" /><figcaption>Understanding cost of AI</figcaption></figure><ul><li><strong>Input Tokens:</strong> The text, code, or data you send to the model in your prompt. This includes your system instructions, conversation history, and any documents you upload. Note that both system and user prompt count towards input token</li></ul><p>Because standard LLM APIs are stateless, the model retains no memory between individual requests. To keep a conversation going or enforce rules consistently, you must resend the system prompt and the recent chat history <em>every single time</em> the user sends a new message.</p><p>This means if you have a bloated system prompt that is 1,000 tokens long:</p><ul><li><strong>Turn 1:</strong> You pay for the 1,000-token system prompt + the user’s prompt.</li><li><strong>Turn 2:</strong> You pay for the 1,000-token system prompt + Turn 1’s history + the new user prompt.</li><li><strong>Turn 3:</strong> You pay for the 1,000-token system prompt + Turn 1 &amp; 2 history + the new user prompt.</li><li><strong>Output Tokens:</strong> The text or data the model generates in response. Generating text requires significantly more computational power than reading it. Consequently, output tokens are typically 3x to 5x more expensive than input tokens.</li><li><strong>Cached Input Tokens:</strong> Many modern providers (like OpenAI and Anthropic) offer steep discounts (often 50% to 90%) when you reuse the same long context across multiple requests within a short timeframe.</li><li><strong>Inference Compute:</strong> If you are hosting your own models, you pay for the underlying hardware (e.g., renting Nvidia H100 or A100 GPUs by the hour) rather than a per-token fee.</li></ul><h3>Frontier &amp; Mid-Tier Model Pricing Comparison</h3><p>Pricing varies wildly depending on the “intelligence tier” of the model. Here is a snapshot of typical costs per 1 Million (1M) tokens as of early 2026:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RHI6BIH5LStns7tq0yFuGg.jpeg" /><figcaption>Indicative cost per model</figcaption></figure><p>Please note that costs are just indicative and you should always check individual provider for accurate cost.</p><h3>2. Factors Influencing AI Costs</h3><p>Cost is rarely static. Your monthly AI bill will fluctuate based on several architectural and user-driven factors:</p><ul><li><strong>Context Window Utilization:</strong> Feeding a 100-page PDF into a model for every single user question will drain your budget rapidly. Larger contexts mean higher input token counts.</li><li><strong>Output Verbosity:</strong> Because output tokens are the most expensive, an AI assistant programmed to give long, chatty responses will cost significantly more than one trained to give concise, structured JSON outputs.</li><li><strong>Traffic Patterns:</strong> Consistent, predictable traffic is cheaper to serve. Highly volatile traffic can result in rate-limit errors or force you into expensive on-demand provisioning.</li><li><strong>Model Selection:</strong> The spread between a budget model and a premium model can exceed 1,000x in cost. Using a premium model for a trivial task is the most common source of budget bleed.</li></ul><p>Their are various website that compare LLM on various parameters and show them on leaderboards. I particularly liked <a href="https://artificialanalysis.ai/models">https://artificialanalysis.ai/models</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zeU-yFqWPiAUccswHEjfTA.jpeg" /><figcaption>Model comparison from <a href="https://artificialanalysis.ai/models">https://artificialanalysis.ai/models</a></figcaption></figure><p>Other popular site for comparison :-</p><ul><li><a href="https://llm-stats.com/">AI Leaderboard 2026: Compare &amp; Rank 300+ Top AI Models by Intelligence, Speed &amp; Price</a></li><li><a href="https://livebench.ai/#/?highunseenbias=true">LiveBench</a></li></ul><p>Please note that no two leaderboard website has same criteria for evaluation and you would have to do some analysis to figure out what is best suited LLM for your use case.</p><h3>3. Build vs. Buy: Self-Hosting vs. Cloud APIs</h3><p>One of the largest architectural decisions is whether to consume Large Language Models (LLMs) via an API or host open-weight models (like Llama 4 or Mistral) on your own infrastructure.</p><h3>Cloud Provider APIs (OpenAI, Google, Anthropic, AWS, Azure etc. )</h3><ul><li><strong>Pros:</strong> Zero infrastructure maintenance, pay-only-for-what-you-use, instant access to the smartest frontier models, and highly mature SDKs and tooling.</li><li><strong>Cons:</strong> Variable OPEX (operational expenditure) that scales linearly with usage, strict rate limits, and potential data privacy concerns for highly regulated industries.</li><li><strong>Who should use it:</strong> Startups, enterprises prioritizing speed-to-market, and applications that require absolute peak reasoning capabilities.</li></ul><h3>Self-Hosted / Open-Source Models</h3><ul><li><strong>Pros:</strong> Flat, predictable infrastructure costs regardless of token volume (you pay for the server uptime, not the token count), complete data sovereignty, and the ability to heavily fine-tune the model.</li><li><strong>Cons:</strong> Requires specialized MLOps/DevOps talent(more so in case you want to further train or fine tune the model), high idle costs if the hardware is not utilized 24/7, and open-source models may lag behind proprietary frontier models in complex reasoning and other advanced tasks.</li><li><strong>Who should use it:</strong> Organizations with massive, predictable token volumes (where flat hardware costs undercut per-token API fees), highly regulated industries (defense, healthcare), and teams needing low-level model control.</li></ul><h3>4. Architectural Design Patterns for Cost Optimization</h3><p>Architects play a massive role in AI economics. Implementing the right infrastructure patterns can cut costs by 50% to 90% without sacrificing user experience. We will explore three key patterns, providing architectural diagrams to visualize the flow and the corresponding savings.</p><h3>Pattern 1: Model Routing</h3><p>Not every query requires a supercomputer. A monolithic architecture (sending every request to a single premium model) is the fastest way to blow AI budget.</p><p>The Model Routing pattern places a lightweight classifier or router (which can itself be a very small AI model) in front of your core infrastructure to assess the semantic complexity of a user’s request.</p><ul><li><strong>How it works:</strong> A user asks, “What are your business hours?” The router sends this to Gemini 2.5 Flash-Lite or open (costing fractions of a cent) or open source LLM. Another user asks, “Analyze this 40-page financial disclosure and extract the liability clauses.” The router detects complexity and sends it to commercial and mature LLM like Claude 4.5 opus, GPT-5 etc..</li></ul><h4>Architectural Diagram: Model Routing Optimization</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6Gz23Uw5wI5-3KX4stMbWg.jpeg" /><figcaption><em>(Diagram 1: Model Routing)</em></figcaption></figure><p><strong>ROI Impact:</strong> This pattern visually demonstrates how an efficient classifier preserves your budget. As illustrated in the diagram, you capitalize on the “80/20 Rule” of AI: 80% of tasks can be handled by cheap, high-speed models, ensuring your expensive, high-reasoning models (and your budget) are reserved for the 20% that actually need them.</p><h3>Pattern 2: Semantic Caching</h3><p>Traditional caching is too rigid for the dynamic nature of AI; it requires an exact keyword match. If User A asks “How do I reset my password?” and User B asks “Forgot my password, help me reset it,” a traditional cache fails, and both requests hit the LLM.</p><p>Semantic Caching uses vector databases (like Redis or Pinecone) to store previous responses. The cache doesn’t look for matching text; it looks for matching <em>intent</em> by converting the query into a multi-dimensional vector and performing a similarity calculation.</p><ul><li><strong>How it works:</strong> The diagram below shows the flow: The user’s input is converted into an embedding (a vector). This vector is compared against thousands of pre-cached semantic vectors in a database. If the cosine similarity (mathematical closeness) is high enough, the cached response is served instantly, bypassing the LLM entirely. If no match is found, the query hits the LLM, the output is generated, and that new response is then added to the semantic cache for future use.</li></ul><h4>Architectural Diagram: Semantic Caching Mechanism</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcZu2I3euacUj0Bz_zl27g.jpeg" /><figcaption>Semantic Caching — Flow Diagram</figcaption></figure><p><strong>ROI Impact:</strong> This pattern provides perhaps the highest possible ROI. When a semantic match is found, your output token cost is exactly $0.00, your input token cost is negligible, and latency drops from seconds to milliseconds. Organizations like <a href="https://redis.io/blog/semantic-caching-and-routing-two-powerful-patterns-for-vector-classification/">Redis highlight semantic caching</a> as a foundational pattern for building efficient AI gateways.</p><h3>Pattern 3: Asynchronous Batch Processing</h3><p>If a task does not require real-time user interaction, never pay full price. The synchronous “Request-Response” model is convenient for chat, but highly inefficient for bulk data processing.</p><p>The Asynchronous Batch Processing pattern involves grouping thousands of requests together into a single file or payload and uploading them to a dedicated “Batch API” endpoint.</p><ul><li><strong>How it works:</strong> As shown in the diagram below, a “Scheduler” manages the queue. The grouped requests (Inputs 1 to 1000+) are batched into one large job. This job is sent to the LLM’s Batch API (e.g., <a href="https://platform.openai.com/docs/guides/batch">OpenAI Batch API</a>). The model provider processes these requests during off-peak hours when their computing infrastructure would otherwise be idle. You receive a notification when the batch is complete and can download the results file.</li></ul><h4>Architectural Diagram: Asynchronous Batch Optimization</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iIphFk5jihOlr6dR_mnVHg.jpeg" /><figcaption><em>(Diagram 3: Asynchronous Batch Processing)</em></figcaption></figure><p><strong>ROI Impact:</strong> The trade-off is time: batches usually take 2–24 hours to complete. However, in exchange for your patience, providers offer a flat, significant <strong>discount (often 50%) on all token costs</strong>. This pattern is the definitive choice for non-time-sensitive workflows like nightly data extraction, document translation, long-form content generation, and bulk summarization.</p><p>You can read about batch processing here —</p><p><a href="https://platform.claude.com/docs/en/build-with-claude/batch-processing">https://platform.claude.com/docs/en/build-with-claude/batch-processing</a></p><h3>5. Agentic AI fundamentally changes the math of AI economics</h3><p>If traditional generative AI is a standard Vending Machine (you put a coin in, you get a candy bar out), Agentic AI is an autonomous factory. Instead of a 1:1 relationship between a user prompt and an AI response, an AI agent operates in a continuous loop of reasoning, planning, tool execution, and reflection to achieve a broad goal.</p><p>While the business value of Agentic AI is massive — it can automate complex, multi-step workflows previously requiring human intervention — it acts as a massive multiplier on your token consumption and infrastructure costs.</p><p>Let’s understand this with an example where a retail company is using AI agents to monitor its competitor site.</p><p>When a user asks an agent to “Research our top three competitors and summarize their pricing changes over the last year,” the agent does not just make one API call. It executes a workflow that looks like this:</p><ol><li><strong>Planning (API Call 1):</strong> The agent breaks the task into sub-tasks (search web, read pages, extract pricing, format report).</li><li><strong>Tool Use &amp; Execution (API Calls 2–10):</strong> The agent searches the web. It then reads the HTML of the websites.</li><li><strong>Reflection &amp; Correction (API Calls 11–13):</strong> If a website blocks the agent, the agent reflects, rewrites its search query, and tries a different source.</li><li><strong>Synthesis (API Call 14):</strong> The agent compiles the extracted data into the final report.</li></ol><p><strong>The Cost Impact:</strong> A single user request that might have cost $0.02 in a simple chat interface can easily cost $0.50 to $2.00 in an agentic workflow due to the “ReAct” (Reason + Act) loops.</p><p>If you are deploying autonomous agents, you need to watch these three specific budget-drainers:</p><ul><li><strong>Context Bloat from Tool Outputs:</strong> When an agent uses a tool (like running a SQL query or scraping a webpage), the raw output of that tool is fed <em>back</em> into the agent’s input context so it can read it. Scraping a single dense webpage can inject 10,000+ input tokens into the prompt loop instantly.</li><li><strong>The “Premium Model” Cost:</strong> Cheap, high-speed models (like Gemini 2.5 Flash) are excellent at straightforward text generation, but they often struggle with complex multi-step reasoning and precise tool calling. To build reliable agents that don’t get stuck in hallucination loops, developers are often forced to use the most expensive, frontier models (like GPT-5.4 or Claude Opus) for the orchestration layer.</li><li><strong>Runaway Infinite Loops:</strong> If an agent encounters an error (e.g., an API it is trying to call is down), an unoptimized agent will repeatedly try to call it, fail, reflect, and try again. Each loop consumes tokens until the agent hits a hard timeout.</li></ul><h3>Design Patterns for Controlling Agentic Costs</h3><p>Because of these compounding costs, throwing a single premium LLM at an agentic task is architectural malpractice. Here are the design patterns used to optimize Agentic AI:</p><h3>Pattern A: Hierarchical Agent Routing (The “Manager-Worker” Model)</h3><p>Instead of using a premium model for everything, split the agent into a hierarchy.</p><ul><li><strong>The Manager (Premium Model):</strong> Uses a high-reasoning model (e.g., Claude 4.6 Opus) strictly to plan the workflow and delegate tasks.</li><li><strong>The Workers (Value Models):</strong> Uses cheap, fast models to execute the sub-tasks (e.g., extracting text from the HTML, formatting a date).</li><li><strong>ROI Impact:</strong> You isolate the expensive token usage to the planning phase, dropping execution costs.</li></ul><h3>Pattern B: Tool Payload Truncation</h3><p>Never let an agent ingest raw data blindly. If an agent searches the web, put a middleware function between the web scraper and the agent. The middleware strips out HTML tags, navigation bars, and ads, and uses a cheap model to summarize the page <em>before</em> feeding the data back into the main agent’s context window.</p><h3>Pattern C: Strict Max_Iterations Budgets</h3><p>Every agentic workflow must have a hardcoded iteration limit or a “token budget” per session. If the agent cannot solve the problem in 5 or 10 steps, it should gracefully fail and hand the task over to a human, rather than burning a hole in your cloud budget trying to brute-force a solution.</p><h3>6. Best Practices for Controlling Spend</h3><p>To wrap up, here are actionable rules for decision-makers to enforce across their engineering teams:</p><ul><li><strong>Enforce Output Constraints:</strong> Set strict max_tokens limits on API calls to prevent runaway generation loops or overly verbose responses.</li><li><strong>Implement an AI Gateway:</strong> Centralize all your AI traffic through an AI Gateway. This allows you to track spend by department, implement global rate limits, and cut off access automatically if a budget threshold is breached.</li><li><strong>Optimize the Prompt (Not Just the Code):</strong> Every word in a system prompt costs money every time it is invoked. Treat prompt engineering like code golf — make instructions as concise and dense as possible.</li><li><strong>Leverage Context Caching:</strong> If your application relies on a massive static document (like a corporate policy handbook), utilize provider-level context caching so you only pay the heavy input fee once, and pay pennies for subsequent queries.</li></ul><p>Adding AI to your product roadmap is one of the highest-leverage moves a company can make today. By understanding AI economics, respecting the anatomy of a token, and implementing these visual architectural patterns early, you ensure that the immense value generated by these models translates directly into sustainable, scalable profit.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89dea02e0ff6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Local Script to Cloud-Hosted Agent: The Journey of Building a Web Performance AI]]></title>
            <link>https://deepakjd2004.medium.com/from-local-script-to-cloud-hosted-agent-the-journey-of-building-a-web-performance-ai-160e6e1e5544?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/160e6e1e5544</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[agentic-ai]]></category>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[ai-agent-development]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Sat, 25 Apr 2026 10:06:21 GMT</pubDate>
            <atom:updated>2026-04-25T10:07:53.055Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUKUl_N4xd_AsISRsD2fpQ.jpeg" /><figcaption>Web Performance AI Agent</figcaption></figure><p>Building a custom AI agent sounds glamorous — until you actually have to connect a Large Language Model (LLM) to your orchestrator and watch them try to talk to each other.</p><p>Over the course of an intense engineering sprint, I took a local Web Performance AI Agent and scaled it to a self-hosted cloud environment on Akamai Connected Cloud using vLLM on a 20GB RTX 4000 Ada GPU. I started with questions about weight quantization and ended up diving deep into the trenches of system administration, VRAM starvation, and LLM psychology.</p><p>Before going to issues faced, it is important to spend some time to understand what was the goal of the agent? Why I even started working on it.</p><p>Let me first start with a simple question — what is a Web Performance AI Agent?</p><p><strong>Under the Hood: How the Web Performance Agent Works</strong></p><p>When you type /audit www.example.com or ask &quot;What are the top recommendations?&quot;, it feels like you are chatting with a human performance engineer. But behind the scenes, there is a complex, multi-component architecture working in perfect harmony.</p><p>At its core, an <strong>AI Agent</strong> is not just a chatbot. It is a Large Language Model (LLM) that has been given access to external tools, memory, and a logic loop, allowing it to take actions and interact with the real world.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dUKUl_N4xd_AsISRsD2fpQ.jpeg" /></figure><p>Here is a detailed breakdown of the five core components that make up our solution:</p><h3>Component 1: The “Brain” (The LLM &amp; vLLM Server)</h3><p>The Brain is responsible for reading the user’s intent, deciding what needs to be done, and structuring the data.</p><ul><li><strong>The Model (Qwen/Llama):</strong> I am using open-weights models (like Alibaba’s Qwen 3.5 9B) hosted on cloud infrastructure. Instead of just generating text, this model has been fine-tuned for <strong>Agentic Reasoning</strong>. It understands JSON schemas and knows how to ask external scripts for help when it doesn’t know an answer.</li><li><strong>The Inference Engine (vLLM):</strong> This is the high-performance server wrapping model. It handles the API routing (mimicking OpenAI’s SDK endpoints) and manages the GPU VRAM. It ensures the LLM can process thousands of tokens of context in milliseconds using optimized KV Caching.</li><li><strong>AWQ Quantization:</strong> To fit massive intelligence onto a single 20GB RTX 4000 Ada GPU, the model’s weights are compressed into 4-bit precision (AWQ). This reduces the model footprint from 18GB to 6GB, leaving plenty of room for massive website audit data.</li></ul><h3>Component 2: The Orchestrator (The Python Controller)</h3><p>If the LLM is the brain, the WebPerformanceAIAgent Python class is the central nervous system. The LLM cannot &quot;do&quot; anything on its own; it relies entirely on the Orchestrator to pass messages back and forth.</p><ul><li><strong>The Memory Manager:</strong> The orchestrator maintains a running messages list. Every user prompt, LLM response, and tool output is appended here. If the history gets too long, the orchestrator prunes older messages to prevent exceeding the LLM&#39;s context window.</li><li><strong>The System Prompt:</strong> This is the agent’s absolute law. It explicitly dictates its persona (“You are a strict, data-driven web performance expert”) and establishes unbreakable rules (e.g., “NEVER guess, you MUST immediately call the get_audit_data tool&quot;).</li><li><strong>The Logic Loop (ReAct):</strong> When a user asks a question, the Orchestrator initiates a MAX_STEPS loop. It asks the LLM what to do. If the LLM requests a tool, the Orchestrator runs the tool, appends the result to the chat history, and loops back to the LLM. This repeats until the LLM has enough data to write a final text answer to the user.</li></ul><h3>Component 3: The Auditor Engine (The Muscle)</h3><p>The LLM doesn’t actually know how fast a website is — it needs the WebPerformanceAuditor engine to do the heavy lifting. When the user types the /audit command, the Orchestrator pauses the AI and fires up the Auditor.</p><ul><li><strong>Headless Browser:</strong> The engine spins up a hidden Chrome instance (via Selenium/Playwright) to visit the target website, download the assets, and measure Render Blocking scripts, image weights, and font formats.</li><li><strong>API Integrations:</strong> It reaches out to the Chrome User Experience Report (CrUX) API to fetch real-world Core Web Vitals (LCP, INP, CLS) for the domain.</li><li><strong>Network Analysis:</strong> It inspects DNS configurations, CDN routing, HTTP/3 protocols, and IPv6 support.</li><li>All this data is compiled into a massive, highly structured JSON dictionary and saved in the Orchestrator’s local memory.</li></ul><h3>Component 4: The Tool Suite (The Agent’s Hands)</h3><p>To bridge the gap between the massive Auditor JSON and the LLM’s limited context window, the Orchestrator defines specific “Tools” (functions) the LLM can call.</p><ul><li><strong>Data Extraction (</strong><strong>get_audit_data):</strong> Instead of dumping the entire 5,000-line JSON audit into the LLM&#39;s prompt at once (which would crash the GPU), the LLM uses this tool to surgically request specific categories (e.g., [&quot;heavy_resources&quot;, &quot;http_protocol&quot;]). The Orchestrator parses the LLM&#39;s request, slices out only that specific data, and hands it back. I built heavy safeguards here to catch &quot;hallucinated&quot; requests if the LLM asks for invalid data types.</li><li><strong>Action Execution (</strong><strong>generate_presentation_report):</strong> Agents don&#39;t just read data; they take action. Using the python-pptxlibrary, this tool takes the LLM&#39;s synthesized recommendations and physically generates a downloadable PowerPoint deck, saved directly to the hard drive.</li></ul><h3>Component 5: The Infrastructure (The Cloud Environment)</h3><p>None of this works without a stable foundation.</p><ul><li><strong>Linux </strong><strong>systemd Daemon:</strong> Ensures the vLLM server runs silently in the background 24/7, surviving server reboots and automatically restarting if memory spikes cause a crash.</li><li><strong>VRAM Guardians:</strong> Strict flags in the startup command (--gpu-memory-utilization 0.88, --max-model-len 6144) act as traffic cops, ensuring the LLM never tries to use more memory than the physical GPU possesses, completely preventing CUDA Out of Memory crashes.</li></ul><p>My initial implementation was using local LM Studio(inference engine) with Qwen2.5 (llm model) on my mac and it worked fine but with lot of latency and hallucination(even after tightening up the implementation with strict prompt engineering)</p><p>Next natural step was to move the inference engine to cloud and possibly use better model.</p><p>Here is a comprehensive look back at the issues Ifaced, the solutions I engineered, and the hard-earned lessons I picked up along the way.</p><p>I used vllm as inference engine and installed it on Linode 20GB RTX 4000 Ada server.</p><h3>Phase 1: The Llama 3.1 8B Tool-Calling Trenches</h3><p>With the server running in linode at http://xx.xx.xx.xx:8000/v1, I pointed my local Python orchestrator.py to the cloud. That’s when the real battle began. I first used Llama 3.1 8B, an incredible generalist model, but it struggled heavily with strict agentic tasks.</p><p><strong>Issue 1: The 400 Bad Request (Tool Choice)</strong></p><ul><li><strong>Problem:</strong> Standard OpenAI SDK tool calls crashed with a 400 BadRequestError.</li><li><strong>Solution:</strong> Unlike OpenAI, open-source models need explicit instructions on how to parse tools. I had to update vLLM startup command to include --enable-auto-tool-choice and --tool-call-parser llama3_json.</li></ul><p><strong>Issue 2: Confident Hallucinations</strong></p><ul><li><strong>Problem:</strong> When asked “Does <a href="https://www.bhp.com/">www.example.com</a> have IPv6 enabled?”, the LLM ignored the tools entirely, guessed the answer, and confidently lied.</li><li><strong>Solution:</strong> I had to treat the LLM like a lazy intern. I rewrote the system_prompt to be extremely aggressive: <em>&quot;CRITICAL INSTRUCTION: You currently have NO data... you MUST immediately call the tool... NEVER guess.&quot;</em></li></ul><p><strong>Issue 3: The 5-Step Infinite Loop of Death</strong></p><ul><li><strong>Problem:</strong> The LLM kept hitting 5-loop execution limit and returning: <em>“I needed too many steps to complete this request.”</em> * <strong>Debugging:</strong> I implemented [🤖 DEBUG] print statements in the Python loop to expose the LLM&#39;s inner monologue.</li><li><strong>The Culprits &amp; Fixes:</strong></li></ul><ol><li><strong>Missing Data:</strong> When the LLM saw empty data, it panicked, and looped to try again. I patched the JSON payloads to fix it.</li><li><strong>Hallucinated Syntax:</strong> The LLM hallucinated its JSON arguments, passing &quot;[&#39;recommendations&#39;]&quot; as a weird string instead of a real array. I <strong>bulletproofed</strong> the Python code to check cats_str = str(categories).lower()instead of relying on exact list matching.</li><li><strong>Hallucinated Categories:</strong> When asked about IPv6, the LLM ignored strict enum and invented a new category called ipv6_support. I updated Python router to catch keywords (if &quot;ipv6&quot; in cats_str) instead of forcing the LLM to memorize schema.</li><li><strong>The PowerPoint Obsession:</strong> Out of frustration, the LLM tried to use the generate_presentation_report tool to answer simple text questions, crashing the script because it passed bad JSON. I added a strict instruction: <em>&quot;Only call this tool if the user EXPLICITLY asks for a presentation.&quot;</em></li></ol><p><strong>Issue 4: Pydantic Validation Crashes</strong></p><ul><li><strong>Problem:</strong> vLLM threw a 1 validation error for ValidatorIterator when handling the chat history.</li><li><strong>Solution:</strong> I found a stray comma in Python system_prompt that accidentally converted it into a Tuple. I also enforced .model_dump(exclude_none=True) on the tool response objects to ensure vLLM received clean dictionaries, fixing a known context-dropping bug.</li></ul><h3>Phase 2: A Paradigm Shift — Enter Qwen</h3><p>After wrestling with Llama 3.1’s creative formatting, I realized a fundamental truth: <strong>Model architecture matters.</strong></p><p>I discussed how Alibaba’s <strong>Qwen</strong> models (like Qwen 2.5 7B and Qwen 3.5 9B) are aggressively fine-tuned for agentic behaviors, coding, and strict JSON adherence. While Llama is a “creative generalist,” Qwen acts as a “focused specialist.”</p><p>I decided to swap the engine. I updated the systemd file to pull Qwen/Qwen3.5-9B, swapped the parser flag to --tool-call-parser hermes, and let vLLM automatically download the open-weight model from Hugging Face.</p><p>Qwen3.5 performed much better from intent understanding perspective and also hallicunated lot less.</p><h3>Phase 3: The Hardware Ceiling and VRAM Gymnastics</h3><p>Upgrading to a 9-Billion parameter model triggered the final boss of journey: Memory Management.</p><p><strong>Issue 1: CUDA Out of Memory (OOM)</strong></p><ul><li><strong>Problem:</strong> The server crashed instantly. A 9B FP16 model requires ~18GB of VRAM just for the weights. On a 20GB RTX 4000 Ada, requesting a 24k context window immediately blew the VRAM limit.</li><li><strong>Solution:</strong> I circled back <strong>AWQ Quantization</strong>. By switching to QuantTrio/Qwen3.5-9B-AWQ, I squashed the 18GB model down to ~6GB, freeing up massive amounts of memory for the KV Cache.</li></ul><p><strong>Issue 2: VRAM Starvation</strong></p><ul><li><strong>Problem:</strong> Even with the AWQ model, I hit an OOM error allocating just 1.03 GB during a prompt.</li><li><strong>Solution:</strong> vLLM is incredibly greedy. Because I had --gpu-memory-utilization 0.95 set, vLLM pre-allocated 18.5GB at startup for its cache pool, leaving zero room for temporary math (activations).</li></ul><p><strong>The Final “Holy Grail” Configuration:</strong> I achieved ultimate stability by tuning the engine specifically for a low-traffic, single-user agent:</p><ul><li>PYTORCH_ALLOC_CONF=expandable_segments:True (Prevents VRAM fragmentation).</li><li>--gpu-memory-utilization 0.88 (Leaves enough breathing room for math).</li><li>--max-model-len 6144 (Limits the combined prompt/JSON payload to ~4,600 words, preventing activation spikes).</li><li>--max-num-seqs 24 (Limits concurrent requests, drastically shrinking the required KV Cache footprint).</li></ul><h3><strong>Code Repo for Web performance AI Agent</strong></h3><p><a href="https://github.com/deepakjd2004/ai-skills/tree/master/web-auditor">https://github.com/deepakjd2004/ai-skills/tree/master/web-auditor</a></p><h3>Final Thoughts and Learnings</h3><p>Building an AI Agent is rarely about the AI itself; it is an exercise in data validation, prompt engineering, and resource management.</p><ol><li><strong>Trust, but Validate:</strong> Never trust an LLM to return valid JSON. Always write “bulletproof” Python functions that can handle strings, lists, or hallucinated schemas gracefully.</li><li><strong>Expose the Inner Monologue:</strong> The [🤖 DEBUG] print statements saved sanity. You cannot fix a looping agent if you don&#39;t know what tool it is trying to call.</li><li><strong>Pick the Right Tool for the Job:</strong> Creative models are terrible at strict tasks. Agentic models (like Qwen or Hermes) will save you hundreds of lines of defensive coding.</li><li><strong>Hardware Dictates Reality:</strong> You can have the best code in the world, but if you don’t understand how PyTorch allocates KV Cache vs. Weights vs. Activations, you will end up staring at a CUDA Out of Memory error.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=160e6e1e5544" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI-Powered Auditing Skills: Comprehensive Web Performance & Akamai CDN Auditing]]></title>
            <link>https://deepakjd2004.medium.com/ai-powered-automation-skills-comprehensive-web-performance-akamai-cdn-auditing-4a72288520e0?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a72288520e0</guid>
            <category><![CDATA[ai-agent]]></category>
            <category><![CDATA[llm-applications]]></category>
            <category><![CDATA[web-performance]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[skills]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Sat, 25 Apr 2026 08:51:03 GMT</pubDate>
            <atom:updated>2026-04-25T09:25:26.020Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A deep dive into building intelligent audit and reporting workflows for modern web infrastructure</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wZVtzFgn7is-GfpTB87niw.jpeg" /><figcaption>AI-Powered Automation Skills — Web Performance &amp; Akamai Auditing</figcaption></figure><p><strong>Introduction</strong></p><p>In today’s digital landscape, maintaining optimal web performance and CDN efficiency is critical for business success. Yet manual auditing of web properties and content delivery networks is time-consuming, error-prone, and difficult to scale. This article explores two powerful AI-integrated automation skills that solve these challenges: <strong>web-auditor</strong> and <strong>akamai_audit</strong>.</p><p>These skills represent a paradigm shift in how organizations can perform comprehensive audits. Rather than manually inspecting properties, pulling reports from multiple dashboards, or waiting for specialized consultants, teams can now trigger automated workflows that gather, analyze, and present data in minutes.</p><p>These AI Skills can be added to claude/gemini-cli or other AI based tools to combine the power of generative AI with web performance and akamai audit data.</p><p>With these skills added to your AI agent, you can ask AI Agent to audit your website or akamai property and prepare an executive summary for your senior management or a detailed report for your web development teams. You can converse with AI agents in natural language to further deep dive on any part of audit and also get some recommendations.</p><p>Capabilities of both the AI agents are explained further in the blog.</p><p>Here are the resource link for both the AI Agents</p><p>- <strong>Web-Auditor</strong>: <a href="https://github.com/deepakjd2004/ai-skills/tree/master/web-auditor">https://github.com/deepakjd2004/ai-skills/tree/master/web-auditor</a></p><p>- <strong>Akamai-Audit</strong>: <a href="https://github.com/deepakjd2004/ai-skills/tree/master/akamai_audit">https://github.com/deepakjd2004/ai-skills/tree/master/akamai_audit</a></p><p><strong>Part 1: Web Performance Auditing at Scale</strong></p><p><strong>Understanding the Challenge</strong></p><p>Web performance directly impacts user experience, SEO rankings, and conversion rates. Organizations need to understand:</p><ol><li><strong>Real-world performance metrics</strong> from actual user browsers (Core Web Vitals)</li><li><strong>Technical optimization opportunities</strong> across DNS, protocols, caching, and compression</li><li><strong>Network efficiency</strong> including CDN usage, protocol versions (HTTP/3), and resource prioritization</li><li><strong>Actionable recommendations</strong> tailored to specific properties</li></ol><p>Traditional auditing approaches fall short:</p><ul><li>Page Speed Insights provides limited insights without context</li><li>Manual browser testing doesn’t scale</li><li>Generic reports lack business relevance</li><li>Stakeholders need presentation-ready deliverables, not raw data</li></ul><p><strong>Introducing Web-Auditor</strong></p><p><strong>web-auditor</strong> is a comprehensive Python-based web performance assessment tool that automates this entire process.</p><p><strong>Architecture &amp; Components</strong></p><p>The skill comprises two primary scripts working in concert:</p><p><strong>1. web_performance_audit_v2.py</strong> — The Data Gathering Engine</p><p>This core script performs 11 distinct audit phases:</p><p>Phase 1: CrUX Data Analysis — you need to create a CRUX API, use this link to get it for free if you already don’t have it — <a href="https://developer.chrome.com/docs/crux/api">https://developer.chrome.com/docs/crux/api</a></p><p>├─ Fetches real-world Core Web Vitals (LCP, INP, CLS)</p><p>├─ Analyzes metric distributions across user populations</p><p>└─ Identifies performance percentiles</p><p>Phase 2: DNS Configuration</p><p>├─ Validates DNS TTL values</p><p>├─ Checks nameserver responses</p><p>└─ Identifies DNS optimization opportunities</p><p>Phase 3: IPv6 Support Detection</p><p>├─ Tests AAAA record resolution</p><p>├─ Verifies dual-stack connectivity</p><p>└─ Recommends IPv6 adoption when applicable</p><p>Phase 4: HTML Parsing &amp; Resource Extraction</p><p>├─ Fetches page HTML (static or via headless browser)</p><p>├─ Extracts all CSS, JS, fonts, images</p><p>├─ Catalogs third-party dependencies</p><p>└─ Identifies render-blocking resources</p><p>Phase 5: CDN Detection (IP-Based)</p><p>├─ Resolves all resource domains to IPs</p><p>├─ Cross-references against known CDN IP ranges</p><p>├─ Identifies CDN vs. origin traffic</p><p>└─ Detects multi-CDN configurations</p><p>Phase 6: First-Party Compression Analysis</p><p>├─ Checks gzip/brotli compression on own assets</p><p>├─ Measures compression ratios</p><p>├─ Flags uncompressed large files</p><p>└─ Calculates bandwidth savings opportunity</p><p>Phase 7: Render-Blocking Resource Analysis</p><p>├─ Identifies CSS/JS in &lt;head&gt; blocking rendering</p><p>├─ Measures render-blocking duration</p><p>├─ Suggests async/defer alternatives</p><p>└─ Recommends critical CSS extraction</p><p>Phase 8–10: Advanced Resource Analysis</p><p>├─ Resource hints (preconnect, prefetch, preload)</p><p>├─ Image optimization and srcset usage</p><p>├─ Font loading strategies (system fonts, WOFF2, subsetting)</p><p>├─ Per-domain HTTP protocol breakdown</p><p>└─ Caching header analysis</p><p>Phase 11: Browser-Based Network Analysis</p><p>├─ Captures network timing from headless Chrome</p><p>├─ Identifies slow resources (&gt;2s load time)</p><p>├─ Catalogs heavy payloads (&gt;1MB)</p><p>└─ Extracts LCP resource information</p><p><strong>Data Model</strong></p><p>The script outputs a structured JSON containing:</p><p>json</p><p>{</p><p>“url”: “https://www.example.com&quot;,</p><p>“timestamp”: “2024–04–25T10:30:00”,</p><p>“rendering_method”: “browser|static”,</p><p>“crux_data”: {</p><p>“lcp”: { “p75”: 2500, “distribution”: {<em>…</em>} },</p><p>“inp”: { “p75”: 150, “distribution”: {<em>…</em>} },</p><p>“cls”: { “p75”: 0.1, “distribution”: {<em>…</em>} },</p><p>“overall_rating”: “GOOD|NEEDS_IMPROVEMENT|POOR”</p><p>},</p><p>“technical_checks”: {</p><p>“dns”: { “ttl”: 3600, “nameservers”: [<em>…</em>] },</p><p>“ipv6_support”: true,</p><p>“cdn_detected”: “Akamai”,</p><p>“http_version”: “HTTP/3”,</p><p>“compression”: { “gzip”: true, “brotli”: true },</p><p>“resource_protocols”: {</p><p>“www.example.com&quot;: “HTTP/3”,</p><p>“cdn.example.com”: “HTTP/2”,</p><p>“third-party.com”: “HTTP/1.1”</p><p>}</p><p>},</p><p>“recommendations”: [</p><p>{ “priority”: “HIGH”, “category”: “Core Web Vitals”, “action”: “…” },</p><p>{ “priority”: “MEDIUM”, “category”: “Compression”, “action”: “…” }</p><p>]</p><p>}</p><p><strong>2. generate_audit_deck.py</strong> — The Presentation Layer</p><p>This script transforms raw audit JSON into executive-ready PowerPoint presentations:</p><p>python</p><p># Two operational modes:</p><p># Mode 1: Template-Based (Optional)</p><p>python generate_audit_deck.py \</p><p><em>— </em>json-file output/audit_20240425.json \</p><p><em>— </em>template-file template/Performance_Review_of_example_com.pptx</p><p># Mode 2: Automatic Standard Deck (Default)</p><p>python generate_audit_deck.py \</p><p><em>— </em>json-file output/audit_20240425.json</p><p>The presentation generator includes:</p><p>- <strong>Cover slide</strong> with URL, audit date, and company branding</p><p>- <strong>Executive summary</strong> with Core Web Vitals scorecard</p><p>- <strong>Technical findings</strong> organized by category</p><p>- <strong>Performance metrics table</strong> with visual ratings</p><p>- <strong>Detailed recommendations</strong> with priority levels and business impact</p><p>- <strong>Network protocol analysis</strong> showing HTTP version breakdown by domain</p><p>- <strong>Actionable roadmap</strong> for improvement initiatives</p><p><strong>Intelligent Template Fallback</strong></p><p>A key innovation is the <strong>template fallback mechanism</strong>. If users provide a custom template, the script uses it. If the template is missing or loading fails, it automatically generates a clean, professional standard presentation. This eliminates failure modes and ensures reports are always delivered.</p><p><strong>Key Technical Features</strong></p><p>1. <strong>Browser-Based Analysis</strong> — Optional headless Chrome integration captures real network timings and JavaScript-rendered content, not just static HTML</p><p>2. <strong>Multi-Domain Protocol Detection</strong> — Goes beyond simple HTTP version detection to analyze protocol usage per resource domain</p><p>3. <strong>CrUX Integration</strong> — Correlates local measurements with real Chrome user data, bridging synthetic and real-user monitoring</p><p>4. <strong>Compression Opportunity Quantification</strong>— Calculates exact bandwidth savings from gzip/brotli implementation</p><p><strong>### Use Cases</strong></p><p><strong>1. Performance Regression Detection</strong></p><p>Run audits on a scheduled basis (weekly/monthly) and compare metrics trends:</p><p>python</p><p># Week 1</p><p>python web_performance_audit_v2.py <a href="http://www.example.com/">www.example.com</a> <em>— </em>crux-key <em>$</em>CRUX_API_KEY</p><p># Week 2 (compare output)</p><p>python web_performance_audit_v2.py <a href="http://www.example.com/">www.example.com</a> <em>— </em>crux-key <em>$</em>CRUX_API_KEY</p><p># Alert if LCP increased by &gt;10%</p><p>```</p><p><strong>2. Multi-Property Portfolio Review</strong></p><p>Audit dozens of properties and generate individual decks for stakeholder reviews:</p><p>```bash</p><p>for domain in site1.com site2.com site3.com; do</p><p>python web_performance_audit_v2.py $domain — crux-key $CRUX_API_KEY</p><p>python generate_audit_deck.py — json-file output/audit_${domain}.json</p><p>done</p><p>```</p><p><strong>3. Competitive Analysis</strong></p><p>Audit competitor sites and present findings to product/marketing teams:</p><p>```bash</p><p>python web_performance_audit_v2.py competitor.com — crux-key $CRUX_API_KEY</p><p># Output: detailed technical breakdown revealing their performance strategy</p><p><strong>— -</strong></p><p><strong>Part 2: Akamai CDN Asset Auditing</strong></p><p><strong>Understanding the Challenge</strong></p><p>Akamai is one of the world’s largest content delivery networks, but managing properties, contracts, and traffic data requires interaction with multiple complex APIs can be tiresome:</p><p>- Akamai Contract API (contract and product inventory)</p><p>- Akamai Property API (property configuration and behaviors)</p><p>- Akamai Reporting API (traffic analysis and billing metrics)</p><p>- CloudLet API (edge application management)</p><p>Large organizations might struggle with:</p><p>- <strong>Visibility gaps</strong> — Multiple contract hierarchies and property ownership is unclear</p><p>- <strong>Traffic analysis inefficiency</strong>— Gathering data across date ranges and CP codes is manual without API</p><p>- <strong>Configuration drift</strong> — Detecting unintended behavior changes is difficult</p><p>- <strong>Cost optimization</strong> — Understanding traffic patterns by property/CP code is complex without use of API, especially when you have to dealy with 100s of hostnames</p><p><strong>Introducing Akamai-Audit</strong></p><p><strong>akamai_audit</strong> is a Python-based Akamai account intelligence framework that provides unified visibility across all properties and traffic data.</p><p><strong>Architecture &amp; Components</strong></p><p>The skill is built on a modular architecture:</p><p><strong>1. EdgeGrid Client Layer</strong> — Secure Akamai API Communication</p><p>python</p><p>class EdgeGridClient:</p><p>def __init__(self, client_token, client_secret, access_token, host):</p><p># Implements HMAC-SHA256 signing per Akamai EdgeGrid spec</p><p># Handles request authentication and response parsing</p><p>pass</p><p>def get(self, path, params=None):</p><p># Authenticated GET with pagination support</p><p>pass</p><p>def post(self, path, payload):</p><p># Authenticated POST for complex queries</p><p>pass</p><p>The client handles:</p><p>- HMAC-SHA256 request signing (Akamai’s authentication mechanism)</p><p>- Request throttling and retry logic</p><p>- Response pagination for large datasets</p><p>- Error handling and status code interpretation</p><p><strong>2. Akamai API Abstraction Layer</strong></p><p>python</p><p>class AkamaiApi:</p><p># Contract &amp; Inventory APIs</p><p>get_all_contracts() # List all contracts</p><p>get_all_groups() # List all groups</p><p>get_all_cpcodes() # List all CP codes</p><p>find_all_properties() # Bulk property search</p><p># Property Detail APIs</p><p>search_for_property(name) # Find property by name</p><p>get_property_version_detail(id, ver) # Get specific version config</p><p>get_property_rule_tree(id, ver) # Get full rule tree (behaviors)</p><p>get_property_hostnames(id, ver) # Get all hostnames</p><p># Traffic &amp; Reporting APIs</p><p>get_traffic_summary(cpcodes, dates) # Aggregate traffic metrics</p><p>get_url_traffic(cpcodes, dates) # Per-URL traffic analysis</p><p># Advanced Queries</p><p>get_property_behaviors(property) # Extract all behavior rules</p><p>get_cloudlet_policies() # Cloudlet deployment status</p><p>```</p><p><strong>3. Report Builders</strong> — Specialized Analysis Modules</p><p>Each report type is encapsulated in a dedicated module:</p><p><strong>contracts.py</strong> — Contract Inventory Report</p><p>Output: CSV of all contracts with:</p><p>├─ Contract ID</p><p>├─ Contract Status (SIGNED, PENDING, etc.)</p><p>├─ Associated Groups count</p><p>├─ Products and services</p><p>└─ Renewal dates</p><p><strong>groups.py</strong> — Organization Hierarchy Report</p><p>Output: CSV of groups with:</p><p>├─ Group ID and Name</p><p>├─ Parent group relationships</p><p>├─ Properties per group</p><p>├─ Team/admin assignments</p><p>└─ SLA status</p><p><strong>properties.py</strong> — Property Configuration Report</p><p>Output: Detailed CSV for each property:</p><p>├─ Property name and ID</p><p>├─ Hostnames (production + staging)</p><p>├─ Contract and group assignment</p><p>├─ Version history</p><p>├─ Deployment status</p><p>└─ Origin configuration</p><p><strong>traffic.py</strong> — Traffic Analysis Report</p><p>Output: Multiple CSVs aggregating:</p><p>├─ traffic_summary_hits.csv (requests per CP code)</p><p>├─ traffic_summary_bytes.csv (bandwidth per CP code)</p><p>├─ url_traffic_hits.csv (per-URL request counts)</p><p>├─ url_traffic_extension_summary.csv (aggregated by file type)</p><p>├─ url_*.csv (specific URLs: 302, 304, 404)</p><p>└─ traffic by date range (customizable)</p><p><strong>behaviors.py</strong>— Property Behavior Analysis</p><p>Output: JSON with all active behaviors including:</p><p>├─ Caching rules</p><p>├─ Request/response headers</p><p>├─ Content compression</p><p>├─ Origin failover</p><p>├─ URL redirects</p><p>├─ Geo-targeting rules</p><p>└─ Performance enhancement policies</p><p><strong>4. Orchestration Engine</strong> — Workflow Automation</p><p>python</p><p>class Orchestrator:</p><p>run_ai_agent_action(action, payload):</p><p># Maps user requests to specific report actions</p><p>Actions supported:</p><p>├─ “full_audit” # Everything</p><p>├─ “account_summary” # High-level inventory</p><p>├─ “traffic_report” # Custom date range</p><p>├─ “property_report” # Single/multiple properties</p><p>├─ “cloudlets_report” # Cloudlet deployment status</p><p>└─ “performance_report” # Performance-oriented metrics</p><p><strong>Data Model &amp; Output Strategy</strong></p><p>The skill generates outputs in multiple formats for maximum accessibility:</p><p><strong>Excel Workbook</strong> (.xlsx)</p><p>- Tab-per-report design</p><p>- Formatted headers and data validation</p><p>- Pre-built pivot table templates</p><p>- Summary dashboard sheet</p><p><strong>CSV Files</strong> (granular)</p><p>- One CSV per report type</p><p>- Headers matching business terminology</p><p>- Easy import into BI tools (Tableau, Looker, PowerBI)</p><p>- Audit trail for compliance</p><p><strong>JSON</strong> (structured)</p><p>- Full fidelity data export</p><p>- API-friendly for downstream automation</p><p>- Timestamped with audit metadata</p><p>- Allows programmatic processing</p><p><strong>Key Technical Features</strong></p><p>1. <strong>Paginated API Queries</strong> — Handles large datasets across contract/group hierarchies without memory exhaustion</p><p>2.<strong>Account Switch Key Support</strong> — Multi-account organizations or akamau personnels can audit different accounts in sequence</p><p>3. <strong>Date Range Customization</strong> — Traffic reports support arbitrary lookback windows (last 7/30/90 days)</p><p>4. <strong>Behavior Tree Parsing</strong>— Extracts and formats complex property rule trees into readable summaries</p><p>5. <strong>Cloudlet Policy Tracking</strong>— Identifies all edge applications and their deployment status</p><p>6. <strong>Performance Metrics Aggregation</strong> — Groups traffic data by CP code, domain, URL, and file type</p><p><strong>Use Cases</strong></p><p><strong>1. Account Inventory Baseline</strong></p><p>Generate a comprehensive snapshot of all properties, groups, and contracts:</p><p>python</p><p>orchestrator.run_ai_agent_action(“account_summary”, {})</p><p># Output: complete organizational hierarchy in Excel</p><p><strong>2. Traffic Analysis &amp; Cost Optimization</strong></p><p>Identify high-traffic CP codes and analyze usage patterns:</p><p>python</p><p>orchestrator.run_ai_agent_action(“traffic_report”, {</p><p>“cpcodes”: [“12345”, “67890”],</p><p>“custom_days”: 30</p><p>})</p><p># Output: CSV files showing hits, bytes, and URL-level breakdown</p><p># Insight: Identify URLs consuming 80% of bandwidth → optimization targets</p><p><strong>3. Property Configuration Audit</strong></p><p>Deep dive into a specific property’s behaviors and hostnames:</p><p>python</p><p>orchestrator.run_ai_agent_action(“property_report”, {</p><p>“property_names”: [“www.example.com&quot;],</p><p>“inventory_criteria”: “ALL”</p><p>})</p><p># Output: All behaviors, hostnames, caching rules, and origin config</p><p><strong>4. Compliance &amp; Change Tracking</strong></p><p>Compare property configurations across time periods to detect unauthorized changes:</p><p># Run audit on Day 1</p><p>audit_1 = orchestrator.run_ai_agent_action(“property_report”, {…})</p><p># Run audit on Day 30</p><p>audit_30 = orchestrator.run_ai_agent_action(“property_report”, {…})</p><p># Diff the behavior trees to identify changes</p><p>diff(audit_1[‘behaviors’], audit_30[‘behaviors’])</p><p><strong>5. Cloudlet Deployment Verification</strong></p><p>Ensure edge applications are properly deployed and active:</p><p>python</p><p>orchestrator.run_ai_agent_action(“cloudlets_report”, {})</p><p># Output: All cloudlets, policies, and deployment status</p><p>```</p><p><strong>— -</strong></p><p><strong>Part 3: Synergy &amp; Integration Patterns</strong></p><p><strong>Why Use Both Skills Together?</strong></p><p>While web-auditor and akamai_audit serve different purposes, they’re most powerful when combined:</p><p><strong>Pattern 1: Infrastructure Verification</strong></p><p>User Request: “Audit my site and verify it’s using Akamai”</p><p>Execution:</p><p>1. web_performance_audit_v2.py detects HTTP/3 and Akamai IP ranges</p><p>2. akamai_audit property_report confirms property configuration</p><p>3. Compare protocol analysis from both sources</p><p>4. Verify CP code assignments and caching rules align</p><p>Result: Comprehensive infrastructure audit with cross-validation</p><p><strong>Pattern 2: Multi-Property Benchmarking</strong></p><p>User Request: “Compare performance and traffic efficiency across 10 properties”</p><p>Execution:</p><p>1. web_performance_audit_v2.py runs on all 10 URLs</p><p>2. akamai_audit property_report on each property</p><p>3. Generate comparison matrix (CWV scores vs. traffic volume)</p><p>4. Identify underperforming properties relative to traffic allocation</p><p>Result: Portfolio dashboard with per-property insights</p><p><strong>— -</strong></p><p><strong>Part 4: Architecture &amp; Best Practices</strong></p><p><strong>Design Principles</strong></p><p><strong>1. Separation of Concerns</strong></p><p>- Data gathering (web_performance_audit_v2.py, EdgeGrid client) isolated from reporting</p><p>- Report generation (generate_audit_deck.py) agnostic to data source</p><p>- Modules are independently testable and replaceable</p><p><strong>2. Fail-Safe Defaults</strong></p><p>- Web auditor falls back to standard PPT if template fails</p><p>- Akamai audit can run with default credentials and explicit account keys</p><p>- Missing API responses are handled gracefully with partial reports</p><p><strong>3. Audit Trail &amp; Reproducibility</strong></p><p>- All reports timestamped with execution metadata</p><p>- JSON outputs include full parameter sets for reconstruction</p><p>- CSV exports support historical comparison</p><p><strong>Deployment Considerations</strong></p><p><strong>Environment Setup</strong></p><p>bash</p><p># Install dependencies</p><p>pip install requests dnspython beautifulsoup4 # web-auditor</p><p>pip install selenium # (optional) for JS-rendered pages</p><p>pip install akamai-edgegrid python-requests # akamai_audit</p><p># Configure credentials</p><p>export CRUX_API_KEY=”your_crux_api_key”</p><p>export AKAMAI_ACCOUNT_SWITCH_KEY=”your_account_key” # optional</p><p># ~/.edgerc contains Akamai credentials (client token, secret, host)</p><p><strong>Template Management</strong></p><p>web-auditor/template/ # Optional custom templates</p><p>└─ Performance_Review_of_example_com.pptx</p><p># Can be customized for branding</p><p># If missing or corrupted, standard PPT auto-generates</p><p><strong>Output Organization</strong></p><p>akamai_audit/output/</p><p>├─ audit_20240425.json</p><p>├─ contracts.csv</p><p>├─ properties.csv</p><p>├─ traffic_summary_hits.csv</p><p>└─ [multiple report files]</p><p>web-auditor/output/</p><p>├─ www_example_com_20240425.json</p><p>└─ www_example_com_20240425.pptx</p><p><strong>— -</strong></p><p><strong>Conclusion</strong></p><p>web-auditor and akamai_audit represent an AI based web performance and CDN(Akamai) audit tools. Rather than stitching together disparate APIs and manual processes, they provide:</p><p>✅ <strong>Comprehensive Coverage</strong> — Multi-faceted performance and infrastructure analysis</p><p>✅ <strong>Actionable Insights</strong>— Raw data transformed into prioritized recommendations</p><p>✅ <strong>Scalable Automation</strong>— Batch audits across dozens of properties</p><p>✅ <strong>Executive Readiness</strong>— Presentation-ready deliverables for stakeholders</p><p>✅ <strong>Integrations</strong> — JSON/CSV outputs feed into BI tools and orchestration platforms</p><p>For teams managing web infrastructure at scale, these skills eliminate manual toil and unlock deeper insights into performance and CDN efficiency. Deploy them as part of your monitoring pipeline, continuous optimization workflows, or compliance auditing processes.</p><p><strong>— -</strong></p><p><strong>Resources &amp; Links</strong></p><p>- <strong>Web-Auditor</strong>: <a href="https://github.com/deepakjd2004/ai-skills/tree/master/web-auditor">https://github.com/deepakjd2004/ai-skills/tree/master/web-auditor</a></p><p>- <strong>Akamai-Audit</strong>: <a href="https://github.com/deepakjd2004/ai-skills/tree/master/akamai_audit">https://github.com/deepakjd2004/ai-skills/tree/master/akamai_audit</a></p><p>- <strong>Akamai EdgeGrid API</strong>: <a href="https://developer.akamai.com/api">https://developer.akamai.com/api</a></p><p>- <strong>CrUX API</strong>: <a href="https://developer.chrome.com/docs/crux/api/">https://developer.chrome.com/docs/crux/api/</a></p><p>- <strong>Core Web Vitals</strong>: <a href="https://web.dev/vitals/">https://web.dev/vitals/</a></p><p><strong>— -</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a72288520e0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating ServiceNow Workflows with Akamai API’s]]></title>
            <link>https://deepakjd2004.medium.com/integrating-servicenow-workflows-with-akamai-apis-a1734d552983?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1734d552983</guid>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 06:55:48 GMT</pubDate>
            <atom:updated>2025-12-08T06:16:28.359Z</atom:updated>
            <content:encoded><![CDATA[<p>A Guide to Building Akamai Integrations in ServiceNow</p><p>ServiceNow is a popular <a href="https://en.wikipedia.org/wiki/Platform-as-a-service">platform-as-a-service</a>, that is designed to support <a href="https://en.wikipedia.org/wiki/IT_service_management">IT service management</a> and <a href="https://en.wikipedia.org/wiki/Help_desk">help desk</a> functionality with automated workflows.</p><p>Akamai is a global cybersecurity and cloud computing company that operates a large distributed computing network to deliver its services. Services include CDN, Edge DNS, WAF, Bot Protection, Network Segmentation, Zero Trust, cloud services and many others.</p><p>Both ServiceNow and Akamai are widely adopted platforms used by a large number of customers.</p><p>Purpose of this blog is to identify a clear path for automating akamai tasks from service-now.</p><p>It’s often easiest to explain this with an example, so let’s take one.</p><p>Suppose the business team wants to onboard a new site, <a href="http://www.new-site.com/"><strong>www.new-site.com</strong></a>, and submits a request through ServiceNow. Before a site can go live, several tasks must typically be completed — such as provision hosting, develop site, DNS configuration, certificate provisioning, CDN setup, and applying protections like WAF, bot mitigation, DDoS defenses, and rate limiting.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w23kmSY8zq446OrUXFmpkQ.jpeg" /></figure><p>In simplified terms, the workflow begins with the business user submitting a Service Request for onboarding <a href="http://www.new-site.com/"><strong>www.new-site.com</strong></a>. That request then moves through the necessary approvals before generating tasks for the relevant teams to complete.</p><p>The onboarding process typically involves multiple teams — for example, the <strong>Infrastructure team</strong> responsible for provisioning resources with the hosting provider, the <strong>Application team</strong> that deploys the website, the <strong>CDN team</strong> that manages certificates and CDN configuration, and the <strong>Security team</strong> that handles Akamai WAF, Bot Protection, and other security controls.</p><p>From this, a few challenges become clear:</p><ul><li><strong>High complexity</strong></li><li><strong>Long turnaround times</strong></li><li><strong>Significant manual effort</strong></li></ul><p>Akamai provides a rich set of automation tools — API, CLI, Terraform provider, PowerShell modules, and Postman collections — that allow teams to automate many of these tasks. For example, the Infrastructure team can use the Akamai Terraform provider to automate DNS management, while the CDN and Security teams can automate their configuration tasks through Terraform or API scripts.</p><p>While these methods are widely used and effective, an alternative approach is to centralize automation within <strong>ServiceNow</strong>. In this model, ServiceNow workflows make direct API calls to Akamai to manage all required resources. Human involvement is limited to approvals and final validation, while the operational steps are fully automated through ServiceNow and Akamai APIs.</p><p>To explain the process of automation, i will start by taking an example of automating DNS record management in Akamai using servicenow business rules.</p><p>Here is what we want to achieve with this automation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9RbfxNDFHkbiLRR16qy3GQ.png" /></figure><p><strong>Preparation</strong>:-</p><p>1) As I am not a servicnow developer(always used it as and end user, never as developer). the most important piece of puzzle was to get access to serviceNow instance — But luckily servicenow has made it pretty easy to get developer instance.</p><ul><li>Go to <a href="https://developer.servicenow.com/"><strong>https://developer.servicenow.com/</strong></a></li><li>Sign up and request a free instance</li><li>You’ll get credentials and a URL like <a href="https://devxxxxx.service-now.com/">https://devXXXXX.service-now.com</a> -keep username/password safe</li></ul><p>2) Gather Your Akamai EdgeGrid Credentials — Akamai do not provide developer instance but you can create a separate group within Akamai Control Center(considering you are already akamai customer) and restrict your access to only that group so that while you play you do not spill.</p><p>If you don’t already have access to API credentials than please ask your Akamai Account Admin to help you with that. Ask them to give you R/W access to Edge DNS API and to reduce blast radius restrict API permission to intended group only.</p><p>You’ll need these from your Akamai Control Center:</p><ul><li><strong>Client Token</strong></li><li><strong>Client Secret</strong></li><li><strong>Access Token</strong></li><li><strong>Host</strong> (e.g., <a href="http://akab-xxxxxxxxx.luna.akamaiapis.net/">akab-xxxxxxxxx.luna.akamaiapis.net</a>)</li></ul><p>3) Familiarize with Akamai Edge DNS API</p><ul><li>API Access Control — <a href="https://techdocs.akamai.com/edge-dns/reference/get-started">https://techdocs.akamai.com/edge-dns/reference/get-started</a></li><li>Edge DNS API — <a href="https://techdocs.akamai.com/edge-dns/reference/edge-dns-api">https://techdocs.akamai.com/edge-dns/reference/edge-dns-api</a></li><li>Get a zone record — <a href="https://techdocs.akamai.com/edge-dns/reference/get-zone-name-type">https://techdocs.akamai.com/edge-dns/reference/get-zone-name-type</a></li><li>Create a record — <a href="https://techdocs.akamai.com/edge-dns/reference/post-zones-zone-names-name-types-type">https://techdocs.akamai.com/edge-dns/reference/post-zones-zone-names-name-types-type</a></li></ul><p>4) Familiarize with Edgegrid authentication mechanism — Akamai uses proprietary authentication mechanism called Edgegrid and it is built with security in mind so from developer standpoint it seems to be little bit more involved but nobody should complain about it, especially due to numerous amount of attackers we are living with. <strong>This is going to be most tricky for anyone who has not worked with Akamai API. </strong>And in this blog we are going to spend lot of time seeing how you can create these auth tokens from service-now.</p><p><strong>High Level Design</strong> —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4IXCo_5hk2ayBQODj8p1bg.jpeg" /></figure><p><strong>Data Layer</strong></p><ol><li><strong>DNS Request Table </strong>— When a user submit the request via. form, this table will be used to store the record. Every record entry in table triggers business logic to make an API call to backend Akamai Edge DNS</li><li><strong>REST Endpoints </strong>— These are reusable rest API endpoints for making different calls to manage DNS record. This demo scope is limited to get and create(post) DNS records only.</li><li><strong>System Properties </strong>— Used to securely store API credentials</li></ol><p><strong>Business Logic Layer</strong></p><ol><li><strong>Business Rule</strong> — Orchestrate the logic to call akamai api based on trigger it received from ‘DNS Request table’. It uses Script Include “AkamaiEdgegridAuth’ for request authentication. Please note that their can be many methods to implement logic to call akamai api’s for e.g using flow designer, using sub flow, actions etc but I chose Business rule because of simplicity over anything else.</li><li><strong>Script Include </strong>— Logic to authenticate akamai api requests</li><li><strong>Hashes Library </strong>— Crypto library for creating HMAC SHA256 authN/Z.</li></ol><p><strong>Low Level Design</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*za8pgip4TsWlCzN9oteo_A.jpeg" /></figure><p>Please go through the technical implementation to understand these tasks in detail. Note that Account Switch Key is for internal Akamai personnel or partners who manages multiple customers. You can ignore Account Switch key if you are none of these.</p><p><strong>Technical Implementation </strong>-</p><p><strong>Step 1 — Create DNS Request Table</strong> in ServiceNow</p><ol><li>Go to <strong>System Definition → Tables</strong></li><li>Create a new table: u_dns_request</li><li>Add fields:</li></ol><ul><li>zone (String)</li><li>hostname (String)</li><li>record_type (String, default: &quot;A&quot;)</li><li>ip_address (String)</li><li>ttl (Integer, default: 300)</li><li>status (Choice: Pending, Success, Failed, default Pending)</li><li>response_message (String)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7O-qdqAXn4y-yhWk7RIjSA.jpeg" /></figure><p><strong>Step 2 — Store Akamai Credentials securely in system properties in ServiceNow</strong></p><ol><li>Go to <strong>System Properties → System Properties</strong></li><li>Create new properties:</li></ol><ul><li><strong>Name</strong>: akamai.client_token</li><li><strong>Value</strong>: (your actual token)</li><li><strong>Type</strong>: string</li><li><strong>Private</strong>: Enabled</li><li><strong>Description</strong>: Akamai EdgeGrid Client Token</li></ul><p>Same for below fields as well</p><ul><li>akamai.client_secret = your client secret</li><li>akamai.access_token = your access token</li><li>akamai.host = your Akamai API host (e.g., <a href="http://akab-xxxxxxxxx.luna.akamaiapis.net/">akab-xxxxxxxxx.luna.akamaiapis.net</a>)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KqpgQ04ddR6zfwvtcHfrtg.jpeg" /></figure><p>Step 3 — <strong>Create Global Script for HMAC hashes — We are going to call this from EdgeGrid Auth(step 4)</strong></p><ol><li>Use this Hashes.js library — <a href="https://github.com/h2non/jshashes/blob/master/hashes.js">https://github.com/h2non/jshashes/blob/master/hashes.js</a></li><li><strong>Navigate to Script Include</strong>:</li></ol><ul><li>In the left navigation/filter, type: <strong>Script Includes</strong></li><li>OR go to: <strong>System Definition → Script Includes</strong></li></ul><p><strong>3. Create New Script Include</strong>:</p><ul><li>Click the <strong>New</strong> button</li><li>You’ll see a form with these fields:</li></ul><p><strong>Fill in the form</strong>:</p><ul><li><strong>Name</strong>: Hashes</li><li><strong>API Name</strong>: global.Hashes (auto-fills)</li><li><strong>Application</strong>: Global (or your custom app)</li><li><strong>Accessible from</strong>: All application scopes ✓</li><li><strong>Active</strong>: ✓ (checked)</li><li><strong>Script: </strong>Copy content from <a href="https://github.com/h2non/jshashes/blob/master/hashes.js">https://github.com/h2non/jshashes/blob/master/hashes.js</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*onVQNjAJN2qE9Vj8IoKd1Q.jpeg" /></figure><p><strong>Step 4 — Create Script Include for EdgeGrid Auth (Hashes script is going to be referred from this script.</strong></p><ol><li><strong>Navigate to Script Include</strong>:</li></ol><ul><li>In the left navigation/filter, type: <strong>Script Includes</strong></li><li>OR go to: <strong>System Definition → Script Includes</strong></li></ul><p><strong>Create New Script Include</strong>:</p><ul><li>Click the <strong>New</strong> button</li><li>You’ll see a form with these fields:</li></ul><p><strong>Fill in the form</strong>:</p><ul><li><strong>Name</strong>: AkamaiEdgeGridAuth</li><li><strong>API Name</strong>: global.AkamaiEdgeGridAuth (auto-fills)</li><li><strong>Application</strong>: Global (or your custom app)</li><li><strong>Accessible from</strong>: All application scopes ✓</li><li><strong>Active</strong>: ✓ (checked)</li><li><strong>Description</strong>: EdgeGrid authentication helper for Akamai API integration</li></ul><ol><li><strong>Paste the script in the “Script” field</strong>:</li></ol><ul><li>Look for the large text box labeled <strong>“Script”</strong></li><li>This is where you paste the entire code — <a href="https://github.com/deepakjd2004/snow-akamai-auth-js/blob/main/snow-akamai-auth_v2.js">https://github.com/deepakjd2004/snow-akamai-auth-js/blob/main/snow-akamai-auth_v2.js</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZUFQTQ9Rqfmt4mEPpIBHQ.jpeg" /></figure><h4><strong>Step 5 — Create REST Message - - API endpoint definitions, including methods</strong></h4><ol><li>Navigate to <strong>System Web Services → Outbound → REST Message</strong></li><li>Click <strong>New</strong></li><li>Configure:</li></ol><ul><li><strong>Name</strong>: Akamai DNS API</li><li><strong>Endpoint</strong>: https://${akamai.host} (use your actual host)</li><li><strong>Authentication</strong>: No authentication (we’ll handle it manually)</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iZtOfwqc98RCA5F5GhXfhQ.jpeg" /></figure><h4>Step 6 — Create HTTP Method 1: Check DNS Record</h4><ul><li><strong>Name</strong>: checkDNSRecord</li><li><strong>HTTP Method</strong>: GET</li><li><strong>Endpoint</strong>: <a href="https://${akamai.host}/config-dns/v2/zones/$%7Bzone%7D/names/$%7Bhostname%7D/types/$%7BrecordType%7D">https://${akamai.host}/config-dns/v2/zones/${zone}/names/${hostname}/types/${recordType}</a></li><li><strong>Authentication</strong>: No change needed</li><li><strong>HTTP Request</strong> tab: Leave body empty</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLYzZ61BMsZorX-nnl6O3Q.jpeg" /></figure><h4>Step 7 — Create HTTP Method 2: Create DNS Record</h4><ul><li><strong>Name</strong>: createDNSRecord</li><li><strong>HTTP Method</strong>: POST</li><li><strong>Authentication</strong>: No change needed</li><li><strong>Endpoint</strong>: <a href="https://${akamai.host}/config-dns/v2/zones/$%7Bzone%7D/names/$%7Bhostname%7D/types/$%7BrecordType%7D">https://${akamai.host}/config-dns/v2/zones/${zone}/names/${hostname}/types/${recordType}</a></li><li><strong>HTTP Request Body</strong>:{<br> “ttl”: ${ttl},<br> “name”: ${hostname},<br> “type”: $recordType},<br> “rdata”: [${ipAddress}]<br> }</li></ul><p><strong>Step 8 — Create Business Rule</strong> — Orchestrates everything</p><p>The Business Rule will:</p><ol><li>Trigger when a new DNS Request record is created with Status = “Pending”</li><li>Call Akamai API to check if record exists</li><li>Create the record if it doesn’t exist</li><li>Update the DNS Request record with success/failure status</li></ol><ul><li>Navigate to <strong>System Definition → Business Rules</strong></li><li>Click <strong>New</strong></li><li>Fill in:</li><li><strong>Name</strong>: Akamai DNS Integration</li><li><strong>Table</strong>: DNS Request [u_dns_request]</li><li><strong>When</strong>: after → insert</li><li><strong>Filter Conditions</strong>: Status is Pending</li><li><strong>Advanced</strong>: ✓ (checked)</li><li><strong>Active</strong> — ✓ (checked)</li><li><strong>Advanced Tab</strong> — Copy paste below script:- <a href="https://github.com/deepakjd2004/snow-akamai-auth-js/blob/main/snow-akamai-auth_v2.js">https://github.com/deepakjd2004/snow-akamai-auth-js/blob/main/example-EDNS-code.js</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KL5LT1mN4a0KVQKKS-oKzQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_mASvTJ-XjBA4h3mmeLXJA.jpeg" /></figure><p>Now is the time to test the execution</p><p><strong>Execution </strong>-</p><p>For executing the business logic, create a new record in table u_dns_request — and this should trigger the workflow to create new record in Akamai.</p><p>Fill everything apart from “Response Message”, AccountSwitchKey is needed for akamai personnel only, customer should ignore filling this field</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XNnecY0CwFZ5fj2Ty3Hm7Q.jpeg" /></figure><p><strong>Verification </strong>—</p><p>Go to Akamai Control Center to verify if record is created or not. This can also be automated using GET API to get details of zone.</p><p><strong>Logging and Troubleshooting</strong>-</p><p>Logs can be seen from <strong>System Logs → System Log → All</strong></p><p>ServiceNow provide a way to test script without executing it via business rule or other method like flow design etc.</p><p><strong>Go to → Scripts — Background </strong>(for local execution of script and testing)</p><p>That’s a wrap!! Thanks for reading!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1734d552983" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[☁️ Automating Akamai with Conversational AI and MCP Server]]></title>
            <link>https://deepakjd2004.medium.com/%EF%B8%8F-automating-akamai-with-conversational-ai-and-mcp-server-9908841c29df?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/9908841c29df</guid>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Wed, 25 Jun 2025 23:15:54 GMT</pubDate>
            <atom:updated>2026-02-27T00:03:59.314Z</atom:updated>
            <content:encoded><![CDATA[<h3>Imagine this:</h3><p>You’re sitting at the beach, sipping your favorite drink (no hard drinks though — we don’t want the AI giving you a cheeky smile and hallucinating responses 😄).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*ROsGPJ4LABw7bABD0EEMKw.jpeg" /></figure><p>From that peaceful spot, you casually ask an AI agent to onboard a hostname to the Akamai platform.</p><p>Sounds futuristic? Well, that future is here. Welcome to the world of <strong>Conversational AI and MCP Server</strong>.</p><h3>🎯 The Experiment: Managing Akamai with Conversational AI</h3><p>I wanted to see how far I could push natural language interfaces to control Akamai resources. The goal?<br> <strong>Replace command-line tools and manual API calls with simple, human language instructions.</strong></p><p>Here’s what my experiment setup looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X4ax73xIqr5VdF2IFdf_vQ.jpeg" /></figure><h3>🛠️ Setup Components</h3><h3>1. Conversational AI Client</h3><p>I used <strong>Claude Desktop</strong>, an AI chat interface running locally. It comes with access to Anthropic’s Claude 4 Sonnet model. You can run it on macOS or your OS of choice.</p><blockquote><em>Note: While I used Claude, this approach is tool-agnostic. You could swap it with OpenWebUI, LM Studio, or any other conversational AI client capable of triggering system commands.</em></blockquote><h3>2. MCP Server (Multi-Command Processor)</h3><p>This is a simple Python script acting as a lightweight API layer to control Akamai resources. It supports:</p><p>✅ Listing contracts<br> ✅ Listing groups<br> ✅ Listing properties<br> ✅ Filtered variations like “show properties with name xyz”<br> …and more, based on Akamai APIs.</p><p>Code Repo is here — <a href="https://github.com/deepakjd2004/akamai-mcp-server">https://github.com/deepakjd2004/akamai-mcp-server</a></p><p>Code Repo for edge diagnostics MCP server — <a href="https://github.com/deepakjd2004/akamai-edge-diagnostics-mcp-server">https://github.com/deepakjd2004/akamai-edge-diagnostics-mcp-server</a></p><h3>3. Akamai API Access</h3><p>For the actual resource control, I use an API client with access to an Akamai University account (limited permissions for testing).</p><h3>🔗 Connecting the AI and MCP Server</h3><p>Claude Desktop can interact with local processes via its config file. Here’s how I wired it up:</p><p><strong>Config location:</strong>CopyEdit</p><pre>~/Library/Application Support/Claude/claude_desktop_config.json</pre><p><strong>Example configuration:</strong></p><pre>{<br>  &quot;mcpServers&quot;: {<br>    &quot;akamai&quot;: {<br>      &quot;command&quot;: &quot;python&quot;,<br>      &quot;args&quot;: &quot;/Experiments/akamai-mcp-server/akamai_mcp_server.py&quot;,<br>      &quot;env&quot;: {}<br>    }<br>  }<br>}</pre><p>After saving the changes, simply restart Claude Desktop to apply the configuration.</p><h3>💬 Time for Action</h3><p>With everything wired up, I opened a new chat window and spoke to the AI in plain English. Here are examples of real commands I used:</p><ul><li>“Show me contract details.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MPhqsAAHodFU-iu8QV5Zrw.jpeg" /></figure><ul><li>“How many groups are in my contract?”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hwykzj15ig9jsTkNJAgatw.jpeg" /></figure><ul><li>“List properties for a specific group.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*euq0RMHrGD5iMd30TjLk9Q.jpeg" /></figure><p>Behind the scenes, Claude translated these prompts into structured API calls to the MCP server, which then interacted with Akamai’s platform — all without me writing a single curl command or digging through documentation.</p><h3>🚀 What’s Next?</h3><p>The possibilities are endless. Beyond basic queries, I plan to explore:</p><ul><li>Edge Diagnostics — It is done now, <a href="https://github.com/deepakjd2004/akamai-edge-diagnostics-mcp-server">https://github.com/deepakjd2004/akamai-edge-diagnostics-mcp-server</a></li><li>Automating cache purges</li><li>Traffic Analysis</li><li>Real-time monitoring summaries</li><li>Integrating with IaC</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9908841c29df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Resiliency in IT: Why It’s More Than Just Uptime]]></title>
            <link>https://deepakjd2004.medium.com/resiliency-in-it-why-its-more-than-just-uptime-d9a2c612ea46?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9a2c612ea46</guid>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Sat, 03 May 2025 23:55:07 GMT</pubDate>
            <atom:updated>2025-05-03T23:55:07.851Z</atom:updated>
            <content:encoded><![CDATA[<p>Resiliency is quite an important topic that gets interest from every aspect of business/IT. Also it is such a wide topic that one can write a book on it and that made me think🤔 where should i start 🥸.</p><p>Just to level-set — <strong>resiliency isn’t unique to Business/IT; it’s deeply rooted in human behavior.</strong> We build resilience into our personal lives all the time. Take insurance, for example. It’s a classic form of personal resiliency. If something unfortunate were to happen — however fate may decide — how can one ensure that their loved ones are still supported? Buy life insurance. That’s and excellent resilience plan. It may not preserve the same happiness, but at least it protects those who rely on us from sudden disruption.</p><p>Similarly, with so many of us now working from home, we’ve built our own forms of <strong>network resiliency</strong>. Take my setup, for example: if my primary internet connection via NBN goes down, I switch to an Optus 5G backup. If that fails too, I can fall back on mobile tethering via Telstra. I’m not even going to try counting how many “nines” that setup gives me! 😄</p><p>The key point is this: <strong>resiliency requires upfront planning and investment</strong>. In my case, I deliberately chose <strong>different providers</strong> to avoid a single point of failure — no shared dependency, no shared outage.</p><p>Alright going back to my earlier point about where should we start when we have to talk about IT resiliency. I am going to my (and i know many security professional’s) favorite CIA Triad.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/236/1*QhBaksXkiOuHwVgrF8YIIg.png" /><figcaption>Credit — <a href="https://falcongaze.com/">https://falcongaze.com/</a></figcaption></figure><h3>The CIA Triad and Where Resilience Fits In</h3><p>In cybersecurity, everything can be mapped to the <strong>CIA triad</strong> — <strong>Confidentiality, Integrity, and Availability</strong>. While availability often plays a quiet third fiddle to its siblings, it’s arguably the most <em>visibly</em> important in real-world operations.</p><p><strong>Resiliency</strong>, which falls under availability, is about more than staying online. It’s about being <strong>prepared to endure disruptions</strong> — and recovering fast when they occur.</p><h3>Why Resilience Is not just a Boardroom-Level Conversation</h3><p>Resiliency is a broad, layered concept that matters at every level of the organization:</p><ul><li>🏢 <strong>CxOs</strong> care because <strong>downtime = lost revenue</strong>, customer churn, and often, <strong>regulatory violations</strong>. For example in banking, regulators like APRA enforce operational continuity standards (e.g. CPS 230). CPS 230 applies to all APRA-regulated entities, including those in banking, insurance, and superannuation. Uptime isn’t just a goal — it’s the law.</li><li>👷‍♂️ <strong>Operations Managers</strong> are tasked with “keeping the lights on” — ensuring consistent service performance across systems.</li><li>💻 <strong>Application/Infrastructure Owners</strong> focus on ensuring their systems meet uptime SLAs — a bottom-up approach to support org-wide resilience.</li><li>🧑‍💻<strong>Developers/Admins/Devops Team</strong> has day to day activities for building, deploying, releasing &amp; monitoring the solution they have build and it meets the resiliency requirement of the application.</li></ul><h3>Resiliency: Designed, Not Enforced</h3><p>Resiliency isn’t like a firewall or a password policy. You <strong>can’t enforce it with a toggle</strong>. It’s <strong>architected</strong>, <strong>communicated</strong>, and <strong>tested</strong> — and built into policies that reflect your organizational goals.</p><p>We talked about resiliency quite a few time in this post and tried to understand it but what is good way to define it with respect to IT:-</p><h3>What Does “Resiliency” Really Mean?</h3><p>Out of many definitions, one stands out:</p><blockquote><strong><em>“Resilience is the capacity to withstand or recover quickly from difficulties.”</em></strong></blockquote><p>Why this one? Because it includes:</p><ul><li>🧱 <strong>Withstand</strong>: Design-time resilience — redundancy, failover logic, autoscaling, chaos testing, etc.</li><li>🔄 <strong>Recover</strong>: Runtime and procedural — backups, incident response, disaster recovery, runbooks.</li></ul><p>Another thing we can agree on is “ 100% resiliency is a myth”.</p><h3>Let’s Talk About the Myth of 100% Resilience</h3><p><strong>100% uptime is a myth.</strong> We love aiming for 99.999999%, but every extra “9” is exponentially expensive. For example:</p><ul><li><strong>99.9% uptime</strong> = ~8.76 hours/year downtime</li><li><strong>99.99%</strong> = ~52.56 minutes</li><li><strong>99.999%</strong> = ~5.26 minutes</li></ul><p>Each jump requires <strong>more infrastructure</strong>, <strong>more failover paths</strong>, and <strong>more budget</strong>.</p><h3>So… How Much Resilience Is Enough?</h3><p>This is where risk-based thinking comes in. Ask yourself:</p><ol><li><strong>What’s at risk if this goes down?</strong></li></ol><ul><li>Revenue?</li><li>Regulatory fines?</li><li>Customer trust?</li><li>Human life? — Human life does not have any dollar value attached and it is paramount.</li></ul><p><strong>2. What is the dollar value of the loss or risk realization?</strong></p><ul><li>Downtime of a public facing app ≠ downtime of an internal HR tool</li></ul><p>There would be many other questions but above two fundamental questions are good starting points. These questions help decide <strong>how many 9s</strong> you need — and what you’re willing to pay for them. As discussed earlier you have to spend good amount of money to buy each <strong>9</strong>, it is not cheap. And this makes a good Segue for next section i.e. how to build resilient apps/infra.</p><h3>Complexity = Fragility (If Not Designed Right)</h3><p>Let’s walk through a simple real-world example. Imagine a <strong>single-tier application</strong> hosted in a datacenter and accessed only by internal staff. It’s a critical app with high business value (I’ll skip the discussion on “number of nines” to keep things simple).</p><p>From a resiliency standpoint, here’s what we initially need to consider:</p><ol><li><strong>Hosting</strong> — is the datacenter robust and redundant?</li><li><strong>Server infrastructure</strong> — are there failover mechanisms in place?</li><li><strong>Application stability</strong> — can it handle crashes or errors gracefully?</li><li><strong>Network reliability</strong> — is the internal network resilient?</li><li><strong>DNS reliability</strong> — can the app still be reached if DNS fails?</li></ol><p>Since it’s an internal app, internet resilience isn’t a concern — assuming the corporate office is connected to the datacenter via a private link.</p><p>But now let’s say the business grows, and suddenly <strong>remote access</strong> is required. The app must be exposed via <strong>Secure Web Gateways (SWG)</strong>. Now, we need to worry about resiliency with :-</p><ol><li><strong>Internet connectivity</strong></li><li><strong>Gateway redundencies, and access policies</strong></li><li><strong>may be other things as well</strong></li></ol><p>Fast forward a bit: the application must now be <strong>publicly accessible</strong>, and for better performance, the business decides to put it behind a <strong>CDN</strong>. That’s a great decision — CDNs improve speed and availability — but also bring new complexity.</p><p>As this application moves from internal-only to externally accessible, <strong>security and resiliency needs multiply</strong>. We now need WAF, Unified Threat Management (UTM) systems, distributed DNS, and more.</p><p>So it means we now need to look at resiliency of :-</p><ol><li>Security solutions</li><li>CDN</li><li>Other complexities introduced</li></ol><p>Here’s the critical insight:<br> <strong>Every new solution introduced adds a new potential point of failure.</strong><br> Each improvement must be evaluated through a resiliency lens, and that has real cost implications. What was once a straightforward setup now demands layered protections and fallback mechanisms — each with its own risks and maintenance overhead.</p><h3>Resiliency Must Be Part of Enterprise Architecture</h3><p>Resilience should not be an afterthought. When someone suggests a new feature, system, or provider, it must be viewed through a <strong>resilience lens</strong>:</p><blockquote><em>“If we add this, how does it affect our availability risk?”</em></blockquote><p>Ignoring this leads to unplanned outages, finger-pointing, and unbudgeted fire drills.</p><h3>Prioritize Your Resilience Investments</h3><p>Budgets are not infinite. So how do you prioritize?</p><p>As discussed earlier, <strong>resilience comes at a cost</strong> — and no one has an unlimited budget. That’s why <strong>prioritization is key</strong>. But how do we decide what to prioritize?</p><p>We start by <strong>analyzing resiliency risks</strong>, which involves understanding two things:</p><ol><li>The <strong>impact</strong> of a failure</li><li>The <strong>likelihood</strong> of that failure occurring</li></ol><p>Take a typical micro services application, for example — running on Kubernetes, protected by a security solution, and accelerated via a CDN.</p><p>Let’s look at the risks first. I know it is not a exhaustive list and point here is not to show one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LkSpaij2qKzhFlTsZICxRw.jpeg" /></figure><p>Let’s categorize risk. Again i want to emphasize the likelihood and impact are quite subjective and it varies from one organization to other. Idea here is not to discuss about why something is for high impact and likelihood but just to see it from reperesnetation perspective and how data can be used for decision making.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3nLCANW94fJvHsx2IU_H6Q.jpeg" /></figure><p>Another way is to assign numbers(we all love numbers)or even better a dollar value to impact and then represent risk level as numbers so that we have clear priority list.</p><p>For e.g. something like below:- Again point here is not to discuss why one risk is rated higer than other as every organization would have different risk level as these risks are many time not only due to IT but kind of business you are doing. Also likelihood to impact also consider if you already have some kind of control in place which you are fairly confident of.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jao0GvGS70j-2rhEPCTC4A.jpeg" /></figure><h3><strong>Why an Outside-In View Is Critical for Resilience</strong></h3><p>By now, it should be clear that building for resiliency is a monumental task — one that requires contributions from nearly everyone in the organization. It’s crucial to get an external perspective on resiliency. Why? Because we all naturally carry biases toward our own solutions, which can make it difficult to identify weaknesses in our architecture. That said, internal knowledge remains invaluable.</p><p>One of the most effective starting points is to engage an experienced vendor to conduct a resiliency workshop. But for such a workshop to succeed, three things are essential:</p><ol><li>a willingness to have open, honest discussions</li><li>having the right people in the room.</li><li>Needless to say, having executive sponsorship acts as a critical enabler for driving meaningful outcomes.</li></ol><p>One important lesson I’ve learned from resiliency discussions with customers is this: <em>“Let’s keep the solution out of the room.”</em></p><p>The goal is to focus on identifying risks, potential impacts, and failure points — without jumping to solutions. As someone with a consulting background, I understand how tempting it is to dive straight into solving the problem, but doing so too early can actually distract from the task at hand: uncovering the real issues first.</p><p>Please note that many large scale enterprise do the full Business Continuity/Disaster Recovery (BC/DR) review as part of their resiliency practice.</p><p>BC/DR review looks at all business/applications of an organisation from top down view, assign dollar value to loss incurs if a business/application is inaccessible. Dollar value assignment considers both tangible and non-tangible losses. Than depending upon importance of an application(based on losses), an organization can prioritize the BC/DR activity.</p><h3>Conclusion: Resiliency Is a Journey, Not a Checkbox</h3><p>Resiliency isn’t a feature you can toggle on — it’s a mindset and a continuous process. It spans technology, people, and processes, and requires thoughtful investment, prioritization, and collaboration. As we’ve seen, each layer of a system introduces potential failure points, and every improvement adds complexity.</p><p>The key is not to eliminate all risk — that’s impossible — but to understand and manage it effectively. By analyzing impact and likelihood, building layered protections, and engaging in open, cross-functional discussions (preferably with external perspective), organizations can make informed decisions that balance cost and continuity.</p><p>Ultimately, resilience is about preparation: not just for what might go wrong, but for how quickly and effectively you can respond when it does.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9a2c612ea46" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Automating Akamai EdgeWorker Deployments with GitHub Actions]]></title>
            <link>https://deepakjd2004.medium.com/automating-akamai-edgeworker-deployments-with-github-actions-e7496a839202?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7496a839202</guid>
            <category><![CDATA[akamai]]></category>
            <category><![CDATA[edge-worker]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[akamai-edgeworkers]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Thu, 10 Apr 2025 00:16:08 GMT</pubDate>
            <atom:updated>2025-04-10T00:32:27.315Z</atom:updated>
            <content:encoded><![CDATA[<p>As part of a modern serverless and edge-native architecture, <strong>Akamai EdgeWorkers</strong> allow you to execute logic at the edge — reducing latency and improving performance for end users.</p><p>In this post, I’ll walk you through how I’ve automated the <strong>build, upload, and activation</strong> of EdgeWorker code using <strong>GitHub Actions</strong>, with a practical example: <a href="https://github.com/deepakjd2004/akamai-ew-hello-world">akamai-ew-hello-world</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fLOk8XsuH4ei324hF3Tq4A.jpeg" /></figure><h3>🔧 Prerequisites</h3><p>To follow along or reuse this setup, you need:</p><ul><li>An Akamai EdgeWorker ID and group set up</li><li>Akamai CLI credentials with the right permissions</li><li>GitHub repository with your EdgeWorker code</li><li>GitHub Secrets set for authentication</li></ul><h3>📁 Project Structure</h3><p>Here’s a simplified view of my repo structure:</p><pre>akamai-ew-hello-world/<br>├── main.js            # EdgeWorker entry point<br>├── ew.json            # Metadata file with EdgeWorker ID/version<br>├── bundle.json        # Akamai packaging manifest<br>├── .github/<br>│   └── workflows/<br>│       └── deploy.yml # GitHub Actions workflow</pre><h3>⚙️ GitHub Secrets Required</h3><p>Set these in your repo under <strong>Settings &gt; Secrets and Variables &gt; Actions</strong>:</p><p><em>Please note that ASK or Account Switch Key is optional and needed for only Akamai employee or partners.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NUtat0YaU0QXkkspzEtqyw.jpeg" /></figure><h3>🛠️ What the Workflow Does</h3><p>Every time I push to the main branch (excluding .md files), the workflow:</p><ol><li><strong>Sets the version</strong> in ew.json and bundle.json based on the commit ID</li><li><strong>Installs</strong> Akamai CLI and the EdgeWorkers CLI plugin</li><li><strong>Packages</strong> the code into a .tgz bundle</li><li><strong>Uploads</strong> the bundle to Akamai</li><li><strong>Activates</strong> the version on <strong>Staging</strong> and <strong>Production</strong></li><li><strong>Waits</strong> until the Staging activation completes before promoting to Production</li></ol><p>Here’s the snippet that filters when the workflow runs:</p><pre>on:<br>  push:<br>    branches: [ main ]<br>    paths-ignore:<br>      - &#39;**/*.md&#39;<br>  pull_request:<br>    branches: [ main ]<br>    paths-ignore:<br>      - &#39;**/*.md&#39;<br>  workflow_dispatch:</pre><p>This ensures we ignore deployments when readme.md is modified — saving unnecessary builds when documentation changes.</p><h3>🔄 Sample Code Snippet</h3><p>Here’s a simplified version of how the version is dynamically injected:</p><pre>COMMIT_ID=$(git rev-parse --short HEAD)<br>cat ew.json | jq --arg version &quot;$COMMIT_ID&quot; &#39;.edgeworker.version = $version&#39; &gt; ew_updated.json<br>mv ew_updated.json ew.json</pre><p>This keeps your deployments traceable to a Git commit — super helpful for rollbacks or debugging.</p><h3>⏳ Wait for Staging Activation (Optional)</h3><p>To avoid race conditions or premature production pushes, I’ve added a loop that <strong>polls Akamai</strong> until the version is fully activated on Staging:</p><pre>while [ &quot;$STATUS&quot; != &quot;COMPLETE&quot; ]; do<br>  # check status via akamai edgeworkers list-activations ...<br>  sleep 30<br>done</pre><h3>📍 Repo Link</h3><p>🔗 <a href="https://github.com/deepakjd2004/akamai-ew-hello-world">GitHub Repo: akamai-ew-hello-world</a></p><p>Fork it or copy the .github/workflows/deploy.yml to bootstrap your own EdgeWorker project!</p><h3>💡 Closing Thoughts</h3><p>With this setup, you can:</p><ul><li>Push and deploy instantly to Akamai EdgeWorkers</li><li>Control activation flow from Staging to Production</li><li>Minimize CI costs by avoiding unnecessary workflow runs</li></ul><p>This has streamlined my dev workflow significantly — and I hope it helps you do the same.</p><h3>📬 Let’s Connect</h3><p>If you try this out, let me know! Feedback, forks, and feature requests are always welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7496a839202" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Git Accidents — Remove sensitive data from git history]]></title>
            <link>https://deepakjd2004.medium.com/git-accidents-remove-sensitive-data-from-git-history-6a1306610695?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a1306610695</guid>
            <category><![CDATA[bfg-repo-cleaner]]></category>
            <category><![CDATA[git-history]]></category>
            <category><![CDATA[sensitive-data]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Wed, 07 Jun 2023 00:07:38 GMT</pubDate>
            <atom:updated>2023-06-07T00:07:38.076Z</atom:updated>
            <content:encoded><![CDATA[<h3>Git Accidents — Remove sensitive data from git history</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QO0h5UHKANZyapTY" /><figcaption>Photo by <a href="https://unsplash.com/@timmossholder?utm_source=medium&amp;utm_medium=referral">Tim Mossholder</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever faced a scenario where you uploaded a file in public/private repo on git and later on realized that you should not have added it? For e.g. file containing some private or confidential information like password/PII/private key or file that is too big and is killing the performance?</p><p>Recognizing mistake is first step. Now that you have realized your mistake, you must be wondering about how to remove the private information from repo. You can easily remove it from current commit but what about all the commits that you have already done in past?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3LtWs4tPPT5hoW1_eOioSA.jpeg" /></figure><p>Thankfully git provide couple of option to deal with this situation.</p><p>But before going into different options, I would like to highlight that once your data is in up there in repo, even for few seconds, consider it as compromised. Now depending upon criticality of data you should take appropriate steps. Passwords are most critical and it is always recommended to change it once you suspect that it has been leaked(which in this case consider it has been leaked by the time you realized). If it is IP of your honeypot server or other servers in DMZ zone than you might not be worried about it too much, but in some cases you still want to remove its references from public repo.</p><p>Let’s talk about options to remove private information/file from all commits till date in repo.</p><ol><li><a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository">git filter-repo</a></li><li><a href="https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository">BFG Repo-Cleaner</a></li></ol><p>I found both the tools useful but in this post I am going to talk about BFG in particular since i found it easy and fast.</p><p>Lets start with installing BFG Repo-Cleaner. I am running my example on mac. For installation instructions on other system see this <a href="https://rtyley.github.io/bfg-repo-cleaner/">link</a></p><p>I used brew to install BFG Repo-Cleaner</p><pre>brew install bfg</pre><p>Once installed check if bfg command line is working — run command “bfg help”</p><pre>bfg help<br>bfg 1.14.0<br>Usage: bfg [options] [&lt;repo&gt;]<br><br>  -b, --strip-blobs-bigger-than &lt;size&gt;<br>                           strip blobs bigger than X (eg &#39;128K&#39;, &#39;1M&#39;, etc)<br>  -B, --strip-biggest-blobs NUM<br>                           strip the top NUM biggest blobs<br>  -bi, --strip-blobs-with-ids &lt;blob-ids-file&gt;<br>                           strip blobs with the specified Git object ids<br>  -D, --delete-files &lt;glob&gt;<br>                           delete files with the specified names (eg &#39;*.class&#39;, &#39;*.{txt,log}&#39; - matches on file name, not path within repo)<br>  --delete-folders &lt;glob&gt;  delete folders with the specified names (eg &#39;.svn&#39;, &#39;*-tmp&#39; - matches on folder name, not path within repo)<br>  --convert-to-git-lfs &lt;value&gt;<br>                           extract files with the specified names (eg &#39;*.zip&#39; or &#39;*.mp4&#39;) into Git LFS<br>  -rt, --replace-text &lt;expressions-file&gt;<br>                           filter content of files, replacing matched text. Match expressions should be listed in the file, one expression per line - by default, each expression is treated as a literal, but &#39;regex:&#39; &amp; &#39;glob:&#39; prefixes are supported, with &#39;==&gt;&#39; to specify a replacement string other than the default of &#39;***REMOVED***&#39;.<br>  -fi, --filter-content-including &lt;glob&gt;<br>                           do file-content filtering on files that match the specified expression (eg &#39;*.{txt,properties}&#39;)<br>  -fe, --filter-content-excluding &lt;glob&gt;<br>                           don&#39;t do file-content filtering on files that match the specified expression (eg &#39;*.{xml,pdf}&#39;)<br>  -fs, --filter-content-size-threshold &lt;size&gt;<br>                           only do file-content filtering on files smaller than &lt;size&gt; (default is 1048576 bytes)<br>  -p, --protect-blobs-from &lt;refs&gt;<br>                           protect blobs that appear in the most recent versions of the specified refs (default is &#39;HEAD&#39;)<br>  --no-blob-protection     allow the BFG to modify even your *latest* commit. Not recommended: you should have already ensured your latest commit is clean.<br>  --private                treat this repo-rewrite as removing private data (for example: omit old commit ids from commit messages)<br>  --massive-non-file-objects-sized-up-to &lt;size&gt;<br>                           increase memory usage to handle over-size Commits, Tags, and Trees that are up to X in size (eg &#39;10M&#39;)<br>  &lt;repo&gt;                   file path for Git repository to clean</pre><p>Clone a fresh copy of your repo with — — mirror flag</p><pre>git clone --mirror git@github.com:deepakjd2004/xxxxxx.git<br><br>Cloning into bare repository &#39;xxxxxxx.git&#39;...<br>remote: Enumerating objects: 77, done.<br>remote: Counting objects: 100% (77/77), done.<br>remote: Compressing objects: 100% (47/47), done.<br>remote: Total 77 (delta 15), reused 69 (delta 10), pack-reused 0<br>Receiving objects: 100% (77/77), 45.04 KiB | 217.00 KiB/s, done.<br>Resolving deltas: 100% (15/15), done.</pre><p>I encourage you to peek inside the newly downloaded directory. You will see that it does not consist of normal files from your repo but it is full copy of git database for your repo, take backup of this full copy for safety.</p><p>In my case I am going to replace every occurrence of ssh_key with **Removed** and this needs to happen across all commits. For all the possible options with bfg tool please look <a href="https://rtyley.github.io/bfg-repo-cleaner/">here</a></p><p>In the current directory, use editor of your choice to create a file with any name and put text you want to replace with **Removed**. I am calling my file as search-replace.txt. For e.g.</p><pre>cat search-replace.txt<br>Q9/KOf2ze1E06qUF2mLPwX5y6dTMCKGkkV+HDQlIp/F0ZTfWIQ9/KOf2ze1E06qUF2mLPwX5y6dTMCKGkkV+HDQlIp/F0ZTfWIQ9/KOf2ze1E06qUF2mLPwX5y6dTMCKGkkV+HDQlIp/F0ZTfWI</pre><p>Run below command to update your commits and all branches and tags so they are clean, but it doesn’t physically delete the unwanted stuff.</p><pre>bfg --replace-text search-replace.txt xxxxxxxx.git</pre><p>Above command will generate a report in current folder. You can examine the report to make sure that it is going to make changes that you intend to do.</p><p>Next, go to cloned directory (that you did with — mirror flag)</p><pre>cd xxxxx.git</pre><p>Run below command to examine the repo and make sure your history has been updated, and then use the standard <a href="https://git-scm.com/docs/git-gc">git gc</a> command to strip out the unwanted dirty data, which Git will now recognize as surplus to requirements.</p><pre>git reflog expire --expire=now --all &amp;&amp; git gc --prune=now --aggressive<br><br>Enumerating objects: 78, done.<br>Counting objects: 100% (78/78), done.<br>Delta compression using up to 12 threads<br>Compressing objects: 100% (58/58), done.<br>Writing objects: 100% (78/78), done.<br>Reusing bitmaps: 8, done.<br>Building bitmaps: 100% (9/9), done.<br>Total 78 (delta 16), reused 53 (delta 0)<br>Computing commit graph generation numbers: 100% (9/9), done.</pre><p>Once you are happy then do the git push</p><pre>git push</pre><p>Now go back into your repo and check if confidential data is removed from all commits. For future make sure to add any sensitive file in .gitignore file or manually scrub the sensitive information before uploading.</p><p><em>Also you should note that if the commit that introduced the sensitive data exists in any forks of your repository, it will continue to be accessible, unless the fork owner removes the sensitive data from their fork or deletes the fork entirely. You cannot remove sensitive data from other users’ clones of your repository, but you can permanently remove cached views and references to the sensitive data in pull requests on GitHub by contacting </em><a href="https://support.github.com/contact?tags=docs-generic"><em>GitHub Support</em></a><em>.</em></p><p>Thanks for reading the article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a1306610695" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Your Own (BYO)Autoscaling Solution using Open Source Tools on Akamai’s cloud computing…]]></title>
            <link>https://deepakjd2004.medium.com/build-your-own-byo-autoscaling-solution-using-open-source-tools-on-linode-a05f70678c26?source=rss-6ec22037447------2</link>
            <guid isPermaLink="false">https://medium.com/p/a05f70678c26</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[jenkins-pipeline]]></category>
            <category><![CDATA[linode]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[autoscaling]]></category>
            <dc:creator><![CDATA[Deepak]]></dc:creator>
            <pubDate>Tue, 06 Jun 2023 06:37:35 GMT</pubDate>
            <atom:updated>2023-07-26T03:51:49.807Z</atom:updated>
            <content:encoded><![CDATA[<h3>Build Your Own (BYO)Autoscaling Solution using Open Source Tools on Akamai’s cloud computing services(Linode)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tlvwUJMO6firKGr5" /><figcaption>Photo by <a href="https://unsplash.com/ja/@aggergakker?utm_source=medium&amp;utm_medium=referral">Jesper Aggergaard</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Autoscaling is the process of dynamically allocating resources to match performance requirements. As the volume of work grows, an application may need additional resources to maintain the desired performance levels and satisfy service-level agreements (SLAs).</p><p>In this post I am going to talk about how you can Build Your Own (BYO) autoscaling solution using open source tools on Akamai’s cloud computing services (<em>Disclaimer — At the time of writing this article I am proudly working for Akamai Technologies</em>), previously called as Linode( why Linode? 🤔true it can be any other cloud or even on-premises but i am going to use Linode because of its developer friendliness and ease to use). You may also ask why building an autoscaling solution when cloud providers already have it? or more likely why do we need this in microservices era(world of <a href="https://kubernetes.io/">Kubernetes</a>)? Fair enough, let me try to answer some of these:-</p><ol><li>Not all public cloud provider provides autoscaling solution. Most of hyperscalers does provide but how much are we paying for it? Nothing comes for free, you might have heard of numerous stories about how cost on hyperscalers spiral and go off the roof. What about clouds where you do not have autoscaling ? or your on-premises infrastructure where admins are still adding servers manually whenever they see alert on dashboard</li><li>Flexibility — You always have to play by cloud provider rules i.e. autoscaling based on CPU, memory or other predefined parameter. Can you autoscale based on application specific parameters, maybe threads?</li><li>Kubernetes — Not all applications are suited for microservices architecture but that doesn’t mean that they don’t need autoscaling.</li></ol><p>Let’s see what we are gonna build in this post.</p><p>Simply put we want to create an automation engine that would scale infrastructure based on servers load profile.</p><p>In our solution we are going to have 3 major pillars —</p><ol><li>Observability Stack — Consisting of Grafana, Prometheus and node-exporter to monitor our infrastructure</li><li>Application Stack — Basically servers/apps that we are gonna monitor using observability stack</li><li>Automation or autoscaling engine — Built using Jenkins pipeline</li></ol><p>Architectures are great way of visualizing the system before its incarnation. Here is our simplistic architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DkRfWoaX9BOXJUI0iY_XfA.jpeg" /><figcaption>High Level Architecture</figcaption></figure><p>We are going to use few open source tools for building our own autoscaling solution, so lets understand these components in brief.</p><ol><li>We have group of servers under App stack — These are the VM’s that we would like to monitor and autoscale based on trigger definition.</li><li>Prometheus Stack — An open-source monitoring system with a dimensional data model, flexible query language, efficient time series database and modern alerting approach. We are going to use it for monitoring our App Stack. More about Prometheus<a href="https://prometheus.io/"> here</a> . Within Prometheus stack we have below sub components:-</li></ol><p>a) Node Exporter — Prometheus exporter for hardware and OS metrics exposed by *NIX kernels, written in Go with pluggable metric collectors. Think of it as an agent that will sit on VM’s to be monitored and communicate with Prometheus server.</p><p>b) Alert Manager — The Alertmanager handles alerts sent by client applications such as the Prometheus server. It takes care of deduplicating, grouping, and routing them to the correct <a href="https://prometheus.io/docs/alerting/latest/configuration/#receiver">receiver integrations</a> such as email, PagerDuty, OpsGenie, or many other <a href="https://prometheus.io/docs/operating/integrations/#alertmanager-webhook-receiver">mechanisms</a> thanks to the web-hook receiver.</p><p>3. Grafana Stack — Grafana is a multi-platform open source analytics and interactive visualization web application. It provides charts, graphs, and alerts for the web when connected to supported data sources. In our solution we are ingesting logs collected by Prometheus to Grafana server for visualization and further act as trigger mechanism for initiating our Jenkins Pipeline to scale VM’s(add or remove VM’s).Within Grafana we will write our alerts to trigger Jenkins pipeline using webhooks, more on it in later section.</p><p>4. Jenkins — Jenkins is an open source automation server. It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration and continuous delivery. We are going to use Jenkins to add and remove servers from our app stack based on alert raised by Grafana system(which in turn relies on monitoring data collected from app servers via. Prometheus stack)</p><p>Another important parts of our project are :-</p><ol><li>Akamai’s cloud computing services — <strong>Linode</strong> is an awesome alternate cloud provider that focuses on Linux workloads. More about Linode <a href="https://www.linode.com/">here</a> . We are going to use Linode for hosting our end to end solution. You may also sign up and get $100 credit which would be more than enough if you want to try out this solution.</li><li>Ansible — Ansible is a radically simple IT automation system. It handles configuration management, application deployment, cloud provisioning, ad-hoc task execution, network automation, and multi-node orchestration. More about Ansible <a href="https://www.ansible.com/">here</a>. In our project we are going to use Ansible heavily for automation of:-</li></ol><p>a) Provisioning Linodes</p><p>b) Deploying Prometheus, Grafana, alert manager and node-exporter</p><p>c) Configuring various part of our solution.</p><p>Please note that I already have running instance of Jenkins that I am going to reuse for building pipeline but if you would like to create one then please feel free to do so by either using <a href="https://www.linode.com/marketplace/apps/linode/grafana/">one click app on Linode</a> or use ansible to do it.</p><p><em>Note — Please note that I am fully aware that in production environment you most probably run your app stack behind a load balancer(nodebalancer in Linode) but for sake of simplicity I am not using it here. But it is very much possible to provision node balancer using ansible and attach provisioned VM’s to it.</em></p><p>Let’s jump into real action ... You can clone my GitHub repo from here — <a href="https://github.com/deepakjd2004/BYO-Autoscaling">https://github.com/deepakjd2004/BYO-Autoscaling</a></p><p>Step 1 — I will start by showing my repo structure</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/586/1*x_XICWRpNiAJPUgMP4oCYg.jpeg" /></figure><p>I will describe the important file/folder. If you are already familiar with Ansible then you would have easily guessed what each folder might contain, if so then please feel free to skip this step, else please follow along.</p><p>a) env — I am going to use virtualenv for running my ansible code. Virtualenv is great way to isolated Python environments. You may run it without virtualenv.</p><p>b) Roles — Roles provide a framework for fully independent, or interdependent collections of variables, tasks, files, templates, and modules. We have to deploy 4 different types of applications, namely Prometheus, Grafana, node-exporter and alertmanager. For each application we would have one role. Each role would have its own handler, variable, templates etc. If you would like to know more about how role works then check <a href="https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_reuse_roles.html">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/456/1*BzoFj4uPBugce3xCC24GAw.jpeg" /><figcaption>roles</figcaption></figure><p>c) deployment.yml — this is the main deployment file that contains detail about provisioning Linodes, installing components (like Prometheus, node-exporter, alertmanager and grafan) and configuring them as needed. Here is the deployment.yml</p><pre>---<br>- name: create linodes<br>  hosts: localhost<br>  vars_files:<br>    - vars<br>    - secret_vars<br>  vars:<br>    labels:<br>      - prometheus<br>      - grafana<br>      - node_exporter<br>  tasks:<br>    - name: Create Linodes for hosting services<br>      include_tasks: create_linode.yml<br>      loop: &quot;{{ labels }}&quot;<br>      loop_control:<br>        loop_var: label<br><br>- name: install and configure prometheus<br>  hosts: prometheus<br>  user: root<br>  roles:<br>    - alertmanager<br>    - prometheus<br><br>- name: install and configure node_exporter<br>  hosts: all<br>  user: root<br>  roles:<br>    - prometheus_node_exporter<br><br>- name: install and configure grafana<br>  hosts: grafana<br>  user: root<br>  roles:<br>    - grafana</pre><p>Above code is self explanatory but let me touch on important sections:-</p><p>In tasks section, i am calling create_linode.yml(file for provisioning Linode, we will check this file later) for provisioning Grafana, Prometheus and node_exporter server. Once Linodes are provisioned then I am installing and configuring Prometheus, node_exporter(on all nodes) and Grafana on server as identified by labels.</p><p>Here is the content of create_linode.yml</p><pre>---<br>- name: Create Linode for hosting {{ label }}<br>  linode.cloud.instance:<br>    label: &quot;{{ label }}&quot;<br>    api_token: &quot;{{ token }}&quot;<br>    type: &quot;{{ type }}&quot;<br>    region: &quot;{{ region }}&quot;<br>    image: &quot;{{ image }}&quot;<br>    root_pass: &quot;{{ root_pass }}&quot;<br>    authorized_keys: &quot;{{ ssh_keys }}&quot;<br>    private_ip: true<br>    group: &quot;{{ group }}&quot;<br>    state: present<br>  register: linode<br><br>- name: Get info about an instance by {{ label }}<br>  linode.cloud.instance_info:<br>    api_token: &quot;{{ token }}&quot;<br>    label: &quot;{{ label }}&quot;<br>  register: info<br><br>- name: Set facts<br>  set_fact:<br>    node1: &quot;{{ info.instance.label }}&quot;<br>    node_ip1: &quot;{{ info.instance.ipv4[0] }}&quot;<br>    node_priv1: &quot;{{ info.instance.ipv4[1] }}&quot;<br><br>- name: Update inventory<br>  blockinfile:<br>    path: ./hosts<br>    marker: &quot;# {mark} {{ label }}&quot;<br>    block: |<br>      [{{ label }}]<br>      {{ hostvars[inventory_hostname][&#39;node_ip1&#39;] }}</pre><p>I am using Ansible Linode module to provision Linodes and also updating inventory (hosts) with ip address so that we can use it for configuring various component of our solution.</p><p>Step 2 — Prepare your developer machine by installing pre-requisites.</p><p>a) Install python3, pip if not already done so</p><p>b) Install Virtualenv if you don’t already have it. Virtualenv can be installed following this <a href="https://virtualenv.pypa.io/en/latest/installation.html">doc</a>. If you would not like to execute this project from virtualenv, this is also absolutely fine, just ignore step (b).</p><p>c) Activate Virtualenv and install some packages that we are gonna use.</p><pre>source venv/bin/activate<br>pip install -r requirements.txt</pre><p>requirement.txt you would find in project repo here — <a href="https://github.com/deepakjd2004/BYO-Autoscaling/blob/main/requirements.txt">https://github.com/deepakjd2004/BYO-Autoscaling/blob/main/requirements.txt</a></p><p>Main package that we are installing here are:-</p><p>Linode API — for provisioning Linodes</p><p>Ansible — for automation</p><p>d) During provisioning of Linode you would need to supply root password( we have variablized it in create_linode.yaml and passed it via secret_vars file). But we don’t want to expose our real password in text file. For hiding our secrets we are going to use ansible vault. You can learn about ansible vault <a href="https://docs.ansible.com/ansible/latest/vault_guide/index.html">here.</a></p><p>First setup your vault password in .vault-pass file in home directory(again it can be stored anywhere, you just need to mention its location in ansible.cfg file). Run below commands to get token for your secrets using vault. We are going to use vault for protecting Linode API tokens and root password for Linodes VM.</p><pre>ansible-vault encrypt_string &#39;Pass0w0rd@123&#39; --name &#39;root_pass&#39;<br>ansible-vault encrypt_string &#39;this is linode api token&#39; --name &#39;token&#39;</pre><p>You can get Linode api token using this <a href="https://www.linode.com/docs/products/tools/api/get-started/">link</a></p><p>Once you have executed above command you need to copy token and root_pass into secret_vars file, something like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GYE97qu7q8acXfdbkvGcRg.jpeg" /></figure><p>e). Configure your ansible.cfg file — Here is mine, it is self explanatory.</p><pre>[defaults]<br>host_key_checking = False<br>VAULT_PASSWORD_FILE = ./.vault-pass<br>enable_plugins = linode<br>inventory_path = ./hosts<br>interpreter_python = /usr/bin/python3<br>log_path = debug.log</pre><p>f) vars file — This is file used by create-linode.yml for provisioning our VM’s. Here is the code and it is also self explanatory</p><pre># linode vars<br>ssh_keys: ssh-rsa AAAAB3NzaC1yocal<br>prefix: app_node<br>cluster_name: POC<br>type: g6-nanode-1<br>region: ap-south<br>image: linode/debian10<br>group: app_node<br>linode_tags: app</pre><p>Now let’s move to next step, which is about deployment.</p><p>Step 3 — Deployment</p><p>(i) Run Ansible notebook to deploy Linodes vm &amp;install/configure Prometheus, Grafana and other components on respective Linodes vm</p><pre>ansible-playbook deployment.yml -i inventory</pre><p>You would see ansible-playbook being executed and output as below</p><pre>ansible-playbook deployment.yml -i inventory<br><br>PLAY [create linodes] *************************************************************************************************************************************************<br><br>PLAY [prometheus] *****************************************************************************************************************************************************<br><br>PLAY [node_exporter] **************************************************************************************************************************************************<br><br>PLAY [prometheus] *****************************************************************************************************************************************************<br><br>TASK [Gathering Facts] ************************************************************************************************************************************************<br>ok: [170.187.xxxx]<br><br>TASK [prometheus : config file] ***************************************************************************************************************************************<br>changed: [170.187.xxxx]<br><br>TASK [prometheus : alert config file] *********************************************************************************************************************************<br>changed: [170.187.xxx]<br><br>TASK [prometheus : Copy systemd init file] ****************************************************************************************************************************<br>changed: [170.187.230.210]<br><br>TASK [prometheus : Start prometheus service] **************************************************************************************************************************<br>changed: [170.187.xx]<br><br>TASK [prometheus : Check if prometheus is accessible] *****************************************************************************************************************<br>ok: [170.187.xxx]<br><br>RUNNING HANDLER [prometheus : Reload systemd] *************************************************************************************************************************<br>changed: [170.187.xxx]<br><br>PLAY [grafana] ********************************************************************************************************************************************************<br><br>TASK [Gathering Facts] ************************************************************************************************************************************************<br>ok: [139.177xxxx]</pre><p>If deployment fails at any particular step then you can fix and easily restart it from the failed step using below command.</p><pre>ansible-playbook deployment.yml -i inventory --start-at-task=&quot;&lt;task name from play&quot;</pre><p>Once ansible playbook executes successfully you would hopefully see that Linodes are provisioned and Prometheus, Grafana, alertmanager, node-exporter all installed. We will verify it in next step.</p><p>Step 4 — Verification — In this step we are going to check if all components are installed correctly.</p><p>a) Check Prometheus — Go to http://&lt;public_ip_of_promethus_server&gt;:9090/targets</p><p>If you are able to see all the three nodes i.e. Grafana, Prometheus and node-exporter, then we are good. Please note that we installed node-exporter on all Linode VM’s and thus they are sending logs to Prometheus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r-K7XxWfIgWr5-v1vtA-cA.jpeg" /></figure><p>b) Check if correct metrics are being emitted. — Go to each VM’s http://&lt;public_ip_of_each_VM&gt;:9100/metrics. You should see like below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cqeNsdQ5t0ADWxX1oEOY3w.jpeg" /></figure><p>c). Let’s check our Grafana Server —</p><p>Login into http://&lt;public_ip_of_grafana_vm&gt;:3000/</p><p>Username is admin and password(either you can use default or mention it in roles/grafana/vars/main.yml). You can also use vault to hide it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uXK5m2Ts_wFH08xfuoNkhQ.jpeg" /></figure><p>Login screen would guide you to add datasources and dashboard. Just follow the prompt and add your Prometheus datasource and start exploring the data. I also imported “Node Exporter Full with Node Name” dashboard to visualize the data. Here is screen grab of my dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*29EzTITmFW0T25yfpory9g.jpeg" /></figure><p>That’s good. We now have fully functional Prometheus, Grafana, alertmanager (verify it by going to http://&lt;public_ip_of_prometheus_vm&gt;:9090/alerts link) and node-exporter.</p><p>Step 5 — Integrate Grafana with Jenkins pipeline.</p><p>a) Lets first define alert in Grafana — for this project i want to create alert for monitoring my memory utilization of VM and fire alert when it reaches more than 75%.</p><p>Within Grafana UI → Home → Alerting → Alert Rules</p><p>Here is the screenshot of my configuration.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RerV2RRXOjbYVdZQlSuBvQ.jpeg" /></figure><p>Here is my data source query, pretty basic — node_memory_Active_bytes/node_memory_MemTotal_bytes*100</p><p>You can customize the rule as you need, their are many options that I am not going to touch base otherwise this post will never end.</p><p>b) Create Contact Points for web hook — Home → Alerting → Contact Points</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rICsG1NewGUsPNYzgxMucw.jpeg" /></figure><p>Select Webhook in integration block and URL is — <a href="http://jenkins_url/generic-webhook-trigger/invoke"><strong>http://JENKINS_URL/generic-webhook-trigger/invoke</strong></a></p><p>Replace JENKINS_URL with your Jenkins instance url.</p><p>For authenticating to your Jenkins instance you would have to pass username and token. For that first create a user in Jenkins and they add usename/password here. Within your Jenkins instance go to</p><p>Manage Jenkins → Security → Manage Users and create a user.</p><p>If you want to test the integration then you may create a dummy pipeline in Jenkins and create a alert to see if jenkins pipeline gets triggered or not.</p><p>c) Lets create our Jenkins Pipeline —My Jenkinfile is quite simple and as below:-</p><p>Please note that I used linode-cli in below code for provisioning Linode within pipeline. But you can use Ansible as well within pipeline to be consistent in using tools.</p><pre>def linodeId = &quot;&quot;<br>def linodeStatus = &quot;&quot;<br>pipeline {<br>    agent any<br><br>    environment {<br>        LINODE_CLI_TOKEN = credentials(&#39;linode-cli-token&#39;)<br>        ROOT_PASS = credentials(&#39;linode-root-pass&#39;)<br>    }<br><br>    stages {<br>        stage(&#39;Infrastructure Check&#39;) {<br>            steps {<br>                sh &quot;linode-cli linodes list&quot;<br>            }<br>        }<br><br>        stage(&#39;Provision&#39;) {<br>            steps {<br>                script {<br>                    linodeId = sh(<br>                        script: &quot;linode-cli linodes create --root_pass $ROOT_PASS --region ap-south --image linode/debian10 --type g6-nanode-1 --json&quot;,<br>                        returnStdout: true<br>                    ).trim()<br><br>                    // Extract the Linode ID from the JSON response<br>                    linodeId = linodeId.replaceAll(&#39;\\[|\\]&#39;, &#39;&#39;).split(&#39;,&#39;)[0].split(&#39;:&#39;)[1].trim()<br><br>                    echo &quot;Linode ID: ${linodeId}&quot;<br><br>                    // Wait for Linode creation to complete<br>                    timeout(time: 2, unit: &#39;MINUTES&#39;) {<br>                     //   def linodeStatus = &quot;&quot;<br><br>                        // Loop until the Linode is running or the timeout is reached<br>                        while (linodeStatus != &#39;[running]&#39;) {<br>                            def linodeInfo = sh(<br>                                script: &quot;linode-cli linodes view ${linodeId} --json&quot;,<br>                                returnStdout: true<br>                            ).trim()<br><br>                            // Parse the JSON response and extract the status field<br>                            echo &quot;${linodeInfo}&quot;<br>                            def statusField = readJSON(text: linodeInfo).status<br>                            echo &quot;${statusField}&quot;<br>                            linodeStatus = statusField ? statusField.toString().toLowerCase() : &quot;&quot;<br>                            echo &quot;${linodeStatus}&quot;<br><br>                            if (linodeStatus != &#39;[running]&#39;) {<br>                                sleep time: 10, unit: &#39;SECONDS&#39;<br>                            }<br>                        }<br>                    }<br><br>                    echo &#39;Linode creation completed&#39;<br>                }<br>            }<br>        }<br><br>               stage(&#39;Verify&#39;) {<br>            steps {<br>                script {<br>    <br>                    if (linodeStatus == &#39;[running]&#39;) {<br>                        echo &#39;Linode is running, verification successful&#39;<br>                    } else {<br>                        error &#39;Linode is not running, verification failed&#39;<br>                    }<br>                }<br>            }<br>        }<br><br>        stage(&#39;Deprovision&#39;) {<br>            steps {<br>                sh &quot;linode-cli linodes delete ${linodeId}&quot;<br>            }<br>        }<br>    }<br>}</pre><p>Pipeline code is quite straightforward , it starts by defining couple of variables that we want to use across multiple stages of pipeline, next we have defined few secrets in Jenkins and are referencing it back in our pipeline using environments section.</p><p>Next, we have 3 stages in the pipeline</p><p>Stage 1- Infrastructure Check — making sure that we have Linode CLI installed on Jenkins server.</p><p>Also as we are using readJSON() function so please make sure that you have <a href="https://plugins.jenkins.io/pipeline-utility-steps/">https://plugins.jenkins.io/pipeline-utility-steps/</a> plugin installed on your jenkins instance.</p><p>Stage 2 — Provisioning — Here we are using Linode cli to create new instance and wait till it comes in running state.</p><p>Stage 3 — Verification — Basically checking if newly provisioned Linode VM is up and running</p><p>Stage 4 — De-provisioning — you most probably won’t need it but i didn’t want to spin off ten’s of VM during my testing so i added this stage to delete VM’s.</p><p>d) Create your pipeline. — Within Jenkins UI, create new “multi branch pipeline” and name it appropriately.</p><p>Within pipeline → Build Trigger, make sure that you checked “Generic Webhook Trigger”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vaq1IK4hLINLt3EBikURXQ.jpeg" /></figure><p>e) Copy/paste jenkinfile created in step c in pipeline definition section.</p><p>Step 6. — Run some script to generate load on one of monitored VM to generate alert and see your pipeline running and VM getting provisioned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*agQXLK9SVD2FKuWJnpIwWg.jpeg" /></figure><p>What‘s next? — Actually a lot, I agree that it will take lot more to make this enterprise class or production ready solution but i am sure it can be achieved. Purpose of this demo project is to show how we can scale up and down automatically using open source tools.</p><p>If you are reading this line then kudos for reaching the very end of this story and thank you for reading. I hope you learned something today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a05f70678c26" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>