<?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 Ayodhya Dayananda on Medium]]></title>
        <description><![CDATA[Stories by Ayodhya Dayananda on Medium]]></description>
        <link>https://medium.com/@ayodhya.dayananda?source=rss-79ea8108de82------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*LV9wjme-ktikICmRKsyRkQ.jpeg</url>
            <title>Stories by Ayodhya Dayananda on Medium</title>
            <link>https://medium.com/@ayodhya.dayananda?source=rss-79ea8108de82------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 03:50:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ayodhya.dayananda/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[Building Vulcan AI Part 1: Teaching AI to Recognize Sapphire]]></title>
            <link>https://medium.com/@ayodhya.dayananda/building-vulcan-ai-part-1-teaching-ai-to-recognize-sapphire-32539a614731?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/32539a614731</guid>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[gemology]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[gemstone]]></category>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Fri, 02 Oct 2026 11:10:36 GMT</pubDate>
            <atom:updated>2026-10-02T11:10:36.264Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Lh64aAE4fc9TspScMk353g.png" /></figure><h3>The first step toward an AI-assisted portable gemstone analyzer</h3><p>Gemstones are traded, collected, studied, and valued all over the world but identifying them correctly is not always simple.</p><p>Two stones can appear visually similar while belonging to completely different gem families. In many cases, reliable identification requires expert observation, multiple instruments, and sometimes laboratory testing. Questions such as whether a stone is natural or synthetic, heated or unheated, or what inclusions it contains are often far more complex than a photograph alone can answer.</p><p>That led me to a bigger idea:</p><blockquote><strong><em>Could we eventually build a portable AI-assisted device that collects multiple types of gemstone information and helps interpret them in a practical, trustworthy way?</em></strong></blockquote><p>That idea became <strong>Vulcan AI</strong>.</p><p>Vulcan AI is an experimental research project exploring how <strong>computer vision, microscopy, spectroscopy, and multimodal AI</strong> could eventually contribute to a portable gemstone analysis system.</p><p>The long-term goal is not to replace gemologists or gemological laboratories. Instead, the goal is to investigate whether AI can assist with early-stage gemstone assessment by combining evidence, expressing confidence, and recognizing when a stone should be referred for deeper expert analysis.</p><h3>Why a device like this matters</h3><p>The global gemstone industry depends heavily on trust, expertise, and accurate identification.</p><p>At the high end of the market, advanced testing already plays a critical role. But in many real-world situations from field sourcing and trading to preliminary screening and education access to specialized instruments and expert interpretation may be limited.</p><p>A future AI-assisted gemstone analyzer could be valuable because it would aim to:</p><ul><li>support faster preliminary gemstone assessment,</li><li>improve accessibility to technical analysis,</li><li>combine multiple signals rather than relying on a single image,</li><li>assist non-experts without pretending to replace expert judgment,</li><li>and most importantly, communicate uncertainty instead of forcing an answer.</li></ul><p>That last point is especially important.</p><p>A reliable system should be able to say:</p><blockquote><strong><em>Inconclusive further examination recommended.</em></strong></blockquote><p>That principle will remain central throughout the Vulcan AI project.</p><h3>The long-term vision for Vulcan AI</h3><p>The end goal is not a simple photo classifier.</p><p>The larger vision is a system where a gemstone can be analyzed using multiple forms of evidence, such as:</p><ul><li>standard visual imaging,</li><li>microscopic imaging,</li><li>Raman spectroscopy,</li><li>FTIR,</li><li>and other optical or spectral measurements.</li></ul><p>Those signals could then be combined through a multimodal AI system to produce:</p><ul><li>a probable identification,</li><li>a confidence score,</li><li>and a referral recommendation when the evidence is insufficient.</li></ul><p>In other words, the real vision is:</p><p><strong>Gemstone → multiple measurements → AI interpretation → result with confidence</strong></p><p>But that kind of system cannot be built all at once.</p><p>So I decided to start with the simplest layer first:</p><p><strong>image-based gemstone classification</strong></p><p>And for the first target, I chose <strong>sapphire</strong>.</p><h3>Why start with sapphire?</h3><p>Sapphire is a strong starting point for several reasons.</p><p>It is commercially important, globally recognized, and visually compelling but it is also challenging from a machine learning perspective because several gemstones can resemble sapphire in color and appearance.</p><p>That makes sapphire a useful first subject for testing an important question:</p><blockquote><strong><em>Can a computer vision model begin to learn meaningful visual differences between blue sapphire and similar-looking gemstones?</em></strong></blockquote><p>That question became the basis for <strong>Sapphire AI V1</strong>, the first experiment in the Vulcan AI series.</p><h3>Sapphire AI V1</h3><p>Sapphire AI V1 is a deliberately limited first experiment.</p><p>It does <strong>not</strong> attempt to determine:</p><ul><li>natural vs synthetic,</li><li>heated vs unheated,</li><li>geographic origin,</li><li>or laboratory-grade gemstone identity.</li></ul><p>Instead, V1 focuses on a much narrower task:</p><blockquote><strong><em>Classifying blue sapphire and visually similar gemstones from standard images</em></strong></blockquote><p>For this version, I trained the model across <strong>eight gemstone classes</strong>:</p><ul><li>Aquamarine</li><li>Iolite</li><li>Kyanite</li><li>Sapphire Blue</li><li>Spinel</li><li>Tanzanite</li><li>Topaz</li><li>Zircon</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qlwltPLGInpPi-75PR2LXA.png" /><figcaption><em>Sample images from the eight gemstone classes used in Sapphire AI V1</em></figcaption></figure><h3>The dataset</h3><p>For this first experiment, I used a public gemstone image dataset and selected the eight classes most relevant to the sapphire classification problem.</p><p>The final split for the experiment included:</p><ul><li><strong>209 training images</strong></li><li><strong>53 validation images</strong></li><li><strong>33 held-out test images</strong></li></ul><p>This is a relatively small dataset, and that fact is important.</p><p>Small datasets are useful for building an initial proof of concept, but they also make it easier for a model to overfit and harder to draw strong real-world conclusions. Still, they are valuable for answering an early research question:</p><p><strong>Is there enough learnable visual signal here to justify moving forward?</strong></p><h3>The model</h3><p>For Sapphire AI V1, I used <strong>MobileNetV3 Small with transfer learning</strong>.</p><p>Transfer learning is useful because it allows a model to start from an existing visual understanding of general patterns such as shapes, edges, and textures, and then adapt that knowledge to a more specific task.</p><p>For this experiment, the overall pipeline was simple:</p><p><strong>Gemstone image → preprocessing → MobileNetV3 → 8-class prediction</strong></p><p>The model was trained using augmentation, class balancing, and a held-out validation process, with final evaluation performed on a separate test set.</p><h3>Training behavior</h3><p>One of the most useful results from this experiment did not come from the final accuracy alone — it came from observing the training pattern.</p><p>Training accuracy continued to improve as the model learned the dataset, eventually reaching a little above 80%. However, validation accuracy remained much lower, mostly around the 50–55% range.</p><p>That widening gap suggested <strong>overfitting</strong>.</p><p>In simple terms, the model was getting better at recognizing patterns in the training data, but not improving at the same rate on unseen validation data.</p><p>This is a very important lesson for the next version.</p><p>The solution is not just “train longer.”<br>The next version needs <strong>better data, more data, and stronger generalization</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kxq8wL90bUIyWKoHug0vug.png" /><figcaption><em>Training accuracy improved steadily, while validation accuracy plateaued, suggesting overfitting and limited generalization in V1</em></figcaption></figure><h3><strong>Caption:</strong> <em>Training accuracy improved steadily, while validation accuracy plateaued, suggesting overfitting and limited generalization in V1.</em></h3><h3>The first results</h3><p>On the held-out test set, Sapphire AI V1 achieved:</p><ul><li><strong>60.6% test accuracy</strong></li><li><strong>61.4% macro precision</strong></li><li><strong>60.0% macro recall</strong></li><li><strong>55.0% macro F1 score</strong></li></ul><p>These are not production-level results and that is completely fine.</p><p>The purpose of V1 was not to create a finished gemstone identification system. The purpose was to establish a real baseline and learn from it.</p><p>From that perspective, the experiment was successful.</p><p>It showed that the model was learning something meaningful, while also clearly revealing where it was failing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sy0Ph8QtagTOVUqbfBNBxw.png" /></figure><p><em>Summary of the Sapphire AI V1 training run and final evaluation metrics</em></p><h3>What happened with sapphire?</h3><p>The sapphire result was the most interesting part of the experiment.</p><p>In this small test set, the model correctly identified all four blue sapphire samples. That means sapphire recall was very high in this run.</p><p>But at the same time, sapphire precision was much lower.</p><p>Why?</p><p>Because several other gemstones were also predicted as sapphire.</p><p>This distinction matters.</p><p>It would be misleading to say:</p><blockquote><em>“The AI identifies sapphire perfectly.”</em></blockquote><p>That is <strong>not</strong> what V1 proved.</p><p>What V1 actually showed was more interesting and more useful:</p><blockquote><strong><em>The model appears able to detect sapphire-like visual characteristics, but it still struggles to distinguish sapphire reliably from some visually similar gemstones.</em></strong></blockquote><p>That is exactly the kind of problem an early experiment is supposed to reveal.</p><h3>Seeing the AI make decisions</h3><p>One of the most useful ways to understand the model is to look at how it behaves on unseen test images.</p><p>Some predictions were correct. For example, a blue sapphire test image was correctly identified as blue sapphire with strong confidence.</p><p>Other cases showed the model’s weaknesses:</p><ul><li>Iolite was classified as Kyanite</li><li>Spinel was classified as Kyanite</li><li>Zircon was classified as Aquamarine</li></ul><p>These errors are not something to hide they are part of the value of the experiment.</p><p>They tell us where the decision boundaries are weak and where the next version needs improvement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r0JCUyv38GoX0oFaBFPJVA.png" /><figcaption><em>Examples of Sapphire AI V1 predictions on gemstone images not used during training</em></figcaption></figure><h3>Understanding the mistakes</h3><p>The confusion matrix made the limitations even clearer.</p><p>Some classes were learned reasonably well, while others remained difficult.</p><p>That is expected in a small first version, especially when the visual similarity between classes is high and the dataset is limited.</p><p>The confusion matrix is important because it transforms the experiment from a simple score into a diagnostic tool.</p><p>It tells us:</p><ul><li>which classes are easy,</li><li>which classes are difficult,</li><li>and where future data collection should focus.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j3rZrYzQNECwuCABGTOU9w.png" /><figcaption><em>Confusion matrix for Sapphire AI V1, showing where the model succeeded and where gemstone classes were confused.</em></figcaption></figure><h3>What V1 taught me</h3><p>The biggest lesson from Sapphire AI V1 is not the accuracy number by itself.</p><p>The biggest lesson is that the experiment successfully exposed the real engineering challenges ahead.</p><p>V1 showed that:</p><ul><li>useful visual patterns can be learned,</li><li>a basic AI pipeline for gemstone classification works,</li><li>sapphire-like visual traits can be partially recognized,</li><li>small datasets lead to unstable generalization,</li><li>visually similar gemstones are a real challenge,</li><li>and image-based AI alone is not enough for full gemstone determination.</li></ul><p>That last point is especially important.</p><p>A photograph can help with visual classification, but it cannot by itself provide the full scientific evidence needed for questions like treatment detection, natural vs synthetic classification, or high-confidence gemological identification.</p><p>That is why Vulcan AI is being built as a series of experiments, not as a one-step claim.</p><h3>What comes next: Sapphire AI V1.1</h3><p>The next experiment will focus on improving the visual sapphire classifier before moving to more advanced gemological tasks.</p><p><strong>Sapphire AI V1.1</strong> will aim to:</p><ul><li>expand the dataset substantially,</li><li>include more difficult blue gemstone lookalikes,</li><li>improve data quality and consistency,</li><li>reduce false sapphire predictions,</li><li>improve generalization on unseen samples,</li><li>and build a stronger foundation for future work.</li></ul><p>This is the right next step.</p><p>Before a system can move toward spectroscopy, inclusions, treatment evidence, or hardware, it needs a more reliable visual baseline.</p><h3>The larger Vulcan AI journey</h3><p>Sapphire AI V1 is only the beginning.</p><p>Future parts of the project may move into:</p><ul><li>improved sapphire classification,</li><li>microscopic inclusion analysis,</li><li>Raman-based gemstone classification,</li><li>FTIR-supported treatment investigation,</li><li>multimodal AI,</li><li>and eventually portable device design.</li></ul><p>So this article is not a conclusion.</p><p>It is the starting point of a longer research and engineering journey.</p><p>And that is exactly why I wanted to document it from the beginning not only the good results, but also the limitations, the mistakes, and the lessons learned.</p><p>Because that is how real technical systems are built.</p><h3>GitHub</h3><p>The code, notebook, and project structure for this experiment are available here:</p><p><strong>GitHub:</strong> <a href="https://github.com/AyodhyaDayananda/vulcan-ai">https://github.com/AyodhyaDayananda/vulcan-ai</a></p><h3>Next in the series</h3><p><strong>Building Vulcan AI — Part 2: Improving Sapphire AI with V1.1</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32539a614731" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conversational Kafka with Azure OpenAI -Executive Proof of Concept]]></title>
            <link>https://medium.com/@ayodhya.dayananda/conversational-kafka-with-azure-openai-executive-proof-of-concept-26c17c5e2d11?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/26c17c5e2d11</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Thu, 02 Oct 2025 18:29:40 GMT</pubDate>
            <atom:updated>2025-10-02T18:29:40.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6yYQvhYynN-yDIjCsH-GZg.png" /></figure><h3>Introduction</h3><p>Operating distributed systems like <strong>Apache Kafka</strong> traditionally requires technical expertise and command-line operations. This proof of concept demonstrates how <strong>Azure OpenAI</strong> can transform Kafka into a <strong>conversational platform</strong>, allowing business leaders and architects to query and manage Kafka in plain English.</p><h3>Why It Matters</h3><ul><li><strong>Accessibility</strong> → Kafka insights become available without specialized skills.</li><li><strong>Faster Decisions</strong> → System details such as retention policies or replication health are surfaced instantly.</li><li><strong>Knowledge On-Demand</strong> → Critical concepts like ISR (In-Sync Replicas) are explained in context.</li><li><strong>Strategic AI Application</strong> → Embedding Azure OpenAI within infrastructure workflows enables smarter, more autonomous operations</li></ul><h3>Architecture Overview</h3><p>The proof of concept runs in a <strong>fully containerized environment</strong>:</p><ul><li><strong>Kafka + Zookeeper</strong> → Core messaging backbone.</li><li><strong>AI Backend (FastAPI + Azure OpenAI)</strong> → Interprets natural language queries, generates Kafka code, executes results.</li><li><strong>Frontend</strong> → Lightweight conversational interface for interaction.</li></ul><pre>User → Conversational UI → Azure OpenAI Agent → Kafka Cluster → Human-readable Results</pre><h3>Example Interactions</h3><ul><li><strong>User:</strong> list topics<br> <strong>AI:</strong> Available topics: []</li><li><strong>User:</strong> create a topic called test-topic with one-day retention<br> <strong>AI:</strong> Topic created successfully</li><li><strong>User:</strong> what is the retention period of test-topic<br> <strong>AI:</strong> Retention: 1.00 days (24.00 hours)</li><li><strong>User:</strong> what is ISR<br> <strong>AI:</strong> ISR refers to replicas fully synchronized with the leader and ready to take over in case of failure.</li></ul><h3>Screenshots</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NzCFqaC27_1AgEoFrQ6hDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vhTMiSwOYMyfPHG0U1dyJA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xd8QDeu7XWqWnixtwM-3xQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_DyMWKHDpLXr1oT0vpUaQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XTf5E-RUyohiyGs0duJFig.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G-XkmFOxoZGLxleRKVyung.png" /><figcaption>Some spelling mistakes were introduced intentionally during prompts (e.g., ‘call’ instead of ‘called’, ‘periode’ instead of ‘period’) to test whether the AI assistant could still interpret and execute the request correctly.</figcaption></figure><h3>GitHub Repository</h3><p>Complete source code for this POC is available here:</p><p><a href="https://github.com/AyodhyaDayananda/kafka-insight-poc/tree/main">kafka-insight-poc</a></p><h3>Strategic Outlook</h3><p>This approach highlights the potential of <strong>AI-driven infrastructure operations</strong>. By embedding conversational AI into critical systems:</p><ul><li>Leaders gain <strong>transparent access to system states</strong>.</li><li>Architects see a path to <strong>self-explaining infrastructure</strong>.</li><li>Organizations move closer to <strong>autonomous AIOps</strong>.</li></ul><p>The key takeaway: <strong>AI is not just for analytics — it can become the interface for infrastructure itself.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26c17c5e2d11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OilBot Anomaly Detector: Building a Real-Time AI-Powered Sensor Anomaly Detection Pipeline with…]]></title>
            <link>https://medium.com/@ayodhya.dayananda/oilbot-anomaly-detector-building-a-real-time-ai-powered-sensor-anomaly-detection-pipeline-with-abd9cae9914e?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/abd9cae9914e</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Sun, 01 Jun 2025 15:03:00 GMT</pubDate>
            <atom:updated>2025-06-01T15:03:00.615Z</atom:updated>
            <content:encoded><![CDATA[<h3>OilBot Anomaly Detector: Building a Real-Time AI-Powered Sensor Anomaly Detection Pipeline with Kafka and Splunk</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*us2jR53zLsgpXyS5.jpeg" /></figure><h3>Introduction</h3><p>In the oil and gas industry, monitoring sensor data in real-time is critical for ensuring equipment health and preventing costly failures. Detecting anomalies early can save time, money, and even lives. In this project, I built <strong>OilBot Anomaly Detector</strong>, an end-to-end pipeline that ingests sensor data, detects anomalies using an AI model, and logs events into Splunk for real-time monitoring and alerting.</p><p>This project combines Python, Apache Kafka, Isolation Forest machine learning, and Splunk’s HTTP Event Collector (HEC) to provide an efficient, scalable anomaly detection system.</p><h3>Project Architecture Overview</h3><p><strong>The pipeline is designed as follows:</strong></p><ul><li><strong>Sensors</strong> generate simulated oil well data (temperature, pressure, vibration).</li><li>Data is streamed into a <strong>Kafka topic</strong> for real-time ingestion.</li><li>A <strong>Kafka consumer</strong> fetches this data and runs an Isolation Forest model to detect anomalies.</li><li>Anomalies and normal events are logged to <strong>Splunk</strong> via its HTTP Event Collector API.</li><li>Splunk dashboards allow for visualization and alerting based on logged anomalies.</li></ul><p>This architecture ensures decoupling between data ingestion, anomaly detection, and monitoring, allowing easy scaling and extension.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXxDUzHn2vSmCmRouGUc7Q.png" /><figcaption>how it works.</figcaption></figure><h3>Step 1: Setting up Kafka to Stream Sensor Data</h3><p>For simulation, I created a Python script that produces JSON-formatted sensor readings to a Kafka topic named oil-sensor-data. Kafka provides durable, scalable messaging to ensure real-time data delivery.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_y0-I30-ACkeoodtMe7pmQ.png" /><figcaption>sensor_simulator.py (this script continuously streams sensor data to Kafka, simulating real-world conditions)</figcaption></figure><h3>Step 2: Building the AI Anomaly Detector</h3><p>For anomaly detection, I used <strong>Isolation Forest</strong>, a robust unsupervised machine learning algorithm effective for detecting outliers in sensor data.</p><p>The model was trained on normal sensor readings and saved using joblib for quick loading during runtime.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*stu7XfpivNfw0sTSYRXUQA.png" /><figcaption>model_trainer.py (the trained model is loaded in the consumer to predict anomalies)</figcaption></figure><h3>Step 3: Consuming Kafka Messages and Detecting Anomalies</h3><p>The Kafka consumer fetches messages, processes the sensor data, and predicts whether a reading is anomalous.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dzzkdrjF2dR0WBX5qM0mTA.png" /><figcaption>anomaly_detector.py</figcaption></figure><h3>Step 4: Logging Anomalies and Events to Splunk</h3><p>To monitor and alert in production, detected anomalies (and normal events if desired) are sent to Splunk using its HTTP Event Collector (HEC).</p><p>First, configure Splunk to enable HEC and generate a token.</p><p>Then, send JSON payloads with Python’s requests module:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MRFjFxRCaqEoBFFLsGuTPA.png" /><figcaption>splunk_logger.py</figcaption></figure><h3>Step 5: Monitoring &amp; Visualization in Splunk</h3><p>With data flowing into Splunk, you can build dashboards to visualize sensor metrics and highlight anomalies. Set up alerts on anomalous events to notify your team in real-time.</p><p>Splunk’s powerful search and visualization tools make it easy to gain operational insights and respond quickly to potential issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pyhLdQAmYSBvmERiLzzORA.png" /><figcaption>Splunk logs</figcaption></figure><h3>Conclusion</h3><p>This project demonstrates how to build a scalable, real-time anomaly detection pipeline leveraging open-source and commercial tools. Key takeaways:</p><ul><li><strong>Kafka</strong> provides reliable data streaming.</li><li><strong>Isolation Forest</strong> offers effective anomaly detection on sensor data.</li><li><strong>Splunk HEC</strong> enables real-time centralized logging and monitoring.</li></ul><h3>AI/ML Improvements</h3><ol><li><strong>Train on real data</strong> (or larger synthetic datasets).</li><li>Add <strong>feature engineering</strong>: rolling averages, deltas, statistical features.</li><li>Replace IsolationForest with:</li></ol><ul><li>AutoEncoder (for unsupervised anomaly detection)</li><li>LSTM (for sequence/temporal data)</li><li>Prophet or ARIMA (for time-series forecasting)</li></ul><p>👉 <strong>Explore the full project on GitHub:</strong> <a href="https://github.com/AyodhyaDayananda/OilBotAnomalyDetector">GitHub — OilBot Anomaly Detector</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abd9cae9914e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Generating ER Diagrams from MySQL Databases using Python and Graphviz]]></title>
            <link>https://medium.com/@ayodhya.dayananda/generating-er-diagrams-from-mysql-databases-using-python-and-graphviz-c9c33e07e65a?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9c33e07e65a</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Sun, 09 Feb 2025 15:22:03 GMT</pubDate>
            <atom:updated>2025-02-09T15:22:03.268Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lQQ4cVs4Q3zQT9WNkx4x7w.jpeg" /></figure><h3>Automating ER Diagram Generation in MySQL for Data Engineering Workflows:</h3><p>Efficient database design and schema management are critical for modern data engineering workflows. MySQL, as one of the most widely-used relational database systems, plays a vital role in data storage and retrieval for scalable pipelines. Visualizing database schemas through ER diagrams simplifies the process of understanding relationships between tables and ensures consistency for tasks like ETL transformations and schema validations.</p><p>In this guide, we’ll explore a Python-based solution to automate ER diagram generation directly from a MySQL database, laying the foundation for robust and maintainable data workflows.</p><h3>Why Automate Schema Visualization?</h3><p><strong>Data engineering tasks often involve:</strong></p><ul><li><strong>Schema Validation</strong>: Ensuring changes to the database schema align with the data pipeline requirements.</li><li><strong>ETL Pipelines</strong>: Transformations often rely on a deep understanding of table relationships.</li><li><strong>Team Collaboration</strong>: Clear visualizations enhance communication between data engineers, analysts, and stakeholders.</li></ul><p>Manually creating and updating ER diagrams becomes infeasible in dynamic environments. Automating this process for MySQL can save significant time while improving accuracy.</p><h3>The MySQL-Focused ER Diagram Generator:</h3><p>Below is a Python script that connects to a MySQL database, extracts table schemas, identifies foreign key relationships, and generates an ER diagram using the Graphviz library.</p><h4>Key Features</h4><ol><li><strong>Table and Column Parsing</strong>: Fetches table names and columns directly from MySQL.</li><li><strong>Foreign Key Detection</strong>: Identifies relationships using the SHOW CREATE TABLE statement.</li><li><strong>Graphical Representation</strong>: Generates a detailed ER diagram in PNG format with table relationships visualized.</li></ol><pre>import mysql.connector<br>from graphviz import Digraph<br>import re<br><br>class ERDiagramGenerator:<br>    def __init__(self, config):<br>        self.config = config<br>        self.connection = None<br>        self.cursor = None<br>        self.table_columns = {}<br>        self.foreign_keys = []<br><br>    def connect(self):<br>        try:<br>            self.connection = mysql.connector.connect(**self.config)<br>            self.cursor = self.connection.cursor()<br>        except mysql.connector.Error as err:<br>            print(f&quot;Error: {err}&quot;)<br>            raise<br><br>    def fetch_tables(self):<br>        self.cursor.execute(&quot;SHOW TABLES&quot;)<br>        return self.cursor.fetchall()<br><br>    def fetch_columns(self, table_name):<br>        self.cursor.execute(f&quot;DESCRIBE {table_name}&quot;)<br>        columns = self.cursor.fetchall()<br>        self.table_columns[table_name] = {col[0]: col[1] for col in columns}<br>        return columns<br><br>    def fetch_foreign_keys(self, table_name):<br>        self.cursor.execute(f&quot;SHOW CREATE TABLE {table_name}&quot;)<br>        create_table_stmt = self.cursor.fetchone()[1]<br>        return re.findall(r&#39;FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)&#39;, create_table_stmt)<br><br>    def generate_table_node(self, table_name, columns):<br>        label = f&quot;&lt;&lt;TABLE BORDER=&#39;1&#39; CELLBORDER=&#39;1&#39; CELLSPACING=&#39;0&#39;&gt;&quot;<br>        label += f&quot;&lt;TR&gt;&lt;TD BGCOLOR=&#39;lightblue&#39;&gt;&lt;B&gt;{table_name}&lt;/B&gt;&lt;/TD&gt;&lt;/TR&gt;&quot;<br><br>        for column in columns:<br>            column_name = column[0]<br>            label += f&quot;&lt;TR&gt;&lt;TD ALIGN=&#39;LEFT&#39; PORT=&#39;{column_name}&#39;&gt;{column_name} ({column[1]})&lt;/TD&gt;&lt;/TR&gt;&quot;<br><br>        label += &quot;&lt;/TABLE&gt;&gt;&quot;<br>        return label<br><br>    def generate_foreign_key_edges(self):<br>        edges = []<br>        for fk_table, fk_column, ref_table, ref_column in self.foreign_keys:<br>            if ref_table in self.table_columns and ref_column in self.table_columns[ref_table]:<br>                edges.append(<br>                    (f&quot;{fk_table}:{fk_column}&quot;, f&quot;{ref_table}:{ref_column}&quot;, <br>                     f&quot;{fk_column} → {ref_column}&quot;, &quot;blue&quot;, &quot;crow&quot;, 10)<br>                )<br>        return edges<br><br>    def generate_er_diagram(self, output_file=&#39;er_diagram.png&#39;):<br>        # Create Graphviz Digraph<br>        dot = Digraph(format=&#39;png&#39;, engine=&#39;fdp&#39;)  <br>        dot.attr(rankdir=&#39;TB&#39;, size=&#39;10,10!&#39;, concentrate=&#39;true&#39;, splines=&#39;polyline&#39;)<br><br>        # Fetch tables<br>        tables = self.fetch_tables()<br><br>        # Generate nodes for each table<br>        for table in tables:<br>            table_name = table[0]<br>            columns = self.fetch_columns(table_name)<br>            label = self.generate_table_node(table_name, columns)<br>            dot.node(table_name, label=label, shape=&quot;plaintext&quot;)<br><br>            # Fetch foreign keys<br>            fk_matches = self.fetch_foreign_keys(table_name)<br>            for fk_column, ref_table, ref_column in fk_matches:<br>                self.foreign_keys.append((table_name, fk_column, ref_table, ref_column))<br><br>        # Draw foreign key relationships<br>        for edge in self.generate_foreign_key_edges():<br>            dot.edge(edge[0], edge[1], label=edge[2], color=edge[3], arrowhead=edge[4], fontsize=str(edge[5]))<br><br>        # Render the diagram<br>        dot.render(output_file)<br>        print(f&quot;ER diagram generated: {output_file}&quot;)<br><br>    def close_connection(self):<br>        if self.connection.is_connected():<br>            self.cursor.close()<br>            self.connection.close()<br><br># Define connection parameters<br>config = {<br>    &quot;host&quot;: &quot;your_mysql_host&quot;,<br>    &quot;port&quot;: 3306,<br>    &quot;database&quot;: &quot;your_database&quot;,<br>    &quot;user&quot;: &quot;your_username&quot;,<br>    &quot;password&quot;: &quot;your_password&quot;<br>}<br><br># Usage of the class<br>if __name__ == &quot;__main__&quot;:<br>    er_gen = ERDiagramGenerator(config)<br>    <br>    try:<br>        er_gen.connect()<br>        er_gen.generate_er_diagram()  # You can specify the output file name here<br>    finally:<br>        er_gen.close_connection()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*dRDjE1FSHXQWlbBKz3wQcg.jpeg" /><figcaption>Generated ER Diagram</figcaption></figure><h3>Next Steps</h3><p>While this implementation focuses on MySQL, extending the solution to support other databases like SQL Server, Hadoop (via Hive Metastore), and Snowflake will allow for a unified application capable of visualizing schemas across multiple systems. The next iteration could:</p><ol><li><strong>Multi-Database Support</strong>: Create adapters for SQL Server, Hive, and Snowflake to extract schema metadata.</li><li><strong>Centralized Visualization</strong>: Combine schemas from different databases into a single ER diagram for cross-database relationship mapping.</li><li><strong>Integration into Applications</strong>: Incorporate the ER diagram generator into internal data tools, enabling schema validation as part of the CI/CD pipeline.</li></ol><p>By automating schema visualization across systems, data engineers can ensure robust and scalable data pipelines while streamlining collaboration across teams. This foundational work in MySQL sets the stage for a comprehensive solution adaptable to modern data engineering challenges.</p><h4>Conclusion</h4><p>Automating ER diagram generation directly from MySQL databases is a valuable addition to any data engineer’s toolkit. It provides quick insights into schema design and improves collaboration across teams. By extending this solution to other platforms, we can create a comprehensive, cross-database visualization tool for modern data pipelines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9c33e07e65a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bulletproofing Your Data Pipelines: Monitoring with Splunk, Dynatrace, and Moogsoft]]></title>
            <link>https://medium.com/@ayodhya.dayananda/bulletproofing-your-data-pipelines-monitoring-with-splunk-dynatrace-and-moogsoft-e2695786e185?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2695786e185</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Mon, 28 Oct 2024 17:19:55 GMT</pubDate>
            <atom:updated>2024-10-28T17:19:55.305Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*NYZSSlp591GXZ79MYWmIUQ.jpeg" /></figure><h3>The Data Engineer’s Nightmare:</h3><p><strong>Imagine this: </strong>Your data pipeline, moving millions of records each minute, suddenly slows down. AI systems start making decisions based on old data, the robots are acting confused, and your dashboards are completely blank. Upper management? They’re in a full-blown panic, calling for answers as if their lives depend on it. You’re sweating bullets, and all eyes are on you to save the day.</p><p>It sounds like a nightmare, but with the right tools, you can avoid it!</p><p>In today’s data-driven world, data pipelines are the backbone of critical insights — but they’re vulnerable to unexpected failures and performance issues. Luckily, with the right monitoring stack, you can stay ahead of these problems. In this post, we’ll explore how to bulletproof your data pipelines using <strong>Splunk, Dynatrace, and Moogsoft.</strong> We’ll apply these tools to popular data technologies like <strong>Kafka, Hadoop, and Azure Data Factory</strong>, providing end-to-end observability and actionable insights.</p><h3>Monitoring Data Flow with Splunk:</h3><p>Splunk is a powerful tool for monitoring data flow in your pipelines. It collects and analyzes machine-generated data from various sources, allowing you to visualize your data in real time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VPBWH6Zd3pYSJ10USVKRtQ.jpeg" /></figure><h4><strong>Example: Kafka </strong>and Azure Data Factory</h4><p>For a Kafka-based pipeline, you can set up Splunk to monitor topics and message throughput. Here’s a sample query to monitor message rates:</p><pre>index=kafka topic=&quot;your_topic_name&quot;<br>| timechart span=1m sum(bytes) as &quot;Bytes Sent&quot;, sum(messages) as &quot;Messages Sent&quot;<br>| where &#39;Messages Sent&#39; &lt; threshold_value</pre><p>This query helps you identify when message rates drop below a certain threshold, signaling a potential issue.</p><p><strong>For Azure Data Factory</strong>, you can monitor pipeline activities and their status with a query like this:</p><pre>index=azure_data_factory activity_name=&quot;your_activity_name&quot;<br>| timechart span=1h count by status<br>| where status != &quot;Succeeded&quot;</pre><p>This helps identify any failed activities in your Azure Data Factory pipelines.</p><h3>Server Monitoring with Dynatrace:</h3><p>Dynatrace is excellent for monitoring the health of your servers and applications. It provides deep insights into your environment, helping you spot issues before they escalate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pgOSrk0x9Z5CA3zQkM1ybg.png" /></figure><h4>Example: Hadoop</h4><p>In a Hadoop environment, you can set up Dynatrace to track the performance of your clusters. You can create a custom dashboard to monitor job execution times and resource usage. Here’s a sample configuration for monitoring a Hadoop job:</p><ol><li><strong>Create a new service in Dynatrace</strong> for your Hadoop cluster.</li><li><strong>Use tags</strong> to categorize different jobs (e.g., ETL jobs).</li><li><strong>Set up alerts</strong> for slow-running jobs or high resource usage:</li></ol><pre>alert:<br>  condition:<br>    metric: &quot;hadoop.job.executionTime&quot;<br>    threshold: &quot;300&quot;  # seconds<br>  action: &quot;Notify via email&quot;</pre><p>This alert configuration will notify you if any job takes longer than 5 minutes to execute.</p><p><strong>For Azure Data Factory</strong>, set up a monitoring service to track pipeline performance:</p><pre>alert:<br>  condition:<br>    metric: &quot;azure.datafactory.pipelineRunDuration&quot;<br>    threshold: &quot;600&quot;  # seconds<br>  action: &quot;Notify via email&quot;</pre><p>This alerts you if any pipeline runs longer than 10 minutes.</p><h3>Alerting with Moogsoft:</h3><p>Moogsoft serves as a central hub for managing alerts from both <strong>Dynatrace and Splunk</strong>. By integrating these tools, you can streamline your alerting process and reduce alert fatigue.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n-dkwie4_Ot3GCrzBbIdyw.jpeg" /></figure><h4>Sending Alerts to Pager Phones</h4><p>To ensure that urgent alerts reach your team promptly, you can set up Moogsoft to send notifications to pager phones. This way, your on-call team is immediately notified of critical issues, allowing them to respond quickly even when they’re away from their desks.</p><h3>Conclusion:</h3><p>Monitoring your data pipelines is crucial for maintaining the health of your data infrastructure. By using tools like Splunk, Dynatrace, and Moogsoft, you can effectively track data flow, server performance, and alerting, ensuring that your data pipelines are resilient and efficient. With the right monitoring stack in place, you can transform your data nightmares into smooth operations, giving you peace of mind and empowering your organization with timely insights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3l35VxPlD6a8mhNCLTxh1A.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2695786e185" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding Big Data File Formats: A Guide for Efficient Data Pipelines]]></title>
            <link>https://medium.com/@ayodhya.dayananda/decoding-big-data-file-formats-a-guide-for-efficient-data-pipelines-c7e3058c19c4?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7e3058c19c4</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Sat, 04 May 2024 18:32:36 GMT</pubDate>
            <atom:updated>2024-05-04T18:32:36.993Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*z4JLqzfzNApkuhkz.jpg" /></figure><h3>Introduction to Big Data File Formats:</h3><p>In the world of large-scale data pipelines and ecosystems, the choice of file format can be a game-changer. It’s like picking the right tool for the job each format has its strengths and weaknesses that can impact your data processing and storage.</p><p>In this article, we’re diving deep into Big Data file formats like Parquet, Avro, ORC, and JSON. These formats are the building blocks of modern data architectures, powering everything from data lakes to real-time analytics.</p><p>Join us as we uncover the secrets of these file formats, comparing their performance, storage efficiency, and compatibility with popular Big Data processing frameworks. Whether you’re architecting a new data pipeline or optimizing an existing one, this guide will equip you with the knowledge to make informed decisions that drive efficiency and performance in your data ecosystem.</p><h3>Common Big Data File Formats:</h3><p>When it comes to Big Data file formats, there are several key players that have emerged as favorites in the industry. Each format has its own strengths and is optimized for specific use cases. Here are some of the most common Big Data file formats you’re likely to encounter:</p><ol><li><strong>Parquet:</strong> Developed by Apache, Parquet is a columnar storage format that offers efficient data compression and encoding schemes. It’s highly optimized for query performance and is ideal for analytical workloads where fast query response times are crucial.</li><li><strong>Avro:</strong> Another Apache project, Avro is a row-based data serialization system that provides a compact, fast, binary data format. Avro is schema-aware, meaning it stores the schema along with the data, making it self-describing and ideal for data exchange between systems.</li><li><strong>ORC (Optimized Row Columnar): </strong>ORC is a columnar storage format that was developed for use in Apache Hive, a data warehouse infrastructure built on top of Hadoop. ORC files are highly optimized for Hive queries, offering improved query performance and better compression compared to other formats.</li><li><strong>JSON (JavaScript Object Notation):</strong> While not a specialized Big Data format, JSON is widely used for storing and exchanging data due to its simplicity and human-readability. It’s commonly used in web applications and for semi-structured data where schema evolution is frequent.</li><li><strong>CSV (Comma-Separated Values):</strong> CSV is a simple and widely supported file format for tabular data. While not optimized for Big Data workloads, CSV files are easy to work with and can be used for data exchange and simple analytics tasks.</li></ol><p>Each of these file formats has its own strengths and weaknesses, and the choice of format should be based on the specific requirements of your data pipeline and use case.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/928/0*Uc-TX9h4xHTGQlzc.png" /></figure><h3>Characteristics of Each File Format:</h3><h4>01. Parquet:</h4><ul><li><strong>Columnar Storage:</strong> Parquet stores data in a columnar format, which is highly efficient for analytics queries that access a subset of columns.</li><li><strong>Compression:</strong> Parquet uses efficient compression techniques, reducing storage space and improving query performance.</li><li><strong>Splittable: </strong>Parquet files are splittable, meaning they can be divided into smaller parts for parallel processing, improving query performance in distributed environments.</li><li><strong>Schema Evolution:</strong> Parquet supports schema evolution, allowing you to evolve your data schema over time without breaking compatibility with existing data.</li></ul><h4>02.Avro:</h4><ul><li><strong>Schema Evolution:</strong> Like Parquet, Avro supports schema evolution, making it flexible for evolving data schemas.</li><li><strong>Compact Binary Format:</strong> Avro uses a compact binary format, which reduces storage space and is efficient for data serialization and deserialization.</li><li><strong>Schema Included:</strong> Avro includes the schema with the data, making it self-describing and eliminating the need for external schema files.</li><li><strong>Interoperability:</strong> Avro supports multiple programming languages, making it easy to integrate with different systems and languages.</li></ul><h4>03.ORC (Optimized Row Columnar):</h4><ul><li><strong>Columnar Storage:</strong> Similar to Parquet, ORC stores data in a columnar format, which is efficient for analytical queries.</li><li><strong>Predicate Pushdown:</strong> ORC supports predicate pushdown, allowing query engines to push filters down to the storage layer, reducing the amount of data read.</li><li><strong>Compression:</strong> ORC supports different compression algorithms, providing flexibility to choose the best compression method for your data.</li><li><strong>Indexing:</strong> ORC supports indexing, which can speed up query performance by enabling faster data retrieval based on column values.</li></ul><h4>04.JSON (JavaScript Object Notation):</h4><ul><li><strong>Human-Readable:</strong> JSON is human-readable and easy to understand, making it popular for data exchange and configuration files.</li><li><strong>Schema Flexibility:</strong> JSON is schema-less or schema-flexible, allowing for easy modification and evolution of data structures.</li><li><strong>Interoperability:</strong> JSON is supported by most programming languages and is widely used for data exchange in web applications.</li></ul><h4>05.CSV (Comma-Separated Values):</h4><ul><li><strong>Simplicity:</strong> CSV is simple and easy to work with, making it suitable for small-scale data processing and exchange.</li><li><strong>Compatibility:</strong> CSV files can be opened and edited in any text editor or spreadsheet software, making them highly compatible.</li><li><strong>Lack of Schema:</strong> CSV does not include schema information, making it less suitable for complex data structures and schema evolution.</li></ul><p>Each file format has its own set of characteristics that make it suitable for different use cases. The choice of file format should be based on the specific requirements of your data pipeline and the nature of your data.</p><h3>Performance Comparison:</h3><p>When it comes to performance, the choice of file format can have a significant impact on the speed and efficiency of data processing. Let’s compare the performance of Parquet, Avro, ORC, JSON, and CSV based on various factors:</p><h4>Read and Write Speed:</h4><ul><li><strong>Parquet:</strong> Parquet is known for its fast read and write speeds, especially for analytical queries that access a subset of columns.</li><li><strong>Avro:</strong> Avro also offers good read and write speeds, but it may be slightly slower than Parquet due to its schema evolution capabilities.</li><li><strong>ORC:</strong> ORC is optimized for fast read speeds, making it ideal for interactive queries in data warehouses.</li><li><strong>JSON:</strong> JSON may have slower read and write speeds compared to binary formats like Parquet and ORC due to its text-based format.</li><li><strong>CSV: </strong>CSV is generally slower than other formats, especially for large datasets, due to its text-based format and lack of compression.</li></ul><h4>Storage Efficiency:</h4><ul><li><strong>Parquet and ORC:</strong> Both Parquet and ORC offer excellent storage efficiency due to their columnar storage and compression techniques. Parquet and ORC are column-oriented formats, which means they store data column-by-column rather than row-by-row. This allows for better compression ratios and improved query performance, especially for analytical queries that access a subset of columns.</li><li><strong>Avro:</strong> Avro also provides good storage efficiency, especially when compared to JSON and CSV. However, it may not be as efficient as Parquet and ORC due to its row-oriented format.</li><li><strong>JSON and CSV:</strong> JSON and CSV are less storage-efficient compared to binary formats like Parquet and ORC, mainly due to their text-based format and lack of compression.</li></ul><h4>Compression:</h4><ul><li><strong>Parquet and ORC:</strong> Both Parquet and ORC support efficient compression techniques, reducing storage space and improving query performance. Because they are column-oriented formats, they can achieve higher compression ratios compared to row-oriented formats like Avro, JSON, and CSV.</li><li><strong>Avro:</strong> Avro also supports compression, but it may not be as efficient as Parquet and ORC due to its row-oriented format.</li><li><strong>JSON and CSV:</strong> JSON and CSV can be compressed, but they are generally less efficient in terms of compression ratios compared to binary formats like Parquet and ORC, mainly due to their text-based format.</li></ul><h4>Schema Evolution:</h4><ul><li><strong>Avro:</strong> Avro supports schema evolution, allowing you to evolve your data schema over time without breaking compatibility with existing data.</li><li><strong>Parquet:</strong> Schema evolution in Parquet can be expensive because it requires merging through multiple files, which can impact performance.</li><li><strong>ORC:</strong> ORC is limited to adding new columns only for schema evolution, making it less flexible compared to Avro and Parquet.</li><li><strong>JSON and CSV: </strong>JSON and CSV are less flexible in terms of schema evolution, as they do not include schema information with the data.</li></ul><p>In conclusion, the choice of file format should be based on the specific requirements of your data pipeline, including read and write speeds, storage efficiency, and schema evolution capabilities. Each format has its own strengths and weaknesses, and the best format for your use case will depend on your specific needs.</p><h3>Best Practices:</h3><ol><li><strong>Choose the Right Format for the Job:</strong> Select a file format based on your specific use case and requirements. For analytical workloads, columnar formats like Parquet and ORC are often the best choice due to their efficient storage and query performance. For schema flexibility and interoperability, Avro may be more suitable.</li><li><strong>Optimize for Compression:</strong> Use compression to reduce storage space and improve query performance. Choose a compression algorithm that balances compression ratio and CPU overhead based on your data characteristics and workload.</li><li><strong>Leverage Partitioning and Clustering:</strong> Use partitioning and clustering strategies to organize your data within the file format. This can improve query performance by reducing the amount of data scanned for each query.</li><li><strong>Schema Design:</strong> Design your schema carefully to optimize for your query patterns and data access patterns. Consider the trade-offs between schema evolution, query performance, and data size.</li><li><strong>Use Splittable Formats:</strong> Choose file formats that are splittable, allowing for parallel processing and improved scalability in distributed environments.</li><li><strong>Consider Data Locality:</strong> If your data processing framework supports it, consider storing your data in a format that allows for data locality, minimizing data movement and improving performance.</li><li><strong>Monitor and Tune Performance:</strong> Regularly monitor the performance of your data processing pipeline and tune it based on the observed patterns. This may include adjusting compression settings, partitioning strategies, or file formats based on performance metrics.</li><li><strong>Consider Data Retention and Archival:</strong> For long-term storage and archival, consider the long-term viability and compatibility of your chosen file format.</li><li><strong>Document Your Choices:</strong> Document the rationale behind your choice of file format and any optimizations or tuning you have done. This will help other team members understand and maintain the pipeline in the future.</li></ol><p>By following these best practices, you can optimize your Big Data file formats for performance, scalability, and efficiency in your data processing pipelines.</p><h3>Real-World Examples:</h3><h4>Streaming Data Pipeline with Kafka and Avro:</h4><ul><li><strong>Use Case:</strong> In a streaming data scenario, where data is continuously flowing in from various sources, maintaining schema compatibility is crucial.</li><li><strong>Solution:</strong> Avro is commonly used with Apache Kafka due to its schema evolution capabilities. Avro allows for the evolution of the schema over time, making it ideal for streaming data where schemas may change frequently.</li><li><strong>Example:</strong> A company ingests sensor data from IoT devices into Kafka using Avro. As the schema of the sensor data evolves, Avro ensures that both old and new data can be processed without issues.</li></ul><h4>Data Warehousing with Parquet and ORC:</h4><ul><li><strong>Use Case:</strong> In a data warehousing scenario, where large volumes of data need to be stored and queried efficiently, columnar storage formats like Parquet and ORC are preferred.</li><li><strong>Solution:</strong> Parquet and ORC are commonly used with data warehouses like Amazon Redshift or Snowflake. These formats excel at storing and querying large volumes of data efficiently due to their columnar storage layout.</li><li><strong>Example:</strong> A company stores its historical sales data in a data warehouse using Parquet. The columnar storage format allows for fast analytics and reporting on sales trends.</li></ul><h4>Batch Processing with Avro and Parquet:</h4><ul><li><strong>Use Case:</strong> For batch processing of data where schema flexibility is required, formats like Avro and Parquet are suitable.</li><li><strong>Solution: </strong>Avro and Parquet are often used in batch processing systems like Apache Spark. Avro allows for flexible schema design, while Parquet offers efficient storage and query performance.</li><li><strong>Example:</strong> A company processes log files using Apache Spark, storing the processed data in Parquet format. The efficiency of Parquet allows for quick analysis of log data for insights.</li></ul><h4>Data Lake with ORC and Hive:</h4><ul><li><strong>Use Case:</strong> In a data lake environment, where data is stored in its raw form for future processing and analysis, efficient storage and query performance are key.</li><li><strong>Solution:</strong> ORC is commonly used with Apache Hive in data lake environments. ORC’s optimized storage layout and indexing features make it ideal for storing and querying large volumes of data efficiently.</li><li><strong>Example:</strong> A company stores its raw data in a data lake using ORC format. The optimized storage layout of ORC allows for fast querying and analysis of raw data when needed.</li></ul><p>These examples illustrate how Parquet, Avro, and ORC are used in real-world data pipelines to address specific requirements and challenges, showcasing their strengths in different use cases.</p><h3>Conclusion:</h3><p>In modern data pipelines, choosing the right file format is crucial for ensuring efficient data storage, processing, and analysis. Parquet, Avro, and ORC are three popular formats that offer unique advantages and are commonly used in various stages of data processing pipelines.</p><ul><li><strong>Parquet:</strong> Parquet is well-suited for analytical workloads where efficient storage and query performance are essential. Its columnar storage format and support for advanced compression techniques make it ideal for data warehousing and analytics.</li><li><strong>Avro:</strong> Avro is preferred for streaming data scenarios where schemas may evolve over time. Its schema evolution capabilities and efficient serialization make it a good choice for real-time data processing with systems like Apache Kafka.</li><li><strong>ORC:</strong> ORC is optimized for fast query performance and is commonly used in data lake environments. Its efficient storage layout and indexing features make it ideal for storing and querying large volumes of data in batch and interactive query scenarios.</li></ul><p>When choosing between Parquet, Avro, and ORC for your data pipeline, consider the specific requirements of your use case, such as data volume, query performance, schema evolution, and integration with other systems. By selecting the right file format for each stage of your pipeline, you can ensure optimal performance and efficiency in your data processing workflows.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V77tiioZ9z9M8Zed.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7e3058c19c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Robust Salesforce Data Extraction Pipeline with Automated Schema Handling using Bulk API…]]></title>
            <link>https://medium.com/@ayodhya.dayananda/creating-a-robust-salesforce-data-extraction-pipeline-using-bulkapi-1-0-airflow-and-snowflake-cc64ceae868f?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc64ceae868f</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 21:12:52 GMT</pubDate>
            <atom:updated>2024-03-01T21:35:14.459Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Robust Salesforce Data Extraction Pipeline with Automated Schema Handling using Bulk API 1.0, Apache Airflow, and Snowflake</h3><p>One of the common challenges in Salesforce data pipelines is dealing with frequently changing objects. This often leads to delays for internal clients like data scientists and analysts, as they have to wait for data engineers to make the necessary fixes. To overcome this issue, I have developed a robust pipeline for Salesforce data extraction using BulkAPI 1.0, Airflow, and Snowflake.</p><h3>Why BulkAPI 1.0?</h3><p>If you already have a data extraction pipeline for Salesforce using BulkAPI 2.0, it’s important to switch to BulkAPI 1.0. This is because BulkAPI 1.0 allows us to extract data in JSON format, whereas BulkAPI 2.0 only supports CSV format.</p><h3>Our Tech Stack</h3><ul><li>Salesforce API</li><li>Python</li><li>Snowflake</li><li>Airflow</li></ul><h3>Architecture Diagram</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LOQm6OdNSE52fLrCK0WIag.png" /></figure><p>In this section, we will present a detailed architecture diagram of our automated Salesforce data pipeline, highlighting its technical components and workflow. The pipeline is designed to efficiently extract, transform, and load Salesforce data into Snowflake, ensuring data integrity and consistency.</p><p><strong>Main Modules:</strong></p><p>1. <strong>Schema Extractor:</strong> Utilizes the sobject_describe REST call to extract the latest Salesforce object schema. This schema is then stored in the Snowflake Landing Zone’s “salesforce_schema” table.</p><p>2. <strong>Payload Extractor:</strong> Utilizes the Bulk API 1.0 to extract the payload of Salesforce objects. The extracted payload is stored in both the Landing Zone’s and Confirmed Zone’s “salesforce_payload” tables in Snowflake.</p><p>3. <strong>Snowflake Flusher:</strong> Manages the loading of data into Snowflake, handling Snowflake’s variant column size limitation of 16MB to ensure data integrity.</p><p>4. <strong>Schema Checker:</strong> Compares the latest schema version in the Landing Zone with the confirmed zone’s “is_current = true” latest version. If discrepancies are found, it updates the confirmed zone’s schema accordingly. It then marks the latest Landing Zone schema as “is_current = true” and the old record as “is_current = false” in the Confirmed Zone’s “salesforce_schema” table.</p><p>5. <strong>JSON Payload Flattener:</strong> Flattens the JSON payload in the Confirmed Zone’s “salesforce_payload” schema and inserts the flattened data into the relevant main table under the Confirmed Zone’s “salesforce” schema.</p><p>Snowflake Zones:</p><p>1. <strong>Landing Zone:</strong> Contains two main schemas, “salesforce_schema” and “salesforce_payload”, for storing the raw schema and payload data, respectively.</p><p>2. <strong>Confirmed Zone:</strong> Contains three main schemas, “salesforce_schema”, “salesforce_payload”, and “salesforce”, for storing the confirmed schema, payload, and final data, respectively.</p><p>The workflow of these modules is orchestrated through Apache Airflow, ensuring a seamless and automated process for handling Salesforce data. Detailed explanations of each module and zone will be provided in the subsequent sections of this article.</p><h3>Module One: Schema Extractor</h3><p>The first step is to extract the Salesforce object schema in JSON format. This schema will be used to dynamically create select queries for data extraction.</p><pre>def describe_salesforce_object(instance_url, api_version, object_name, access_token, headers=None, params=None):<br>    url = f&quot;{instance_url}/services/data/v{api_version}/sobjects/{object_name}/describe/&quot;<br>    if not headers:<br>        headers = {}<br>    headers.update({<br>        &quot;Authorization&quot;: f&quot;Bearer {access_token}&quot;,<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>    })<br><br>    try:<br>        response = requests.get(url, headers=headers, params=params)<br>        response.raise_for_status()<br>        describe_info = response.json()<br>        return describe_info<br>    except requests.exceptions.HTTPError as e:<br>        logging.error(f&quot;Failed to describe object. Status code: {response.status_code}, Error message: {response.text}&quot;)<br>        raise<br>    except Exception as e:<br>        logging.error(f&quot;An error occurred: {e}&quot;)<br>        raise</pre><h3>Module Two: Payload Extractor</h3><p>Using the previously extracted schema, create a select query for the Salesforce object dynamically. Pass this query to BulkAPI 1.0 to extract the data in JSON format.</p><pre>def create_batch_job(base_uri, job_id, session_id, soql_query, headers=None):<br>    endpoint = f&quot;{base_uri}/job/{job_id}/batch&quot;<br>    if not headers:<br>        headers = {}<br>    headers.update({<br>        &quot;X-SFDC-Session&quot;: session_id,<br>        &quot;Content-Type&quot;: &quot;application/json&quot;<br>    })<br><br>    payload = {<br>        &quot;query&quot;: soql_query<br>    }<br><br>    try:<br>        response = requests.post(endpoint, headers=headers, json=payload)<br>        response.raise_for_status()<br>        batch_info = response.json()<br>        logging.info(&quot;Batch job created successfully.&quot;)<br>        return batch_info<br>    except requests.exceptions.HTTPError as e:<br>        logging.error(f&quot;Failed to create batch job. Status code: {response.status_code}, Error message: {response.text}&quot;)<br>        raise<br>    except Exception as e:<br>        logging.error(f&quot;An error occurred: {e}&quot;)<br>        raise</pre><h3>Snowflake Structure</h3><h4>Landing Zone</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/668/1*59qpVOsNk1WOUggoZFnnPw.png" /><figcaption>Schema: Salesforce_schema and Salesforce_Payload</figcaption></figure><h4>Confirmed Zone</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/707/1*9AexgRHUs2yUUwlHbst8mQ.png" /><figcaption>Schema: Salesforce, Salesforce_schema, and Salesforce_Payload</figcaption></figure><h3>Module Three: Flush to Snowflake</h3><p>This module flushes the extracted JSON payload to Snowflake. It includes a method to check the payload size and separate it into chunks to fit the Snowflake variant column size limitation of 16MB.</p><pre>def check_and_chunk_json(file_path, chunk_size_mb=10):<br>    try:<br>        # Check file existence<br>        if not os.path.exists(file_path):<br>            logging.error(f&quot;File {file_path} does not exist.&quot;)<br>            return None<br><br>        # Check file size<br>        file_size_mb = os.path.getsize(file_path) / (1024 * 1024)  # Size in MB<br>        if file_size_mb &lt;= chunk_size_mb:<br>            # File size is within limit, return the file content<br>            with open(file_path, &#39;r&#39;) as file:<br>                return [json.load(file)]<br>        else:<br>            # File size is greater than limit, chunk the file<br>            chunks = []<br>            with open(file_path, &#39;r&#39;) as file:<br>                data = json.load(file)<br>                chunk = []<br>                chunk_size = 0<br>                for item in data:<br>                    item_size_mb = len(json.dumps(item)) / (1024 * 1024)<br>                    if chunk_size + item_size_mb &gt; chunk_size_mb:<br>                        # Current item exceeds chunk size, start a new chunk<br>                        chunks.append(chunk)<br>                        chunk = []<br>                        chunk_size = 0<br>                    chunk.append(item)<br>                    chunk_size += item_size_mb<br>                if chunk:<br>                    chunks.append(chunk)<br>            return chunks<br>    except Exception as e:<br>        logging.error(f&quot;Error processing file {file_path}: {str(e)}&quot;)<br>        return None</pre><h3>Module Four: Schema Change Checker</h3><p>This module is designed to validate the schema consistency between the <strong>Landing Zone and Confirmed Zone</strong> tables within the “<strong>salesforce_schema</strong>” schema. It achieves this by comparing the JSON payloads of the latest records in the Landing Zone tables, representing the most recent schema of the Salesforce object, with the “is_current” true records in the Confirmed Zone tables, which hold the previous version of the schema. If discrepancies are detected, the module updates the relevant table and ensures that the Confirmed Zone reflects the latest schema changes under the “<strong>salesforce</strong>” schema.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UhdslqmlB-bKLQwu" /></figure><h3>Module Five: Flatten Payload</h3><p>In this module, we will focus on processing unprocessed data within the “confirmed_zone.payload” schema where the audit_status is marked as “unprocessed.” The process involves flattening this data and subsequently inserting it into the relevant tables under the “confirmed_zone.salesforce” schema. Finally, we will update the audit_status of the data in the “confirmed_zone.payload” schema to “processed.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*jwQzL_aZsgtQlLZA04eTOQ.png" /></figure><h3>Building an Automated Salesforce Data Pipeline with Apache Airflow</h3><p>In this section, we will explore how to create an Apache Airflow DAG to automate your robust Salesforce data pipeline. The pipeline will handle all Salesforce objects in the following sequence:</p><ol><li>Extract Schema: Utilize the extract_schema Python module to extract the latest schema of Salesforce objects.</li><li>Flush Schema to Snowflake: Use the snowflake_flusher module to flush the extracted schema to Snowflake.</li><li>Extract Payload: Employ the extract_payload Python module to extract the payload of Salesforce objects.</li><li>Flush Payload to Snowflake: Utilize the snowflake_flusher module again to flush the extracted payload to Snowflake.</li><li>Schema Checker: Implement the schema_checker module to Validates the schema.</li><li>JSON Payload Flattener: Finally, use the json_payload_flattener module to flatten the JSON payload.</li></ol><pre>from datetime import datetime, timedelta<br>from airflow import DAG<br>from airflow.operators.python_operator import PythonOperator<br>from your_module import extract_schema, snowflake_flusher, extract_payload, schema_checker, json_payload_flattener<br><br>default_args = {<br>    &#39;owner&#39;: &#39;airflow&#39;,<br>    &#39;depends_on_past&#39;: False,<br>    &#39;start_date&#39;: datetime(2022, 1, 1),<br>    &#39;email_on_failure&#39;: False,<br>    &#39;email_on_retry&#39;: False,<br>    &#39;retries&#39;: 1,<br>    &#39;retry_delay&#39;: timedelta(minutes=5),<br>}<br><br>dag = DAG(<br>    &#39;salesforce_data_pipeline&#39;,<br>    default_args=default_args,<br>    description=&#39;A DAG to automate the Salesforce data pipeline&#39;,<br>    schedule_interval=timedelta(days=1),<br>)<br><br>extract_schema_task = PythonOperator(<br>    task_id=&#39;extract_schema&#39;,<br>    python_callable=extract_schema,<br>    dag=dag,<br>)<br><br>flush_schema_task = PythonOperator(<br>    task_id=&#39;flush_schema_to_snowflake&#39;,<br>    python_callable=snowflake_flusher,<br>    dag=dag,<br>)<br><br>extract_payload_task = PythonOperator(<br>    task_id=&#39;extract_payload&#39;,<br>    python_callable=extract_payload,<br>    dag=dag,<br>)<br><br>flush_payload_task = PythonOperator(<br>    task_id=&#39;flush_payload_to_snowflake&#39;,<br>    python_callable=snowflake_flusher,<br>    dag=dag,<br>)<br><br>schema_checker_task = PythonOperator(<br>    task_id=&#39;schema_checker&#39;,<br>    python_callable=schema_checker,<br>    dag=dag,<br>)<br><br>json_payload_flattener_task = PythonOperator(<br>    task_id=&#39;json_payload_flattener&#39;,<br>    python_callable=json_payload_flattener,<br>    dag=dag,<br>)<br><br>extract_schema_task &gt;&gt; flush_schema_task &gt;&gt; extract_payload_task &gt;&gt; flush_payload_task &gt;&gt; schema_checker_task &gt;&gt; json_payload_flattener_task</pre><h3>Conclusion: Enhancing Data Timeliness and Efficiency with Adaptive Schema Handling</h3><p>In conclusion, implementing this robust pipeline can significantly reduce delays caused by frequently changing Salesforce objects. The pipeline’s adaptive schema handling capability ensures that schema changes are seamlessly incorporated into the data processing flow, reducing the risk of data errors and inconsistencies. By automating the extraction, transformation, and loading processes with Apache Airflow, you can provide more timely and reliable data to your internal clients. This not only improves data accuracy and consistency but also enhances overall operational efficiency.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc64ceae868f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking Real-time Data Insights: A Guide to Azure Service Bus for Data Extraction]]></title>
            <link>https://medium.com/@ayodhya.dayananda/unlocking-real-time-data-insights-a-guide-to-azure-service-bus-for-data-extraction-e771a43be27d?source=rss-79ea8108de82------2</link>
            <guid isPermaLink="false">https://medium.com/p/e771a43be27d</guid>
            <dc:creator><![CDATA[Ayodhya Dayananda]]></dc:creator>
            <pubDate>Sun, 18 Feb 2024 04:43:11 GMT</pubDate>
            <atom:updated>2024-02-18T04:48:52.472Z</atom:updated>
            <content:encoded><![CDATA[<p>In the fast-paced world of data-driven decision-making, access to timely and relevant data is paramount. As a data engineer, I often find myself needing immediate access to specific data sets from a variety of vendor sources such as Zoom, Teams, Workday, Canvas, Salesforce, and Jira, to name a few.</p><p>To address this challenge, I have developed a solution that leverages Azure Service Bus for real-time data extraction. This solution empowers internal clients to request and receive portions of data swiftly and efficiently, enabling them to make informed business decisions without delays.</p><p>In this article, I will delve into the intricacies of real-time data extraction using Azure Service Bus. I will explore the architecture of the solution, the implementation steps involved, and provide practical examples to guide you through the process. By the end, you’ll have a comprehensive understanding of how to use Azure Service Bus to streamline your data extraction processes and gain valuable insights for your business.</p><p>Let’s dive in!</p><h3>Understanding the Problem</h3><p>In today’s data-driven landscape, timely access to data is crucial for making informed business decisions. However, data analysts and data scientists often face challenges in accessing the data they need in a timely manner. This is particularly true when dealing with vendor data sources like Zoom, Teams, Workday, Canvas, Salesforce, and Jira, which may not offer real-time access or may have complex extraction processes.</p><p>Traditional methods of data extraction often involve manual intervention or scheduled batch processes, which can result in delays and may not meet the real-time requirements of the business. Additionally, extracting data from multiple sources and consolidating it for analysis can be a time-consuming and error-prone process.</p><p>To address these challenges, there is a need for a solution that allows for real-time data extraction from various vendor data sources, enabling data analysts and data scientists to access the data they need quickly and efficiently. This is where Azure Service Bus comes in, offering a scalable and reliable platform for real-time data extraction and delivery.</p><p>In the next sections, we’ll explore how Azure Service Bus can be used to overcome these challenges and provide a seamless solution for real-time data extraction.</p><h3>Solution Overview</h3><p>The solution for real-time data extraction using Azure Service Bus consists of several key components:</p><p><strong>1. Azure Service Bus</strong>: Azure Service Bus is a fully managed messaging service that provides reliable message queuing and message routing between applications and services. In our solution, Azure Service Bus serves as the central messaging hub for data extraction requests and responses.</p><p><strong>2. Azure Function:</strong> An Azure Function is a serverless compute service that allows you to run event-driven code without having to explicitly provision or manage infrastructure. In our solution, an Azure Function is used to listen for messages on a specific Azure Service Bus topic. When a data extraction request is sent to the Azure Service Bus topic, the Azure Function is triggered to process the request. This is achieved using the Queue Storage trigger for Azure Functions, which allows the function to be invoked whenever a new message is added to a specified Azure Service Bus queue or topic.</p><p><strong>3. Data Sources:</strong> The data sources, such as Zoom, Teams, Workday, Canvas, Salesforce, and Jira, contain the data that needs to be extracted. These data sources may have APIs or other interfaces for extracting data, which the Azure Function will interact with.</p><p><strong>4. Extraction Parameters:</strong> The data extraction request sent to the Azure Service Bus topic includes extraction parameters, such as the type of data to extract, the timeframe for extraction, and any other relevant details.</p><p><strong>5. Data Lake or Data Warehouse:</strong> Once the data extraction is completed, the extracted data is flushed to the relevant data lake or data warehouse for further analysis and processing by data analysts and data scientists.</p><p>In this solution, the Azure Service Bus acts as a mediator between the client requesting the data extraction and the Azure Function responsible for executing the extraction. The use of Azure Functions and the Queue Storage trigger provides a scalable and cost-effective way to implement the listener component of our solution, ensuring that data extraction requests are processed in a timely manner.</p><p>Next, we’ll explore the implementation steps involved in setting up this solution using Azure Service Bus.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHf6e-9L1tpWaCxCQyj0rg.png" /><figcaption>Architecture Diagram</figcaption></figure><h3>Implementation Steps</h3><p>Implementing the real-time data extraction solution using Azure Service Bus involves several key steps:</p><p><strong>1. Create Azure Service Bus Resources:</strong></p><ul><li>Create a new Azure Service Bus namespace in the Azure portal.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*us2Jij1zVIFI6v2d1xGtjg.png" /><figcaption>Step 01 : search for azure service bus</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BYJDBe45yOfoDv1zMlu6Sw.png" /><figcaption>Step 02 : click on + Create</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsisqnDweJmgznP16hfF2w.png" /><figcaption>Step 03 : After adding necessary configurations click on Review + create</figcaption></figure><ul><li>Create a new topic within the namespace to act as the central messaging hub for data extraction requests and responses.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cE-WozJjTkPEiyllPatAdg.png" /><figcaption>Step 01 : Click on + Topic</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vco1a7c3D-hcVaL3YVcjaQ.png" /><figcaption>Step 02 : After adding necessary configurations click on Create</figcaption></figure><ul><li>Optionally, create subscriptions within the topic to route messages to different Azure Function instances based on specific criteria.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V39exsmZIgo_b4s5JZXWlw.png" /><figcaption>Step 01 : Click on + subscription</figcaption></figure><p><strong>2. Develop Azure Function for Data Extraction:</strong></p><ul><li>Create a new Azure Function app(You can do this by vs code or azure portal).</li></ul><p>To create an Azure Function App, you need to provide configuration details for Subscription, Resource Group, Function App Name, Runtime Stack(Python, Java, .net), Region, Operating System(Linux, Windows), Plan Type, SKU and Size, Application Insights (optional), and Tags (optional).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LWQt3Xh-tNxNsMvCv-sYZw.png" /><figcaption>By VS Code : click on Create Function App Azure in vs code(Befor that you need to login to Azure account through vs code)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5uKrUeBvSoTgdr1N1G4_A.png" /><figcaption>In this section you need to provide necessary configurations.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BflMFj6qJbawLeOdIA40BQ.png" /><figcaption>By Azure portal : Those are the configurations what we need to add</figcaption></figure><ul><li>Develop the Azure Function code to listen for messages on the Azure Service Bus topic using the Queue Storage trigger.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pIUUjjFup9RPFnjfR2zXtQ.png" /><figcaption>By VS Code : click on Create Function in vs code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QlK8jdxMZc4-u4Mc99vFpw.png" /><figcaption>In this section you need to provide necessary configurations.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1J8KwaGRhMtGIGSBj-TXFg.png" /><figcaption>Azure Function</figcaption></figure><ul><li>Process the data extraction request received in the message, extract the data from the specified data sources based on the extraction parameters, and flush the extracted data to the relevant data lake or data warehouse.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RPqTCX7skjwPrg9Jf6hETg.png" /><figcaption>My Work Space</figcaption></figure><p><strong>In my workspace, I have organized it into four main parts:</strong></p><p><strong>Template Package:</strong> This package contains common functionalities such as flushing data to a data warehouse or data lake and getting configurations. It provides reusable components for my solution.</p><p><strong>Zoom Package:</strong> This package contains specific functionalities related to the Zoom vendor. You can create similar packages for other vendors to handle their specific requirements.</p><p><strong>ASB_handler Package: </strong>This package is a common module used for handling Azure Service Bus (ASB) message producers, message listeners, payload validators, and other ASB-related functionalities. It provides a centralized location for managing ASB-related tasks across all vendors.</p><p><strong>function_app.py Module:</strong> This module is used to configure different Azure Functions. I define the Azure Functions here and use the functionalities from the template, Zoom, and ASB_handler packages as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JTlc0lfCwRnLVC0SVThBsg.png" /><figcaption>Vendor main.py</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbYgBd7yRhdWi4CxIHXAhA.png" /><figcaption>asb service_provider</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kcihx1k9FubnohuXzbtKTQ.png" /><figcaption>azure function(calling asb handler in azure function)</figcaption></figure><p><strong>03. Deploy the Functon app:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LGhVGXAlzFi7-pjJJlJgA.png" /><figcaption>click on deploy to function app</figcaption></figure><p><strong>04. Test the Solution:</strong></p><ul><li>Send a test data extraction request to the Azure Service Bus topic using a sample JSON payload.</li><li>Verify that the Azure Function is triggered and processes the request correctly, extracting the data from the specified data sources and flushing it to the data lake or data warehouse.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YZrlTHNAlWH5ZNacWOJvzA.png" /><figcaption>send payload to azure service bus</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c11z4t4A-X0MyDgz2oDQCg.png" /><figcaption>function app monitoring</figcaption></figure><p><strong>05. Monitor and Maintain the Solution:</strong></p><p>· Monitor the Azure Function and Azure Service Bus resources to ensure that the data extraction process is running smoothly.</p><p>· Monitor the performance of the solution and make any necessary adjustments to optimize its performance and scalability.</p><p>· Ensure that the solution is secure by implementing appropriate authentication and access controls for the Azure Service Bus and Azure Function resources.</p><p>· By following these implementation steps, you can set up a robust and efficient real-time data extraction solution using Azure Service Bus, enabling data analysts and data scientists to access the data they need quickly and efficiently for making informed business decisions.</p><h3>Conclusion</h3><p>In the fast-evolving landscape of data-driven decision-making, real-time access to data is paramount. Azure Service Bus provides a reliable and scalable solution for real-time data extraction, allowing data engineers to meet the demands of internal clients for immediate access to data from various vendor sources.</p><p>By leveraging Azure Service Bus, data engineers can efficiently process data extraction requests, extract data from multiple sources, and flush it to data lakes or data warehouses for further analysis. The use of Azure Functions and the Queue Storage trigger provides a cost-effective and scalable approach to implementing the listener component of the solution.</p><p>In this article, we’ve explored the architecture of a real-time data extraction solution using Azure Service Bus, discussed its benefits, and outlined the implementation steps. By following these guidelines, data engineers can create a robust and efficient data extraction pipeline, empowering data analysts and data scientists to make timely and informed business decisions.</p><p>With Azure Service Bus, real-time data extraction becomes not just a possibility, but a practical and effective solution for meeting the data demands of today’s fast-paced business environment.</p><h3>References and Further Reading</h3><p><strong>Azure Functions: </strong><a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp">https://learn.microsoft.com/en-us/azure/azure-functions/functions-overview?pivots=programming-language-csharp</a></p><p><strong>Azure Service Bus: </strong><a href="https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview">https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-messaging-overview</a></p><p><strong>My GitHub Repository:</strong> <a href="https://github.com/AyodhyaDayananda/vender-data-integration/blob/feature/exp-001-np/README.md">https://github.com/AyodhyaDayananda/vender-data-integration/blob/feature/exp-001-np/README.md</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e771a43be27d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>