<?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 Buse Kaylan on Medium]]></title>
        <description><![CDATA[Stories by Buse Kaylan on Medium]]></description>
        <link>https://medium.com/@busekaylan?source=rss-3f074004b6a6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*NKmx6ftv9t1vlUuhkccLfw.png</url>
            <title>Stories by Buse Kaylan on Medium</title>
            <link>https://medium.com/@busekaylan?source=rss-3f074004b6a6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 18:53:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@busekaylan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From 137 Bytes to 2.7: How Much Space Does Factory Data Really Take? UNS to Lakehouse — Part 3]]></title>
            <link>https://pub.towardsai.net/from-137-bytes-to-2-7-how-much-space-does-factory-data-really-take-uns-to-lakehouse-part-3-aecad8ffc98d?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/aecad8ffc98d</guid>
            <category><![CDATA[industrial-iot]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[apache-parquet]]></category>
            <category><![CDATA[data-compression]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Fri, 06 Nov 2026 23:43:21 GMT</pubDate>
            <atom:updated>2026-11-08T05:35:22.374Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>One day of a virtual bottling plant, stored eleven different ways. The winner is 51 times smaller than the raw messages, and two of the “optimizations” along the way made things worse.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*t5EaMDMLZRH9tA8SsjaVgg.png" /></figure><p>A pressure sensor reports 800.53 mbar. The number takes six characters, but the message carrying it through the Unified Namespace takes 134 bytes.</p><p>That gap is easy to ignore with one sensor. A plant with a few thousand signals publishes millions of such messages a day. Most teams that decide to “just keep the history” start by writing those messages to disk as they arrive. That is a sensible first step, and an expensive one if it becomes the long-term format.</p><p>In Part 2 we built a virtual factory: three lines, eight machines, 37 signals, faults, frozen sensors and network outages, all deterministic from a single seed. This post uses one simulated day of that factory to answer a narrow question with real numbers: <strong>how much space does this data take, and which storage decisions actually matter?</strong></p><h3>The setup</h3><p>The experiment simulates 24 hours of the plant, with seed 42 and report-by-exception enabled. That produces <strong>1,158,046 published readings</strong>. The same table is then written in eleven formats:</p><ul><li><strong>Text formats:</strong> JSON lines (one raw MQTT message per line, topic plus payload) and CSV, each with and without gzip.</li><li><strong>Parquet with different codecs:</strong> uncompressed, snappy and zstd.</li><li><strong>Parquet tuned further:</strong> a different sort order, delta-encoded timestamps, byte-stream-split floats, and a different way of storing the delivery time.</li></ul><p>Each variant is written three times, and the median write time is reported. For Parquet, the script also reads the file metadata to see how many bytes each column takes. Everything runs with one command:</p><pre>git clone https://github.com/BuseKaylan/uns-to-lakehouse.git<br>cd uns-to-lakehouse<br>make install<br>make bench-storage</pre><p>All results are committed to the repository under benchmarks/results/01_storage_footprint/ as CSV and JSON, together with the Python and library versions that produced them. My numbers come from a 16-core Intel MacBook running Python 3.14 and pyarrow 26. File sizes are identical on any machine, because the data is deterministic. Write times will differ.</p><h3>Anatomy of one message</h3><p>Before comparing formats, it helps to look at what is being stored.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KyuhJpx9sNP0fAkthEqyow.png" /></figure><p>Here is one reading as a raw UNS message:</p><pre>{&quot;topic&quot;: &quot;acme-plant/filling-area/line-1/filler/pressure&quot;,<br> &quot;payload&quot;: {&quot;value&quot;: 800.53, &quot;unit&quot;: &quot;mbar&quot;, &quot;timestamp&quot;: 1767592800000}}</pre><p>Of its 134 bytes:</p><ul><li><strong>46</strong> are the topic path, which is the same on every pressure message from this machine.</li><li><strong>65</strong> are keys, quotes, braces and spaces, which are identical in every message.</li><li><strong>13</strong> are the timestamp, and <strong>4</strong> are a unit that never changes.</li><li><strong>6</strong> are the measurement itself.</li></ul><p>Averaged over the whole day, a message is <strong>137.15 bytes</strong>. Raw JSON is not wasteful because JSON is bad. It is wasteful because each message is written to be understood on its own, without knowing what came before. That is exactly right on the wire and exactly wrong on disk.</p><h3>Round 1: text formats</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/654/1*zfxNV8wJZsPa1WhDkcE6Mw.png" /></figure><p>CSV removes the repeated keys but keeps the repeated topic path, so it only saves about 20%. Gzip is the real step: 21 to 22 times smaller than raw JSON. That shows how much repetition there is to remove.</p><p>The catch is that a gzip file is one opaque stream. To answer “what was the average vibration on line 2 between 14:00 and 15:00”, a query engine has to decompress and parse the whole day. Text plus gzip is a good archive format, not a good analytics format.</p><p>A note on the write times: the JSON writer is a Python loop that builds one dictionary per row, while CSV and Parquet are written by Arrow’s C++ code. The gap says more about Python vs. C++ than about the formats themselves.</p><h3>Round 2: columns instead of rows</h3><p>Parquet stores each column separately. That one change lets every column use the encoding that suits it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdzNKYuUXvKpxG3o1ETu4g.png" /></figure><p>Laid out by column, the hierarchy becomes trivial to compress:</p><ul><li>A column like machine is just a handful of distinct strings repeated over and over. Parquet stores a small dictionary once (filler, capper, labeler…) and then only small integer indices.</li><li>A column like event_ts has long runs of the same value, because every sensor publishes in the same second. Runs are encoded once with a count.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/761/1*MZx4aTrRXRYIFXRqP-GZDA.png" /></figure><p>Uncompressed Parquet, with no compression codec at all, is already 15 times smaller than JSON. Encoding alone does most of the work. With zstd the file is 29 times smaller, beats gzipped text, and stays fully queryable by column. Writing it took about 0.4 seconds.</p><h3>Where the bytes go</h3><p>A file size alone doesn’t say what to fix next. Parquet records the compressed size of every column in its metadata, so we can look inside.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCn_R4LP-izCBkmLG-e46A.png" /></figure><p>In the zstd file:</p><ul><li>value takes <strong>3.49 MB</strong> of the 5.52 MB total.</li><li>The two timestamps take 0.81 MB.</li><li>The five hierarchy columns (area, line, machine, metric, unit) still take <strong>1.21 MB</strong>.</li></ul><p>That last number looks like an obvious target. The usual advice for time-series data is to sort by series and then by time, which puts each sensor’s history in one stretch. So that is the next experiment.</p><h3>Surprise 1: sorting made the file bigger</h3><p>Sorting by area, line, machine, metric, event_ts did exactly what was expected for the strings: the hierarchy columns went from 1.21 MB to <strong>0.02 MB</strong>. The values improved as well, from 3.49 MB to 2.51 MB, because neighbouring values now come from the same sensor and look alike.</p><p>The file still went from 5.52 MB <strong>up to 8.18 MB</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwNf6U-VIFfJ7u5tL1Z0Dw.png" /></figure><p>The cost moved to the timestamps:</p><ul><li><strong>In arrival order</strong>, dozens of readings in a row share the same second. The timestamp column is long runs of identical values, which dictionary and run-length encoding handle almost for free.</li><li><strong>Sorted by sensor</strong>, every row has a different timestamp. The dictionary now holds 86,400 distinct seconds, every row needs a 17-bit index into it, and the two timestamp columns grow from 0.81 MB to <strong>5.63 MB</strong>.</li></ul><p>The fix is to store timestamps the way a sorted column wants to be stored: as differences. Delta encoding (DELTA_BINARY_PACKED in Parquet) keeps the first value and then only the gaps: +1000, +2000, +3000 milliseconds. Those gaps fit in a few bits.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*fk8zPj1tQxqTjesQTh237A.png" /></figure><p>The lesson: a sort order is not an optimization on its own. It changes which columns are cheap and which are expensive, and it only pays off when the encodings follow.</p><h3>Surprise 2: the float encoding that didn’t help</h3><p>Parquet also offers BYTE_STREAM_SPLIT, an encoding designed for floating-point data. It regroups the bytes of each float so the compressor sees similar bytes next to each other. It is often recommended for sensor measurements.</p><p>On this data it made the value column <strong>65% larger</strong>: 2.51 MB → 4.13 MB.</p><p>The reason is in the data. The simulator rounds to three decimals, the way most PLCs and gateways report, and report-by-exception only publishes when a value moves. As a result there are only <strong>219,174 distinct values among 1.16 million readings</strong>. That suits dictionary encoding, which byte-stream-split replaces. On raw high-resolution floats the result could well be the opposite. The result belongs to this data, not to the encoding, and that is exactly why it was measured instead of assumed.</p><h3>Surprise 3: the column that was mostly a copy</h3><p>The schema carries two timestamps:</p><ul><li>event_ts: when the value was measured.</li><li>delivered_ts: when it reached the broker.</li></ul><p>They differ only for readings that were buffered during a network outage and forwarded later. That is what store-and-forward means, and the late readings are flagged as historical. In this day that is <strong>22,601 readings, about 2%</strong>. For the other 98%, delivered_ts is an exact copy of event_ts, and it still cost 0.57 MB, about 15% of the file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZmAizDEwmASN_Bl1haGXZA.png" /></figure><p>Storing the delay in milliseconds instead (delay_ms = delivered_ts - event_ts) loses nothing, because the delivery time can always be recomputed. But the column becomes a long run of zeros, broken only by outages, and it shrinks to <strong>0.03 MB</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*b605fi0A_lHz4YjG3vix7Q.png" /></figure><p>In this final file, value is 80% of the bytes and event_ts most of the rest. Everything describing <em>where</em> a reading came from costs almost nothing. What remains is mostly the measurements themselves, which is where a storage format should spend its bytes.</p><h3>The full scoreboard</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wxA945dtspoCshuvwRtYZQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/927/1*TQ_GQ05-pbobo7GbSps3DQ.png" /></figure><p>For 37 signals, the difference is 58 GB a year against 1.1 GB a year. Scaled linearly to a plant with 10,000 signals, it is roughly <strong>15.7 TB against 310 GB</strong>. That is the difference between a storage project and a rounding error.</p><h3>What report-by-exception saves on disk</h3><p>Report-by-exception publishes a value only when it moves past a deadband, or when a heartbeat interval expires. In this factory, sensors took 2,090,880 samples during the day and published 1,158,046 of them, about 55%.</p><p>To see what that is worth on disk, the experiment runs the same day a second time with report-by-exception turned off, and writes both runs as raw JSON and as the best Parquet variant.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*feg-Kv43RCmgcfV8f0v12Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/666/1*9S6bLfcSg7vc69krWLNo-w.png" /></figure><p>In JSON, the saving follows the message count almost exactly, because every message costs the same. In Parquet the saving is smaller, because the readings that report-by-exception drops are exactly the ones that compress best: values that didn’t change, at regular intervals. A good columnar format already removes much of that redundancy on its own.</p><p>Report-by-exception still matters, mainly for the broker, the network and every consumer that has to process each message. For storage, the format decision is worth far more than the publishing policy.</p><h3>What this decides for the table design</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KIfWNH-sx_Wy3NlueZScOQ.png" /></figure><ol><li><strong>Never keep raw JSON as the history.</strong> Even untuned Parquet is 15 times smaller and can be queried by column.</li><li><strong>Use zstd.</strong> On this data it is a third smaller than snappy, at no measurable cost in write time.</li><li><strong>Sort by sensor, then time, inside each file.</strong> The hierarchy columns become nearly free and the values compress better.</li><li><strong>Delta-encode timestamps whenever data is sorted.</strong> Without it, sorting makes things worse.</li><li><strong>Store the delivery delay, not a second timestamp.</strong> The late-data information stays and costs almost nothing.</li><li><strong>Measure before tuning float encodings.</strong> The “right” encoding depends on resolution and on how often values repeat.</li></ol><h3>Limitations</h3><ul><li>This is simulated data from one virtual plant, not a real factory. Real signals have more noise, more resolution and more irregular publishing. The relative ordering of the formats should hold, but the exact ratios will not.</li><li>One day was written as one file. Real ingestion writes many smaller files over time, and each file pays its own overhead. That is a separate problem with its own experiment later in the series.</li><li>Write times come from one laptop, and they compare a Python JSON writer with Arrow’s native writers.</li><li>Nothing here includes table-format metadata yet. The numbers are the pure Parquet cost of the data.</li></ul><p>The next question follows directly: so far every reading has been one row with one value. Part 4 compares that narrow layout with wide and hybrid tables, where one row holds a whole machine.</p><p>The full code, raw results and charts are in the repository: <a href="https://github.com/BuseKaylan/uns-to-lakehouse/tree/main/benchmarks/results/01_storage_footprint">github.com/BuseKaylan/uns-to-lakehouse</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aecad8ffc98d" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/from-137-bytes-to-2-7-how-much-space-does-factory-data-really-take-uns-to-lakehouse-part-3-aecad8ffc98d">From 137 Bytes to 2.7: How Much Space Does Factory Data Really Take? UNS to Lakehouse — Part 3</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Virtual Factory: A Reproducible Testbed for Industrial Data | UNS to Lakehouse — Part 2]]></title>
            <link>https://pub.towardsai.net/building-a-virtual-factory-a-reproducible-testbed-for-industrial-data-uns-to-lakehouse-part-2-01e5c32074e0?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/01e5c32074e0</guid>
            <category><![CDATA[industry-4-0]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[unified-name-space]]></category>
            <category><![CDATA[mqtt]]></category>
            <category><![CDATA[industrial-iot]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Tue, 13 Oct 2026 23:49:51 GMT</pubDate>
            <atom:updated>2026-10-17T11:24:34.637Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqCCnp_mCJraByB1i6Jz9g.png" /></figure><p>You can’t benchmark a factory you don’t have. And even if you have one, you can’t ask it to break down on Tuesday at 10:20, lose its network for six minutes, and do it all again tomorrow for the next experiment.</p><p>In Part 1, we looked at the missing link between the Unified Namespace and the lakehouse, and the questions this series will try to answer with real measurements. Before we can measure anything, we need data that behaves like the real thing, and we need to be able to produce exactly the same data again and again. So in this part, we build a virtual factory.</p><h3>Why Not Just Generate Random Numbers?</h3><p>Random numbers are easy. Realistic factory data is not. The problems we want to study only show up if the simulator reproduces how plants actually behave:</p><ul><li><strong>A hierarchy:</strong> Every value belongs to a site, area, line and machine.</li><li><strong>Report-by-exception:</strong> Devices publish a value only when it changes enough, so silence is normal.</li><li><strong>Machine faults:</strong> Machines stop, and related signals react together.</li><li><strong>Stuck sensors:</strong> A sensor freezes at its last value while the machine keeps running.</li><li><strong>Network outages:</strong> An edge gateway loses its connection, buffers data and sends it late.</li><li><strong>Slow wear:</strong> Some signals drift over days, which is what predictive maintenance looks for.</li></ul><p>If any of these are missing, our experiments would be measuring an idealized world, and the results wouldn’t survive contact with a real plant.</p><h3>The Plant</h3><p>Our virtual factory is a small bottling plant, structured the way most Unified Namespace designs are: <strong>site / area / line / machine / metric</strong>.</p><pre>acme-plant<br>├── filling-area<br>│   ├── line-1      filler, capper, labeler<br>│   └── line-2      filler, capper, labeler<br>└── packaging-area<br>    └── line-3      case-packer, palletizer</pre><p>That’s 8 machines publishing 37 signals. The entire plant lives in a single YAML file, so growing it to 50 machines or adding a new line is a configuration change, not a code change:</p><pre>machine_types:<br>  filler:  [pressure, temperature, speed, vibration, count, state]<br>  capper:  [temperature, speed, vibration, count, state]<br><br>areas:<br>  filling-area:<br>    line-1: [filler, capper, labeler]<br>    line-2: [filler, capper, labeler]<br>  packaging-area:<br>    line-3: [case-packer, palletizer]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iKsweBsj3onSpPBznMZqmQ.png" /></figure><h3>Making Signals Behave</h3><p>Each sensor follows one of three simple models:</p><ul><li><strong>Gauges</strong> (pressure, temperature, speed, vibration) wander around a target value and are constantly pulled back towards it, like a real controlled process. Each one has its own noise level and its own “pull strength”. Vibration also carries a slow upward trend to simulate wear.</li><li><strong>Counters</strong> (bottle count) only grow, and only while the machine is running.</li><li><strong>State</strong> (RUNNING / FAULT) is published whenever it changes.</li></ul><p>When a machine faults, its signals react the way you would expect: speed falls to zero, filler pressure drops towards 120 mbar, vibration fades to background noise, and the counter stops. When the fault clears, everything recovers on its own.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mhJfGlXm60Ge4aXjgVdZTw.png" /></figure><h3>Report-by-Exception: Where Silence Begins</h3><p>Real devices rarely publish every sample. They publish a value only when it moves more than a configured <strong>deadband</strong>, plus a <strong>heartbeat</strong> after a period of silence so subscribers know the device is still alive:</p><pre>pressure:<br>  kind: gauge<br>  mean: 800        # mbar<br>  deadband: 2.0    # publish only if the value moved at least 2 mbar<br>  interval: 1      # sample every second<br>  max_silence: 60  # ...but publish at least once a minute</pre><p>The effect is significant. In one simulated day, the factory took <strong>2,090,880 samples</strong> but published only <strong>1,158,046</strong> of them, about 55%. The other 45% were never sent. That’s efficient for the network, but it means a gap in the data doesn’t automatically mean anything is wrong. Keep this in mind; it comes back in a big way later in the series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VBCrWb6K8NYmmyX-YDkEUA.png" /></figure><h3>When Things Go Wrong</h3><p>Three kinds of trouble are built in, each with its own random schedule:</p><ul><li><strong>Machine faults:</strong> On average a few per machine per day, lasting minutes.</li><li><strong>Frozen sensors:</strong> Occasionally a sensor gets stuck. The machine keeps running, but the sensor keeps reporting the same value through its heartbeats. From the outside, everything looks fine.</li><li><strong>Network outages:</strong> A line’s edge gateway loses its connection for a few minutes. It keeps collecting data, buffers it, and delivers it after reconnecting. This is called <strong>store-and-forward</strong>.</li></ul><p>Outages are where things get interesting for data engineers. Every reading carries two timestamps: when it was <strong>measured</strong> and when it was <strong>delivered</strong>. During an outage, these drift apart by minutes. Any pipeline that relies on arrival time will put these readings in the wrong place. In our simulated day, 22,601 readings arrived late this way.</p><h3>Speaking MQTT: Two Flavours</h3><p>The factory can publish its data in two ways.</p><p><strong>Plain UNS with JSON payloads</strong>, one topic per signal:</p><pre>acme-plant/filling-area/line-2/filler/pressure   {&quot;value&quot;: 812.4, &quot;unit&quot;: &quot;mbar&quot;, &quot;timestamp&quot;: 1767592800000}</pre><p><strong>Sparkplug B</strong>, the more structured option many plants use. Each line becomes an edge node, and each machine becomes a device:</p><ul><li><strong>group_id</strong> → site: acme-plant</li><li><strong>edge node</strong> → area + line: filling-area.line-2</li><li><strong>device</strong> → machine: filler</li></ul><p>Sparkplug adds a small but important protocol on top of MQTT. To see it in action, I wrote a small listener that decodes the traffic. Here’s what happens when the factory starts:</p><pre>NBIRTH filling-area.line-2              bdSeq=0 seq=0<br>DBIRTH filling-area.line-2/filler       seq=1 aliases: pressure=1, temperature=2, speed=3, vibration=4, count=5, state=6<br>DDATA  filling-area.line-2/filler       seq=4   pressure=802.553@06:00:00.000  speed=120.785@06:00:00.000  ...</pre><p>A few things are worth noticing:</p><ul><li><strong>NBIRTH</strong> announces the edge node and carries a <strong>bdSeq</strong> number, the “birth/death sequence”.</li><li><strong>DBIRTH</strong> introduces every metric with its name, its data type and a short numeric <strong>alias</strong>.</li><li><strong>DDATA</strong> messages carry only the aliases, not the names. That keeps messages small, but it means any consumer that missed the birth messages simply cannot tell which value is which.</li><li><strong>seq</strong> counts every message from an edge node from 0 to 255, so subscribers can detect lost messages.</li></ul><p>Now watch what happens at 10:20, when line 2 loses its network connection:</p><pre>NDEATH filling-area.line-2              bdSeq=0<br>...                                     (line 2 is silent for about six minutes)<br>NBIRTH filling-area.line-2              bdSeq=1 seq=0<br>DBIRTH filling-area.line-2/filler       seq=1 aliases: pressure=1, temperature=2, ...<br>DDATA  filling-area.line-2/filler       seq=6   count=28614@10:20:36.000 (historical)  pressure=804.808@10:20:37.000 (historical) ...</pre><p>The broker publishes the node’s <strong>death certificate</strong> (NDEATH). When the gateway comes back, it is reborn with <strong>bdSeq=1</strong>, announces its metrics again, and then flushes six minutes of buffered data, every value flagged as <strong>historical</strong>. The timestamps say 10:20, but the data arrived after 10:27.</p><p>This is exactly the kind of situation our future connector must handle correctly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iEBUsrNCNPiC4xClGuuB7A.png" /></figure><p>All of this comes from a small, dependency-free Sparkplug B encoder and decoder in the project. Writing it by hand turned out to be a great way to understand the protocol, and it’s short enough to read in one sitting.</p><h3>Reproducible by Design</h3><p>Every random decision in the simulator, from sensor noise to fault times to outage lengths, derives from a single <strong>seed</strong> in the config file. Same config, same seed, same data. Always.</p><p>I tested this on two very different machines: my MacBook and a Linux server in the cloud. Both produced exactly <strong>1,158,046 readings</strong> for the same simulated day, with the same faults at the same seconds.</p><p>The simulator also writes a <strong>ground truth</strong> file next to the data: every fault, frozen sensor and outage that really happened, with exact start and end times. This turns out to be very valuable. Later in the series, we won’t just ask “how fast is this pipeline?” but also “how <em>correct</em> are its results?”, and the ground truth is what we’ll compare against.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QvkQcc8cNK8MMg7H7i7J4g.png" /></figure><h3>Try It Yourself</h3><p>Everything in this post is in the project repository: <a href="https://github.com/BuseKaylan/uns-to-lakehouse">https://github.com/BuseKaylan/uns-to-lakehouse</a></p><p>To generate a full day of factory data as Parquet, no broker needed:</p><pre>make install<br>make dataset        # one simulated day in about 13 seconds on my laptop</pre><p>To watch the live factory, start a local MQTT broker and run the simulator and the listener side by side:</p><pre>mosquitto -c docker/mosquitto.conf<br>.venv/bin/unslake simulate --mode sparkplug --duration 1d --speed 60<br>make listen</pre><p>At 60x speed, a full factory day flows by in 24 minutes, outages included.</p><h3>What’s Next?</h3><p>Now that we have a factory that never gets tired, we can start measuring. In <strong>Part 3</strong>, we’ll take one simulated day and store it in several formats: raw MQTT messages as JSON, CSV, and Parquet with different compression settings, sort orders and encodings. The question is simple: how much space does sensor data really take? Some of the early results surprised me.</p><h3>Wrapping Up</h3><p>A good experiment needs a good test environment. Our virtual factory reproduces the behaviours that make industrial data hard: a deep hierarchy, report-by-exception silence, faults, stuck sensors and late data after network outages. It speaks both plain MQTT and Sparkplug B, produces exactly the same data every time, and records the truth so we can check our answers later. With that foundation in place, the measurements can begin.</p><p>Thanks for reading, and see you in Part 3.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=01e5c32074e0" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/building-a-virtual-factory-a-reproducible-testbed-for-industrial-data-uns-to-lakehouse-part-2-01e5c32074e0">Building a Virtual Factory: A Reproducible Testbed for Industrial Data | UNS to Lakehouse — Part 2</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Missing Link in Factory Data: Why a Unified Namespace Isn’t Enough | UNS to Lakehouse — Part 1]]></title>
            <link>https://pub.towardsai.net/the-missing-link-in-factory-data-why-a-unified-namespace-isnt-enough-uns-to-lakehouse-part-1-a7d074b498bf?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/a7d074b498bf</guid>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[industrial-iot]]></category>
            <category><![CDATA[unified-namespace]]></category>
            <category><![CDATA[mqtt]]></category>
            <category><![CDATA[apache-iceberg]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Fri, 09 Oct 2026 22:58:18 GMT</pubDate>
            <atom:updated>2026-10-20T00:41:34.823Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ae4Z0CJcOSU1g6RlIrKpVA.png" /></figure><p>A modern bottling line can produce millions of sensor readings a day. So why is it still so hard to answer a simple question like <em>“Why did our scrap rate go up last month?”</em></p><p>In my previous posts, we focused on getting the core tools of a data platform up and running: Kafka, Airflow, NiFi, Spark and Superset. With this post, I’m starting a new series in a domain where those tools meet a very different kind of data: industrial data coming straight from the factory floor.</p><p>The industrial world has found an elegant way to share this data in real time, called the <strong>Unified Namespace (UNS)</strong>. But real time is only half the story. In this first part, we’ll look at where factory data comes from, what the Unified Namespace solves, and the gap it leaves behind. Let’s dive in.</p><h3>Where Factory Data Is Born?</h3><p>Picture a bottling line. Each machine on that line, the filler, the capper, the labeler, has sensors attached to it. Those sensors are wired to small, rugged industrial computers called <strong>PLCs</strong> (Programmable Logic Controllers). A PLC runs the machine’s logic, for example: <em>“if the temperature goes above 80°C, stop the motor.”</em></p><p>From there, data travels upward through a set of layers that the industry describes with the <strong>ISA-95</strong> model:</p><ul><li><strong>Levels 0–1, Sensors and PLCs:</strong> Raw values, often at millisecond resolution.</li><li><strong>Level 2, SCADA and HMI:</strong> The control screens operators watch all day.</li><li><strong>Level 3, MES (Manufacturing Execution System):</strong> Work orders, batches, quality checks.</li><li><strong>Level 4, ERP:</strong> Orders, costs, inventory. The business side.</li></ul><p>Next to these layers there’s usually a <strong>historian</strong>, a specialized database that stores sensor values as time series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ApDixPPu_yi6UMSphBhmdg.png" /></figure><p>These systems talk to each other using industrial protocols. Older ones like <strong>Modbus</strong> or <strong>Siemens S7</strong> are simple but cryptic. A value might arrive as DB10.DBW4 = 812, and you’d need a separate document to know that this means <em>“filler pressure on line 2.”</em> Newer protocols like <strong>OPC UA</strong> can carry names, units and structure along with the value itself.</p><h3>The Spaghetti Problem</h3><p>In a traditional factory, every system is connected directly to the others. SCADA talks to the PLCs, the historian talks to SCADA, MES talks to the historian, the reporting tool talks to MES… Every new system means a handful of new point-to-point integrations, and every machine replacement risks breaking a chain somewhere.</p><p>As data engineers, this probably sounds familiar. It’s the same pain we’ve felt with tightly coupled data pipelines, just with PLCs instead of microservices.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yvoZTzwl99kDvxn7Z5GWzA.png" /></figure><h3>Enter the Unified Namespace</h3><p>The Unified Namespace replaces this spaghetti with a single hub. Every system <strong>publishes</strong> its data to a central broker, almost always an <strong>MQTT broker</strong>, and anyone who needs that data simply <strong>subscribes</strong> to it. If you’ve worked with Kafka topics, the idea will feel natural.</p><p>The magic is in the naming. Data is published under a meaningful, hierarchical address that mirrors the plant structure:</p><pre>acme-plant/filling-area/line-2/filler/pressure  →  812 mbar</pre><p>Anyone reading this topic knows exactly what the value is and where it comes from. There’s one namespace for the entire plant, which is why it’s called <em>unified</em>.</p><p>On top of plain MQTT, many plants use <strong>Sparkplug B</strong>, an open specification from the Eclipse Foundation that standardizes payloads and adds something really important: state. When a device connects, it publishes a <strong>birth</strong> message describing its metrics. When it disconnects, a <strong>death</strong> message is published. This lets subscribers tell the difference between <em>“no data because the value didn’t change”</em> and <em>“no data because the machine is offline.”</em> Keep this in mind, because we’ll come back to it with real measurements later in the series.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9e2TLXSHHobIitea1IeZUA.png" /></figure><h3>So, What’s Missing?</h3><p>The UNS is fantastic at answering one question: <strong>what is happening right now?</strong></p><p>But factories also ask questions like:</p><ul><li><em>Why did our scrap rate go up last month?</em></li><li><em>What did the vibration sensor look like in the two weeks before this bearing failed?</em></li><li><em>How much energy does it cost us to produce one bottle?</em></li><li><em>Which customer order was produced on which line, at what time, and at what quality?</em></li></ul><p>These questions need <strong>history</strong>, and they need that history <strong>joined with business data</strong> from MES and ERP. A UNS by design carries the current state, not the past. Historians do store the past, but they are often closed, expensive systems, frequently licensed per tag, and getting their data out and joining it with ERP data can be painful. Meanwhile, the data scientists and analysts who could answer these questions often don’t have easy access at all.</p><p>So the scrap rate question from the very beginning isn’t hard because the data doesn’t exist. It’s hard because the data lives in the wrong places, in the wrong shape, for the people asking.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zO-ILd9wBkbyc-ijeLJ_PQ.png" /></figure><h3>Three Ways to Keep History Today</h3><p>Let’s look at the main options plants use today:</p><p><strong>1. Historians</strong> (AVEVA PI and similar)</p><ul><li>✅ Built for industrial time series, mature and reliable</li><li>❌ Often proprietary and costly, hard to query from modern data tools, data stays in a silo</li></ul><p><strong>2. Time-series databases</strong> (InfluxDB, TimescaleDB and similar)</p><ul><li>✅ Fast for recent sensor queries, open-source options available</li><li>❌ Not designed to be the place where you join sensor data with ERP orders and quality records at scale</li></ul><p><strong>3. Open lakehouse</strong> (Apache Iceberg on object storage)</p><ul><li>✅ Cheap storage, open format, readable by Spark, Trino, DuckDB, Snowflake and more, lives next to business data</li><li>❌ Not designed for high-frequency, tiny writes out of the box. Needs careful design for sensor data</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r1tRN9OF05HwnYhh3W4zpw.png" /></figure><p>The lakehouse option is the most interesting one for us data engineers, and the one this series will focus on. It’s also worth saying that these options aren’t mutually exclusive. Many plants will keep a historian or a time-series database for operational use and add a lakehouse for analytics. But building that lakehouse layer is not as simple as it sounds.</p><h3>Why “Just Write MQTT to Iceberg” Isn’t That Simple</h3><p>At first glance, the solution looks trivial: subscribe to the broker, write everything to an Iceberg table, done.</p><p>In practice, sensor data comes with some very specific challenges:</p><ol><li><strong>Losing context.</strong> The topic acme-plant/filling-area/line-2/filler/pressure is just a string. Store it as-is, and a query like <em>“average pressure across all line-2 machines”</em> becomes slow and awkward. The hierarchy needs to become real columns and a smart partitioning strategy.</li><li><strong>Narrow or wide tables?</strong> One row per measurement is flexible but produces billions of rows. One column per sensor is analysis-friendly, but the schema changes every time a sensor is added. Which one wins, and when?</li><li><strong>What does silence mean?</strong> No data for 10 minutes might mean the value didn’t change, or the machine was offline. Ignore Sparkplug’s birth and death messages, and your uptime calculations can quietly go wrong.</li><li><strong>Late and out-of-order data.</strong> When the network drops, edge devices buffer their data and send it in a burst when they reconnect, sometimes hours later. That data has to land in the right place in time.</li><li><strong>The small files problem.</strong> Thousands of tiny messages per second, written naively, turn an Iceberg table into millions of tiny files, and queries slow to a crawl.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JM9hY9AlWrYDk1XwTThIzw.png" /></figure><p>None of these challenges are new on their own, but there’s surprisingly little practical, measured guidance on solving them <em>together</em>, specifically for factory data. That’s the gap I want to explore.</p><h3>The Questions This Series Will Answer</h3><p>Here’s what we’ll investigate, with real experiments and published numbers:</p><ul><li>How much space does raw sensor data <strong>actually</strong> take when stored in Parquet?</li><li>Narrow vs. wide vs. hybrid tables: which design works best for typical factory queries?</li><li>How often should we commit to Iceberg to balance data freshness and query speed?</li><li>How far can a Python ingestion pipeline go before it becomes the bottleneck?</li><li>How wrong do analytics get when we ignore Sparkplug’s state messages?</li><li>Can we turn raw signals into meaningful events like <em>“Filler on line 2 was down from 14:02 to 14:19”</em>, and test those rules on historical data before going live?</li></ul><p>All experiments will run on the same reproducible setup, and every script and raw result will be published on GitHub.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n0yg4TeN-GQvkMx_a_MbPA.png" /></figure><p>The Unified Namespace solved a real problem for factories: getting live data out of silos and into one well-organized place. But live data is only half the story. To answer questions about scrap, downtime, energy and quality, that data needs to become history, sitting right next to the business data that gives it meaning. That bridge is surprisingly under-documented, and over this series we’ll measure it, learn from it and build it in the open. In the next part, we’ll start with the foundation for every experiment: a virtual factory that publishes realistic sensor data over MQTT.</p><p>Thanks for reading, and see you in Part 2, where our virtual factory comes to life.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a7d074b498bf" width="1" height="1" alt=""><hr><p><a href="https://pub.towardsai.net/the-missing-link-in-factory-data-why-a-unified-namespace-isnt-enough-uns-to-lakehouse-part-1-a7d074b498bf">The Missing Link in Factory Data: Why a Unified Namespace Isn’t Enough | UNS to Lakehouse — Part 1</a> was originally published in <a href="https://pub.towardsai.net/">Towards AI</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Kafka Installation on Ubuntu: Everything You Need to Get Started]]></title>
            <link>https://blog.devgenius.io/apache-kafka-installation-on-ubuntu-everything-you-need-to-get-started-9175e7fed725?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9175e7fed725</guid>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[realtime-data-streaming]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[kafka]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Sun, 05 Jul 2026 00:07:08 GMT</pubDate>
            <atom:updated>2026-07-06T11:11:23.826Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rTF_YfYEbDC708zAsvwkMw.png" /></figure><p>Welcome back, data engineering enthusiasts! In our journey through the world of distributed systems and big data, we’ve already explored powerful tools like Spark for large-scale processing, NiFi for seamless data flow orchestration, and Elasticsearch for lightning-fast search and analytics. Today, we take an exciting step forward into the heart of real-time data streaming — Apache Kafka.</p><p>Imagine a system where data flows continuously like a river, where producers and consumers are perfectly decoupled, and where millions of events can be processed in real time without breaking a sweat. That’s exactly what Apache Kafka brings to the table. Designed for high-throughput, fault-tolerant, and scalable event streaming, Kafka has become the backbone of modern data architectures.</p><p>In this guide, we’ll walk through installing and configuring Apache Kafka on an Ubuntu 22.04 environment. Whether you’re building real-time analytics pipelines, event-driven microservices, or streaming data platforms, this setup will give you a solid foundation to start working with Kafka in a production-like environment.</p><p>So, buckle up and get ready to dive into the world of distributed streaming. By the end of this guide, you’ll have a fully functional Kafka setup running on Ubuntu, capable of producing and consuming real-time data streams with ease.</p><p>Let’s start by ensuring our system is ready for installation. First, we need to update the package list and install Java, since Kafka runs on the Java Virtual Machine. Apache Kafka requires a compatible JDK version (commonly OpenJDK 11 or newer), so we begin with installing it on our Ubuntu 22.04 instance.</p><p>Begin by running the following commands:</p><pre>sudo apt update<br>sudo apt install openjdk-11-jdk -y</pre><p>Once Java is installed, you can verify the installation by checking the version:</p><pre>java -version</pre><p>After confirming Java is installed successfully, the next step is to create a dedicated user for Kafka. This is a recommended best practice to isolate Kafka from system-level processes and improve security.</p><pre>sudo adduser kafka<br>sudo usermod -aG sudo kafka</pre><p>Now switch to the Kafka user:</p><pre>su - kafka</pre><p>Next, we’ll download Apache Kafka binaries from the official Apache mirrors. Always make sure to download a stable version compatible with your environment. For this guide, we’ll use Kafka with ZooKeeper-based configuration (traditional setup).</p><pre>wget https://downloads.apache.org/kafka/3.7.0/kafka_2.13-3.7.0.tgz<br>tar -xvzf kafka_2.13-3.7.0.tgz<br>mv kafka_2.13-3.7.0 kafka</pre><p>After extracting Kafka, navigate into the directory:</p><pre>cd kafka</pre><p>Now, before starting Kafka, we need to ensure that ZooKeeper is running, since Kafka relies on it for cluster coordination in this setup. Start ZooKeeper using the following command:</p><pre>bin/zookeeper-server-start.sh config/zookeeper.properties</pre><p>Open a new terminal session (or screen session), and start the Kafka broker:</p><pre>bin/kafka-server-start.sh config/server.properties</pre><p>At this point, Kafka is up and running on your Ubuntu machine.</p><p>Next, let’s create a test topic to verify our setup. A topic in Kafka is where data is published and consumed.</p><pre>bin/kafka-topics.sh --create --topic test-topic --bootstrap-server localhost:9092 --partitions 1 --replication-factor 1</pre><p>You can list the created topics using:</p><pre>bin/kafka-topics.sh --list --bootstrap-server localhost:9092</pre><p>Now, let’s produce some messages into our topic:</p><pre>bin/kafka-console-producer.sh --topic test-topic --bootstrap-server localhost:9092</pre><p>And in another terminal, consume those messages:</p><pre>bin/kafka-console-consumer.sh --topic test-topic --from-beginning --bootstrap-server localhost:9092</pre><p>If everything is set up correctly, you’ll see messages flowing in real time — your first step into the world of streaming data is complete.</p><p>Finally, to make Kafka more production-ready, you can configure systemd services for both ZooKeeper and Kafka so they run automatically on boot. This ensures your streaming infrastructure remains persistent even after system restarts.</p><p>As we wrap up this guide, you’ve successfully installed and configured Apache Kafka on Ubuntu. You’re now ready to build real-time data pipelines, event-driven architectures, and scalable streaming applications.</p><p>Stay tuned for more hands-on guides, where we’ll continue exploring modern data engineering tools, architectures, and best practices!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9175e7fed725" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/apache-kafka-installation-on-ubuntu-everything-you-need-to-get-started-9175e7fed725">Apache Kafka Installation on Ubuntu: Everything You Need to Get Started</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Big Data Processing with AWS EMR & Zeppelin: A Step-by-Step Guide]]></title>
            <link>https://blog.devgenius.io/big-data-processing-with-aws-emr-zeppelin-a-step-by-step-guide-4f8174574686?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f8174574686</guid>
            <category><![CDATA[amazon]]></category>
            <category><![CDATA[zeppelin]]></category>
            <category><![CDATA[emr]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-emr]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 04:07:19 GMT</pubDate>
            <atom:updated>2025-04-09T17:40:56.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*gCJQqyiDH6BJjn_Ly20Ygg.png" /></figure><p>Embarking on another exciting chapter in our data engineering journey! In previous posts, we’ve tackled building data pipelines, orchestrating workflows, and leveraging cloud services to handle large-scale data processing.</p><p>Today, we’re diving into <strong>AWS EMR (Elastic MapReduce)</strong> — a powerful managed platform designed to run big data frameworks like <strong>Apache Spark and Zeppelin</strong> with ease. If you’re looking for a scalable solution to process massive datasets in the cloud, this guide is for you. We’ll cover:</p><ul><li>Setting up an <strong>AWS EMR cluster</strong>,</li><li>Connecting to the <strong>Master Node</strong>,</li><li>Using <strong>Zeppelin for interactive data analysis</strong>.</li></ul><p>By the end of this tutorial, you’ll have a fully operational EMR setup, ready to process and analyze data efficiently.</p><p>Let’s jump right in!</p><p>In today’s world of big data, processing large datasets efficiently is a key challenge for businesses and data engineers. <strong>AWS EMR (Elastic MapReduce)</strong> is a fully managed cloud-based service that simplifies running big data frameworks like <strong>Apache Spark, Hadoop, Hive, and Zeppelin</strong> on Amazon Web Services.</p><h4>🚀 What is AWS EMR?</h4><p>AWS EMR is a <strong>scalable and cost-effective</strong> solution designed to process and analyze vast amounts of data. Instead of managing infrastructure manually, EMR allows users to <strong>quickly deploy clusters</strong> and focus on data processing. It automatically scales resources based on workload, ensuring optimal performance while keeping costs under control.</p><h4>🏗️ Key Components of AWS EMR</h4><ol><li><strong>Master Node</strong> — Manages the cluster and distributes tasks.</li><li><strong>Core Nodes</strong> — Perform data processing and store data.</li><li><strong>Task Nodes</strong> — Handle additional compute-intensive tasks.</li></ol><p>By distributing workloads across multiple nodes, <strong>EMR accelerates data processing</strong> compared to traditional on-premise solutions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/0*-iFm-c4Al3eCm7w-.png" /></figure><h4>💡 Why Use AWS EMR?</h4><ul><li><strong>Easy Setup</strong> — Deploy clusters with just a few clicks.</li><li><strong>Auto-Scaling</strong> — Adjusts resources based on demand.</li><li><strong>Cost-Effective</strong> — Pay only for what you use, with the option to leverage <strong>Spot Instances</strong> for further savings.</li><li><strong>Integrated with AWS</strong> — Seamlessly connects with <strong>S3, Redshift, RDS, and other AWS services</strong>.</li><li><strong>Supports Popular Tools</strong> — Run <strong>Apache Spark, Hadoop, Hive, Pig, and Zeppelin</strong> without complex configurations.</li></ul><h4>🔗 How Does AWS EMR Work?</h4><ol><li><strong>Data Ingestion</strong> — Load data from sources like <strong>Amazon S3, RDS, or DynamoDB</strong>.</li><li><strong>Processing</strong> — Use <strong>Spark, Hive, or other tools</strong> to clean, transform, and analyze data.</li><li><strong>Storage &amp; Output</strong> — Store processed data in <strong>S3, Redshift, or other AWS databases</strong> for further use.</li></ol><h4>🌟 Real-World Use Cases</h4><ul><li><strong>Data Analytics</strong> — Process logs, transaction data, or user behavior insights.</li><li><strong>Machine Learning</strong> — Train ML models using <strong>Spark MLlib</strong> on massive datasets.</li><li><strong>ETL Pipelines</strong> — Automate data transformations and load data into warehouses.</li></ul><p>Now, let’s create EMR cluster!</p><ol><li>Sign in to your <strong>AWS Management Console</strong>.</li><li>Go to the <strong>EMR service</strong> page.</li><li>Click the <strong>“Create Cluster”</strong> button to start the setup process.</li></ol><p>On the <strong>Cluster Configuration</strong> page:</p><ol><li>Enter a <strong>name</strong> for your cluster (e.g., <em>my-emr-cluster</em>).</li></ol><p>2. Select the <strong>EMR release version</strong>.</p><p>3. Choose a version that supports <strong>Zeppelin.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/792/1*oJucHo0eilf1IVaXN_fc4Q.png" /></figure><p>AWS EMR allows you to install pre-configured <strong>application bundles</strong> based on your use case:</p><ul><li><strong>Core Big Data Applications</strong> — Includes Hadoop, Hive, and Spark.</li><li><strong>Spark &amp; Zeppelin</strong> — A great choice for interactive data analysis.</li><li><strong>Presto</strong> — Optimized for low-latency SQL-based queries.</li></ul><p>For this guide, select <strong>“Spark &amp; Zeppelin”</strong>, which includes <strong>Apache Spark</strong> (for distributed computing) and <strong>Zeppelin</strong> (for interactive notebooks).</p><ol><li><strong>Instance Type:</strong> Choose instance types based on your workload.</li></ol><ul><li>For small-scale testing: <strong>m5.xlarge</strong> (4 vCPUs, 16GB RAM).</li><li>For larger workloads: <strong>r5.2xlarge</strong> or higher.</li></ul><p><strong>2. Number of Instances:</strong></p><ul><li><strong>1 Master Node</strong> — Manages the cluster and job execution.</li><li><strong>2+ Core Nodes</strong> — Perform the actual computations.</li><li>(Optional) <strong>Task Nodes</strong> — Extra compute nodes for heavy workloads.</li></ul><p>💡 <em>Tip:</em> If cost is a concern, consider using <strong>Spot Instances</strong> for core or task nodes to save on pricing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/795/1*vZforPX6Y0OzTw4I417_ZA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*hdnX9y9qyG9EkG98z7HQHw.png" /></figure><p>Proper networking setup is crucial for your <strong>AWS EMR cluster</strong> to communicate with other services and allow secure access. In this step, you’ll define the <strong>VPC, Subnet, and Security Groups</strong> for your cluster.</p><h4>1️⃣ Choose a VPC (Virtual Private Cloud)</h4><ul><li>The <strong>VPC</strong> determines the network where your EMR cluster will run.</li><li>You can select an <strong>existing VPC</strong> or create a <strong>new one</strong> under <strong>AWS Console → VPC → Create VPC</strong>.</li><li>Ensure that the selected VPC has <strong>internet access</strong> if you need to install packages or interact with external data sources.</li></ul><h4>2️⃣ Select a Subnet</h4><ul><li>The <strong>Subnet</strong> defines the specific <strong>availability zone</strong> where your cluster will be launched.</li><li>If you plan to access your cluster via <strong>SSH</strong>, choose a subnet that is <strong>publicly accessible</strong> (has an Internet Gateway).</li></ul><h4>3️⃣ Configure Security Groups</h4><p>Security Groups act as a <strong>firewall</strong> controlling inbound and outbound traffic.</p><ul><li><strong>Master Node Security Group:</strong></li><li>Allow <strong>SSH (port 22)</strong> access from your IP (0.0.0.0/0 is not recommended; use your specific IP).</li><li>Open <strong>Zeppelin UI (port 8890)</strong> if you are using Zeppelin for interactive analysis.</li><li><strong>Worker Nodes Security Group:</strong></li><li>Typically, worker nodes do not need direct access from the internet.</li><li>Ensure they can communicate internally with the master node.</li></ul><h4>4️⃣ Enable Auto-Assign Public IP (If Needed)</h4><ul><li>If you plan to <strong>connect to the master node via SSH</strong>, ensure that the <strong>Auto-Assign Public IP</strong> option is enabled for the master node.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*Qvkl-CG5T96KA94gDz6mEA.png" /></figure><p>After that, select an <strong>EC2 Key Pair</strong> for SSH access to the master node (if you don’t have, you should create a new one). Then, choose an <strong>IAM Role</strong> with the necessary <strong>S3 and EMR permissions</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*EfIrYfKLJ2BA_8m9YhPKIQ.png" /></figure><p>For this practice, you need to below IAM service roles (if you work with S3 or any other Amazon services, you should add related service permissions into your EMR roles);</p><p>“EMR_DefaultRole” is given at the below:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Action&quot;: [<br>                &quot;ec2:AuthorizeSecurityGroupEgress&quot;,<br>                &quot;ec2:AuthorizeSecurityGroupIngress&quot;,<br>                &quot;ec2:CancelSpotInstanceRequests&quot;,<br>                &quot;ec2:CreateFleet&quot;,<br>                &quot;ec2:CreateLaunchTemplate&quot;,<br>                &quot;ec2:CreateNetworkInterface&quot;,<br>                &quot;ec2:CreateSecurityGroup&quot;,<br>                &quot;ec2:CreateTags&quot;,<br>                &quot;ec2:DeleteLaunchTemplate&quot;,<br>                &quot;ec2:DeleteNetworkInterface&quot;,<br>                &quot;ec2:DeleteSecurityGroup&quot;,<br>                &quot;ec2:DeleteTags&quot;,<br>                &quot;ec2:DescribeAvailabilityZones&quot;,<br>                &quot;ec2:DescribeAccountAttributes&quot;,<br>                &quot;ec2:DescribeDhcpOptions&quot;,<br>                &quot;ec2:DescribeImages&quot;,<br>                &quot;ec2:DescribeInstanceStatus&quot;,<br>                &quot;ec2:DescribeInstances&quot;,<br>                &quot;ec2:DescribeKeyPairs&quot;,<br>                &quot;ec2:DescribeLaunchTemplates&quot;,<br>                &quot;ec2:DescribeNetworkAcls&quot;,<br>                &quot;ec2:DescribeNetworkInterfaces&quot;,<br>                &quot;ec2:DescribePrefixLists&quot;,<br>                &quot;ec2:DescribeRouteTables&quot;,<br>                &quot;ec2:DescribeSecurityGroups&quot;,<br>                &quot;ec2:DescribeSpotInstanceRequests&quot;,<br>                &quot;ec2:DescribeSpotPriceHistory&quot;,<br>                &quot;ec2:DescribeSubnets&quot;,<br>                &quot;ec2:DescribeTags&quot;,<br>                &quot;ec2:DescribeVpcAttribute&quot;,<br>                &quot;ec2:DescribeVpcEndpoints&quot;,<br>                &quot;ec2:DescribeVpcEndpointServices&quot;,<br>                &quot;ec2:DescribeVpcs&quot;,<br>                &quot;ec2:DetachNetworkInterface&quot;,<br>                &quot;ec2:ModifyImageAttribute&quot;,<br>                &quot;ec2:ModifyInstanceAttribute&quot;,<br>                &quot;ec2:RequestSpotInstances&quot;,<br>                &quot;ec2:RevokeSecurityGroupEgress&quot;,<br>                &quot;ec2:RunInstances&quot;,<br>                &quot;ec2:TerminateInstances&quot;,<br>                &quot;ec2:DeleteVolume&quot;,<br>                &quot;ec2:DescribeVolumeStatus&quot;,<br>                &quot;ec2:DescribeVolumes&quot;,<br>                &quot;ec2:DetachVolume&quot;,<br>                &quot;iam:GetRole&quot;,<br>                &quot;iam:GetRolePolicy&quot;,<br>                &quot;iam:ListInstanceProfiles&quot;,<br>                &quot;iam:ListRolePolicies&quot;,<br>                &quot;iam:PassRole&quot;,<br>                &quot;sdb:BatchPutAttributes&quot;,<br>                &quot;sdb:Select&quot;,<br>                &quot;sqs:CreateQueue&quot;,<br>                &quot;sqs:Delete*&quot;,<br>                &quot;sqs:GetQueue*&quot;,<br>                &quot;sqs:PurgeQueue&quot;,<br>                &quot;sqs:ReceiveMessage&quot;,<br>                &quot;cloudwatch:PutMetricAlarm&quot;,<br>                &quot;cloudwatch:DescribeAlarms&quot;,<br>                &quot;cloudwatch:DeleteAlarms&quot;,<br>                &quot;application-autoscaling:RegisterScalableTarget&quot;,<br>                &quot;application-autoscaling:DeregisterScalableTarget&quot;,<br>                &quot;application-autoscaling:PutScalingPolicy&quot;,<br>                &quot;application-autoscaling:DeleteScalingPolicy&quot;,<br>                &quot;application-autoscaling:Describe*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;iam:CreateServiceLinkedRole&quot;,<br>            &quot;Resource&quot;: &quot;arn:aws:iam::*:role/aws-service-role/spot.amazonaws.com/AWSServiceRoleForEC2Spot*&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringLike&quot;: {<br>                    &quot;iam:AWSServiceName&quot;: &quot;spot.amazonaws.com&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><p>“EMR_EC2_DefaultRole” is given at below:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Action&quot;: [<br>                &quot;cloudwatch:*&quot;,<br>                &quot;dynamodb:*&quot;,<br>                &quot;ec2:Describe*&quot;,<br>                &quot;elasticmapreduce:Describe*&quot;,<br>                &quot;elasticmapreduce:ListBootstrapActions&quot;,<br>                &quot;elasticmapreduce:ListClusters&quot;,<br>                &quot;elasticmapreduce:ListInstanceGroups&quot;,<br>                &quot;elasticmapreduce:ListInstances&quot;,<br>                &quot;elasticmapreduce:ListSteps&quot;,<br>                &quot;kinesis:CreateStream&quot;,<br>                &quot;kinesis:DeleteStream&quot;,<br>                &quot;kinesis:DescribeStream&quot;,<br>                &quot;kinesis:GetRecords&quot;,<br>                &quot;kinesis:GetShardIterator&quot;,<br>                &quot;kinesis:MergeShards&quot;,<br>                &quot;kinesis:PutRecord&quot;,<br>                &quot;kinesis:SplitShard&quot;,<br>                &quot;rds:Describe*&quot;,<br>                &quot;s3:*&quot;,<br>                &quot;sdb:*&quot;,<br>                &quot;sns:*&quot;,<br>                &quot;sqs:*&quot;,<br>                &quot;glue:CreateDatabase&quot;,<br>                &quot;glue:UpdateDatabase&quot;,<br>                &quot;glue:DeleteDatabase&quot;,<br>                &quot;glue:GetDatabase&quot;,<br>                &quot;glue:GetDatabases&quot;,<br>                &quot;glue:CreateTable&quot;,<br>                &quot;glue:UpdateTable&quot;,<br>                &quot;glue:DeleteTable&quot;,<br>                &quot;glue:GetTable&quot;,<br>                &quot;glue:GetTables&quot;,<br>                &quot;glue:GetTableVersions&quot;,<br>                &quot;glue:CreatePartition&quot;,<br>                &quot;glue:BatchCreatePartition&quot;,<br>                &quot;glue:UpdatePartition&quot;,<br>                &quot;glue:DeletePartition&quot;,<br>                &quot;glue:BatchDeletePartition&quot;,<br>                &quot;glue:GetPartition&quot;,<br>                &quot;glue:GetPartitions&quot;,<br>                &quot;glue:BatchGetPartition&quot;,<br>                &quot;glue:CreateUserDefinedFunction&quot;,<br>                &quot;glue:UpdateUserDefinedFunction&quot;,<br>                &quot;glue:DeleteUserDefinedFunction&quot;,<br>                &quot;glue:GetUserDefinedFunction&quot;,<br>                &quot;glue:GetUserDefinedFunctions&quot;<br>            ]<br>        }<br>    ]<br>}</pre><p>Once your <strong>AWS EMR cluster</strong> is up and running, you need to connect to the <strong>Master Node</strong> to manage and run big data applications like <strong>Hadoop, Spark, and Zeppelin</strong>.</p><p>This guide walks you through securing your SSH key, connecting to the master node, exploring <strong>HDFS</strong>, and running a <strong>PySpark</strong> example.</p><p>Before connecting to the EMR master node, you must adjust the file permissions for your <strong>.pem</strong> key to ensure secure access.</p><p>🔹 <strong>For Windows (PowerShell as Administrator):</strong></p><pre>icacls &quot;path_to_your_file/your_key.pem&quot; /inheritance:r<br>icacls &quot;path_to_your_file/your_key.pem&quot; /grant &quot;your_username:R&quot;<br>icacls &quot;path_to_your_file/your_key.pem&quot; /remove &quot;BUILTIN\Users&quot;<br>icacls &quot;path_to_your_file/your_key.pem&quot; /remove &quot;NT AUTHORITY\Authenticated Users&quot;<br>icacls &quot;path_to_your_file/your_key.pem&quot; /remove &quot;Everyone&quot;</pre><p>🔹 <strong>For Mac/Linux:</strong></p><pre>chmod 400 ~/path_to_your_file/your_key.pem<br>chmod o-rwx ~/path_to_your_file/your_key.pem<br>chmod g-rwx ~/path_to_your_file/your_key.pem</pre><p>Once the SSH key is properly secured, connect to the <strong>EMR Master Node</strong> using SSH.</p><pre>ssh -i ~/path_to_your_file/your_key.pem hadoop@your_emr_master_public_ip</pre><p>After logging in, you can list files stored in <strong>HDFS</strong>:</p><pre>hdfs dfs -ls /</pre><p>To create a new folder inside HDFS:</p><pre>hdfs dfs -mkdir /user/hadoop/test_folder</pre><p>📌 <em>This is useful for organizing and storing datasets before processing them with Spark or Hadoop.</em></p><p>To launch the <strong>PySpark interactive shell</strong>, run:</p><pre>pyspark</pre><p>Once inside the Spark shell, try running a simple <strong>DataFrame</strong> example:</p><pre>df = spark.createDataFrame([(1, &quot;Alice&quot;), (2, &quot;Bob&quot;)], [&quot;id&quot;, &quot;name&quot;])<br>df.show()</pre><p>📌 <em>This confirms that Spark is working and ready to process data.</em></p><p>Livy is a <strong>REST API service</strong> that allows remote Spark job execution. You can submit a job to Spark via <strong>HTTP requests</strong>.</p><p>Example: Sending a Spark job stored in <strong>Amazon S3</strong>:</p><pre>curl -X POST --data &#39;{&quot;file&quot;: &quot;s3://your-bucket/your-script.py&quot;}&#39; \<br>    -H &quot;Content-Type: application/json&quot; \<br>    http://your_emr_master_public_ip:8998/batches</pre><p>Now that we have set up our <strong>EMR cluster</strong> and connected to the <strong>Master Node</strong>, it’s time to explore <strong>Zeppelin</strong>, an interactive web-based notebook for <strong>big data analytics</strong>. Zeppelin provides an easy way to write and execute <strong>Apache Spark</strong>, <strong>SQL</strong>, and other queries in an interactive environment.</p><p>Now, we’ll walk through <strong>how to access Zeppelin on EMR</strong> and explore its key features.</p><p>1️⃣ Navigate to the <strong>AWS Management Console</strong>.<br>2️⃣ Go to <strong>EMR</strong> → Click on your running <strong>EMR cluster</strong>.<br>3️⃣ Scroll down to the <strong>Applications</strong> section.<br>4️⃣ Locate <strong>Zeppelin</strong> in the list and click on the <strong>Zeppelin UI URL</strong>.</p><p>This will open Zeppelin in a new browser tab. 🎉</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Nc22hGm-s-qVqxyyYWnmg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HRBifH0KHcc4X0HH.png" /></figure><p>📌 <em>Make sure your security group settings allow inbound access to Zeppelin’s port (default: </em><em>8890). If not, update the </em><strong><em>EMR Master Node Security Group</em></strong><em> to allow access.</em></p><p>1️⃣ Click on <strong>Notebook</strong> → <strong>Create a new notebook</strong>.<br>2️⃣ In the first paragraph (cell), type the following Spark SQL command:</p><pre>%sql<br>SHOW DATABASES;</pre><p>3️⃣ Click the <strong>Run</strong> button (▶) or press <strong>Shift + Enter</strong>.</p><p>📌 <em>This command lists all available databases in Spark.</em></p><p>Now, let’s create a sample DataFrame and display it using PySpark:</p><pre>%pyspark<br>df = spark.createDataFrame([(1, &quot;Alice&quot;), (2, &quot;Bob&quot;)], [&quot;id&quot;, &quot;name&quot;])<br>df.show()</pre><p>One of Zeppelin’s powerful features is its <strong>built-in visualization tools</strong>. You can easily convert query results into <strong>bar charts, pie charts, or tables</strong> with just a click.</p><p>For example, try running:</p><pre>%sql<br>SELECT id, name FROM my_table;</pre><p>After execution, click on the <strong>visualization icon</strong> and choose a chart type (e.g., <strong>bar chart, pie chart</strong>).</p><p>📌 <em>This is especially useful for interactive data analysis and dashboarding.</em></p><p>Zeppelin uses <strong>interpreters</strong> to connect with different backend systems like <strong>Spark, Hive, Python, and Shell</strong>.</p><p>To manage or modify interpreters:<br> 1️⃣ Click on <strong>Interpreter</strong> in the top menu.<br> 2️⃣ Locate the <strong>Spark</strong> interpreter and check the configuration (e.g., master=yarn-client).<br> 3️⃣ Restart the interpreter if needed.</p><p>📌 <em>You can also add custom interpreters for different data sources like </em><strong><em>PostgreSQL, Elasticsearch, or Cassandra</em></strong><em>.</em></p><h3>📌 Note: Installing Additional Python Libraries for PySpark in Zeppelin</h3><p>If you plan to use additional Python libraries such as <strong>NumPy</strong>, <strong>Pandas</strong>, or <strong>Matplotlib</strong> in <strong>PySpark</strong>, you need to install them on the <strong>EMR Master Node</strong> before running them inside Zeppelin.</p><p>After installation, restart the <strong>Zeppelin Spark interpreter</strong> to ensure the changes take effect.</p><p>📌 <em>If you’re running a multi-node cluster, you should install the libraries across all nodes using an EMR bootstrap script or by running the installation command on each worker node.</em></p><p>Now, you can seamlessly use these libraries in Zeppelin notebooks with PySpark:</p><pre>%pyspark<br>import numpy as np<br>import pandas as pd<br><br>data = np.random.rand(5,3)<br>df = pd.DataFrame(data, columns=[&#39;A&#39;, &#39;B&#39;, &#39;C&#39;])<br>df</pre><p>This ensures that you can leverage <strong>Python’s rich data processing ecosystem</strong> within Zeppelin while working on <strong>big data analytics</strong>. 🚀</p><h4>💡 Optimizing Costs: Shutting Down Unused EMR Clusters</h4><p>AWS EMR is a powerful tool for big data processing, but it can also be <strong>costly</strong> if not managed properly. Since EMR clusters utilize EC2 instances, storage, and network resources, keeping an idle cluster running can lead to <strong>unnecessary expenses</strong>.</p><p>To <strong>avoid unexpected charges</strong>, it’s important to <strong>terminate your EMR cluster</strong> when it’s no longer needed.</p><h4>🚀 Automating EMR Workflows with Step Functions</h4><p>Instead of keeping an EMR cluster <strong>running continuously</strong>, many organizations <strong>use AWS Step Functions</strong> to start and stop EMR clusters only when needed. This <strong>serverless</strong> approach helps optimize costs by spinning up a cluster, running the necessary processing jobs, and automatically shutting it down once the job is complete.</p><p>A typical <strong>Step Functions workflow</strong> for EMR looks like this:</p><p>✅ <strong>Start an EMR cluster</strong><br>✅ <strong>Submit a Spark job or Hive script</strong><br>✅ <strong>Monitor job execution</strong><br>✅ <strong>Automatically terminate the cluster after completion</strong></p><p>This approach ensures that you only pay for what you use, rather than <strong>incurring high costs for an idle cluster</strong>.</p><p>Congratulations on successfully setting up your AWS EMR cluster and diving into big data processing with Apache Zeppelin!</p><p>You are now ready to scale your data workflows, analyze large datasets, and leverage the power of Apache Spark and other big data tools on AWS. By following this guide, you’ve learned how to set up an EMR cluster, connect to the master node, and use Zeppelin for interactive data analysis.</p><p>Stay tuned for more tutorials and insights on leveraging the cloud for data engineering and automation!</p><p>Thank you for following along! If you have any questions, feedback, or specific topics you’d like me to cover, feel free to leave a comment below.</p><p>Happy big data processing with AWS EMR!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f8174574686" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/big-data-processing-with-aws-emr-zeppelin-a-step-by-step-guide-4f8174574686">Big Data Processing with AWS EMR &amp; Zeppelin: A Step-by-Step Guide</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Airflow on EC2 Ubuntu 24.04: Install, Configure, and Build an API-to-S3 Data Pipeline ]]></title>
            <link>https://blog.devgenius.io/apache-airflow-on-ec2-ubuntu-24-04-install-configure-and-build-an-api-to-s3-data-pipeline-7c215f14c952?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/7c215f14c952</guid>
            <category><![CDATA[apache-airflow]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Sat, 29 Mar 2025 01:22:51 GMT</pubDate>
            <atom:updated>2025-04-02T10:43:18.898Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yQML5LGPcyabW4_f_ZAsig.png" /></figure><p>Welcome back to our ongoing data engineering journey! In previous posts, we’ve explored setting up data pipelines, working with cloud services, and managing large-scale data workflows.</p><p>Today, we’re taking it a step further with <strong>Apache Airflow</strong>, a powerful workflow orchestration tool. If you’re looking to automate data pipelines efficiently, this guide is for you. We’ll walk through <strong>installing and configuring Apache Airflow on Ubuntu 24.04</strong>, setting up a <strong>DAG (Directed Acyclic Graph)</strong>, and creating a workflow that fetches data from an API and stores it in <strong>AWS S3</strong>.</p><p>By the end of this tutorial, you’ll have a fully functional <strong>end-to-end data pipeline</strong> that automates your API-to-S3 workflow with Airflow.</p><p>Let’s dive in!</p><p>Before installing Apache Airflow, we need to ensure that our <strong>Ubuntu 24.04 system</strong> has all the necessary dependencies. The following command installs <strong>Python 3, pip, virtual environment support, and essential system libraries</strong> required for Airflow to function properly:</p><pre>sudo apt update<br>sudo apt install python3<br>sudo apt-get install software-properties-common<br>sudo apt-add-repository universe<br>sudo apt-get install python3-setuptools<br>sudo apt-get install python3-pip<br>sudo apt install python3-venv libpq-dev -y</pre><p>Why are these packages needed?</p><p>✅ <strong>Python 3 &amp; pip</strong> → Apache Airflow is a Python-based tool, so we need Python 3 and its package manager (pip) to install Airflow and its dependencies.</p><p>✅ <strong>python3-venv</strong> → Helps create an <strong>isolated environment</strong> for Airflow, preventing conflicts with system-wide Python packages.</p><p>✅ <strong>libpq-dev</strong> → Required for PostgreSQL, which is commonly used as Airflow’s metadata database.</p><p>✅ <strong>software-properties-common &amp; universe repository</strong> → Ensures that we have access to additional packages needed for various dependencies.</p><p>✅ <strong>python3-setuptools</strong> → Helps manage Python packages more efficiently.</p><p>Now that we have installed the necessary dependencies, the next step is to <strong>set up a virtual environment</strong> for Apache Airflow. A virtual environment helps <strong>isolate Airflow and its dependencies</strong> from system-wide Python packages, preventing version conflicts.</p><p>Run the following commands:</p><pre>python3 -m venv airflow_env<br>source ~/airflow_env/bin/activate<br>python3 -m pip install --upgrade pip</pre><p>Before installing Apache Airflow, we need to install additional system libraries that are required for <strong>database connectivity, security, and cryptographic functions</strong>. These dependencies ensure that Airflow runs smoothly and can interact with various services like MySQL, SSL, Kerberos authentication, and XML security.</p><pre>sudo apt-get install libmysqlclient-dev<br>sudo apt-get install libssl-dev<br>sudo apt-get install libkrb5-dev <br>sudo apt-get install libxmlsec1-dev<br>sudo apt-get install pkg-config</pre><p>✅ <strong>libmysqlclient-dev</strong> → Provides MySQL client development libraries, required if Airflow needs to connect to a <strong>MySQL database</strong> for metadata storage.</p><p>✅ <strong>libssl-dev</strong> → Essential for <strong>secure communications</strong> using SSL/TLS, ensuring encrypted connections.</p><p>✅ <strong>libkrb5-dev</strong> → Required for <strong>Kerberos authentication</strong>, which is used in secure enterprise environments.</p><p>✅ <strong>libxmlsec1-dev</strong> → Provides cryptographic and XML security functions, often needed for <strong>SSO (Single Sign-On) authentication</strong> in Airflow.</p><p>✅ <strong>pkg-config</strong> → A helper tool that manages library paths and dependencies, ensuring proper linking of installed libraries.</p><p>Once these dependencies are installed, we’re ready to <strong>proceed with the Apache Airflow installation</strong> and configuration. 🚀</p><p>We can proceed with <strong>installing Apache Airflow</strong> itself. The following commands will create a dedicated directory for Airflow, set the <strong>AIRFLOW_HOME</strong> environment variable, and install Apache Airflow using pip.</p><pre>mkdir ~/airflow<br>export AIRFLOW_HOME=~/airflow<br>pip install apache-airflow</pre><p>Next, we will configure it and set up the database for Airflow to function properly!</p><p>Now that Apache Airflow is installed, we need to <strong>initialize the metadata database</strong> and create an <strong>admin user</strong> to access the Airflow web interface. The following commands will set up Airflow’s database, create an admin user, and list all available users. (While creating user stage, you should create your sign-in password!)</p><p>Run the following commands:</p><pre>airflow db init<br>airflow users create --username bkaylan --firstname Buse --lastname Kaylan --role Admin --email xxxxx@gmail.com<br>airflow users list</pre><p>At this point, <strong>Apache Airflow is fully initialized</strong>, and we can move on to <strong>configuring DAGs (Directed Acyclic Graphs) to automate data workflows</strong>!</p><p>To enable Airflow to interact with <strong>Amazon S3</strong> and other AWS services, we need to install the <strong>Amazon provider package</strong>. This package contains the necessary hooks, operators, and sensors to connect Airflow with Amazon Web Services.</p><pre>pip install apache-airflow-providers-amazon</pre><p>✅ <strong>amazon provider package</strong> → This package includes the components required to <strong>integrate Apache Airflow with AWS services</strong>, such as <strong>Amazon S3</strong>, <strong>EC2</strong>, <strong>Redshift</strong>, and others.</p><ul><li>For this tutorial, we specifically need it to <strong>push data to Amazon S3</strong> from Airflow.</li><li>It provides <strong>AWS-specific operators</strong> (like S3FileOperator, S3Hook, etc.) that allow you to upload and download files, manage buckets, and perform other S3 operations seamlessly.</li></ul><p>After setting up and configuring Airflow, the next step is to start the <strong>Airflow Webserver</strong> and <strong>Scheduler</strong>. The Webserver provides the <strong>Airflow UI</strong>, where you can monitor and manage your workflows, while the Scheduler handles the execution of tasks according to the defined schedules in your DAGs.</p><p>Start the Airflow Webserver:</p><pre>airflow webserver -p 8080 --daemon</pre><p>This command starts the <strong>Airflow Webserver</strong> and makes the <strong>Airflow UI</strong> accessible at <a href="http://localhost:8080/">http://&lt;AWS_EC2_PUBLIC_IPV4_ADDRESS&gt;:8080</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L8xk6bLIxQnjhMqsex5NBg.png" /></figure><p>After signing into the Airflow web interface, you’ll be directed to the homepage. From here, you can view the list of <strong>DAGs</strong> (Directed Acyclic Graphs) and access various other sections of the Airflow UI, such as logs, task statuses, and more:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y5dCeGVFcYP6D0QXRm_Cpg.png" /></figure><p>Now, we are ready to create our first DAG. First, navigate to the <strong>Airflow UI</strong>. Once logged in, click on <strong>Admin</strong> in the top menu, and then select <strong>Connections</strong> from the dropdown.</p><p>In the <strong>Connections</strong> page, you’ll need to <strong>add a new connection</strong> to enable the integration between Apache Airflow and Amazon S3. This connection will allow your DAGs to interact with S3, upload data, and perform other S3-related tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOuGs0RTvhlGF-rPBxEuFQ.png" /></figure><p>To add a new connection:</p><ol><li>Click the <strong>+</strong> button to add a new connection.</li><li>In the <strong>Conn ID</strong> field, provide a unique identifier for your connection (e.g., S3).</li><li>For <strong>Conn Type</strong>, choose Amazon Web Services.</li><li>Enter your <strong>AWS Access Key</strong> and <strong>Secret Key</strong> in the corresponding fields, or configure other authentication methods (e.g., using an IAM role if running on EC2).</li><li>Fill in the <strong>Extra</strong> field if you need to add additional parameters (e.g., region, session token, etc.). For Amazon S3, you can use the following format to provide your AWS credentials and region:</li></ol><pre>{<br>    &quot;aws_access_key_id&quot;: &quot;xxx&quot;,<br>    &quot;aws_secret_access_key&quot;: &quot;xxx&quot;,<br>    &quot;region_name&quot;: &quot;your_region&quot;<br>}</pre><p>Finally, Save the connection by clicking <strong>Save</strong>.</p><p>Once this connection is configured, you can use it in your DAGs to securely interact with Amazon S3.</p><p>Now, we can move to create a DAG!</p><p>Our example Apache Airflow Directed Acyclic Graph (DAG) automates the process of fetching weather data from an API and uploading it to Amazon S3. The workflow consists of four main tasks: <strong>calling the API, processing the data, saving it to S3, and controlling the flow with dummy operators.</strong></p><p>Let’s go through the code:</p><pre>from datetime import datetime<br>from airflow import DAG<br>import requests<br>from airflow.operators.python_operator import PythonOperator<br>from airflow.operators.dummy_operator import DummyOperator<br>import json<br>from airflow.providers.amazon.aws.hooks.s3 import S3Hook<br><br>def api_call(**kwargs):<br>    ti = kwargs[&#39;ti&#39;]<br>    url = &quot;https://archive-api.open-meteo.com/v1/archive?latitude=41.0138&amp;longitude=28.9497&amp;start_date=2014-01-01&amp;end_date=2024-01-01&amp;hourly=temperature_2m&quot;<br><br>    response = requests.get(url)<br>    data = response.json()<br>    ti.xcom_push(key=&#39;weather_data&#39;, value=json.dumps(data))<br><br>def save_to_s3(**kwargs):<br>    ti = kwargs[&#39;ti&#39;]<br>    weather_data = ti.xcom_pull(task_ids=&#39;API-Call&#39;, key=&#39;weather_data&#39;)<br><br>    s3_hook = S3Hook(aws_conn_id=&#39;S3&#39;) <br>    s3_hook.load_string(<br>        string_data=weather_data,<br>        key=&#39;weather_2010_2024_ist.json&#39;,<br>        bucket_name=&#39;bkaylan21&#39;<br>    )<br><br>with DAG(dag_id=&#39;s3_upload_weather_ist&#39;, schedule_interval=&#39;@daily&#39;, start_date=datetime(2024, 3, 26), catchup=False) as dag:<br>    start_flow = DummyOperator(task_id=&quot;start_flow&quot;)<br><br>    api_hit_task = PythonOperator(<br>        task_id=&#39;API-Call&#39;,<br>        python_callable=api_call,<br>        provide_context=True,<br>    )<br><br>    upload_to_s3 = PythonOperator(<br>        task_id=&#39;save-to-S3&#39;,<br>        python_callable=save_to_s3,<br>        provide_context=True,<br>    )<br><br>    stop_flow = DummyOperator(task_id=&quot;stop_flow&quot;)<br><br>    start_flow &gt;&gt; api_hit_task &gt;&gt; upload_to_s3 &gt;&gt; stop_flow</pre><p>As understood that, in the <strong>save_to_s3</strong> function, we use the following line to connect to S3:</p><pre>s3_hook = S3Hook(aws_conn_id=&#39;S3&#39;)</pre><p>Here, the <strong>aws_conn_id=&#39;S3&#39;</strong> refers to the connection ID that we previously configured in the Airflow UI under <strong>Admin &gt; Connections</strong>. This connection ID must match the one you created for Amazon S3.</p><p>For example, if you named your connection <strong>aws_s3_connection</strong> when setting up the connection in the Airflow UI, you should replace &#39;S3&#39; with &#39;aws_s3_connection&#39;:</p><pre>s3_hook = S3Hook(aws_conn_id=&#39;aws_s3_connection&#39;)</pre><p>Once you have created your <strong>weather_dag.py</strong> file, the next step is to send it to the <strong>example_dags</strong> directory on your EC2 instance. This is the directory where Airflow looks for DAG files to execute. While you can organize your DAG files into different directories, for simplicity, we’ll be sending the file to the default <strong>example_dags</strong> directory.</p><p>However, the <strong>example_dags</strong> directory might be located in different paths depending on how Airflow is configured or installed. To find the exact location of the <strong>example_dags</strong> directory on your EC2 instance, use the following command:</p><pre>sudo find / -type d -name &quot;example_dags&quot; 2&gt;/dev/null</pre><p>This command will return the location of the <strong>example_dags</strong> directory where you should place your <strong>weather_dag.py</strong> file. For my example, this path is “…/python3.12/site-packages/airflow/example_dags”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_fV8IFLdePQb7na7pId5g.png" /></figure><p>The command you provided is used to securely copy the <strong>weather_dag.py</strong> file from your local machine to your EC2 instance. Let’s break it down:</p><pre>scp -i bkaylan.pem C:\weather_dag.py ubuntu@PUBLIC_IP_ADDRESS:/home/ubuntu/airflow_env/lib/python3.12/site-packages/airflow/example_dags/</pre><p>After restarting Airflow, you will be able to see the <strong>weather_dag.py</strong> file in the <strong>DAGs</strong> section of the Airflow homepage. The DAG will appear as a new entry, similar to what is shown in the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ci4fgfkU0ii3-kXsFLDTDw.png" /></figure><p>This means that Airflow has successfully detected the <strong>weather_dag.py</strong> file in the <strong>example_dags</strong> directory, and the DAG is now available to be triggered or scheduled for execution. You can interact with it directly from the Airflow UI, where you can view its status, logs, and schedule, as well as manually trigger or pause it.</p><p>Once the DAG is visible in the <strong>DAGs</strong> section, you can click on it to explore further details, such as task statuses, execution logs, and more.</p><p>Now, you can start the workflow by clicking on the <strong>Trigger</strong> icon (the play button) on the left side of the DAG in the Airflow UI.</p><p>By clicking this icon, you will manually trigger the DAG, initiating the execution of the tasks defined within it. Once triggered, Airflow will start running the tasks according to the specified schedule or as per the manual trigger, and you can monitor its progress in real-time.</p><p>This is an easy way to test or run the workflow immediately without waiting for the scheduled interval.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Y9D6vHJ68NLHAfksNpCwA.png" /></figure><p>After the workflow successfully completes, you will be able to see the file in your <strong>S3 bucket</strong>.</p><p>This means that the data from the API call has been successfully fetched, processed, and uploaded to the specified S3 bucket as part of the DAG execution. You can navigate to your S3 bucket in the AWS Management Console and verify that the file (in this case, <strong>weather_2010_2024_ist.json</strong>) is now stored there:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GHXwxz6_UEKAEAce0F4uPw.png" /></figure><p>Congratulations on successfully setting up Apache Airflow on your Ubuntu 24.04 instance!</p><p>You are now equipped to automate workflows and manage data pipelines seamlessly with Airflow. By following this guide, you’ve learned how to install and configure Airflow, create a DAG to fetch data from an API, and upload it to an AWS S3 bucket.</p><p>In the upcoming posts, I’ll be diving deeper into topics like integrating different services with Amazon, working with Azure for cloud automation, and enhancing workflows for advanced data processing. Stay tuned for more valuable insights and tutorials on cloud services and workflow automation.</p><p>Thank you for following along! If you have any questions, feedback, or specific topics you’d like me to cover, feel free to leave a comment below.</p><p>Happy automating with Apache Airflow!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7c215f14c952" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/apache-airflow-on-ec2-ubuntu-24-04-install-configure-and-build-an-api-to-s3-data-pipeline-7c215f14c952">Apache Airflow on EC2 Ubuntu 24.04: Install, Configure, and Build an API-to-S3 Data Pipeline 🚀</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Launch Apache Superset on Ubuntu 22.04: A Complete Tutorial]]></title>
            <link>https://blog.devgenius.io/how-to-launch-apache-superset-on-ubuntu-22-04-a-complete-tutorial-4f59fa2a1400?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f59fa2a1400</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[superset]]></category>
            <category><![CDATA[apache-superset]]></category>
            <category><![CDATA[apache-superset-install]]></category>
            <category><![CDATA[data-engineering]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Sat, 22 Jun 2024 22:51:08 GMT</pubDate>
            <atom:updated>2024-07-07T12:37:45.052Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k80jXZuif67zKhUpqkG-Zw.png" /></figure><p>Welcome back to our ongoing data engineering journey! In previous posts, we’ve covered the essentials of launching EC2 instances, connecting them with PuTTY, deploying Apache NiFi, and using Elasticsearch and Kibana.</p><p>Today, we’re diving into another powerful data visualization tool: Apache Superset. If you’re looking to explore advanced data analytics and visualization on your Ubuntu 22.04 system, you’re in the right place. In this post, we’ll walk you through the step-by-step process of installing and configuring Apache Superset, so you can start creating stunning dashboards and visual insights from your data.</p><p>Let’s get started!</p><p>Before launching Apache Superset, it’s essential to ensure that Python 3 is installed on your Ubuntu 22.04 instance. You can check if Python 3 is already installed by running the following command:</p><pre>python3 --version</pre><p>If Python 3 is not installed, you can install it using the following command:</p><pre>sudo apt update<br>sudo apt install python3</pre><p>Then, you should install necessary dependencies for launching Apache Superset. Here’s a breakdown of what these packages do:</p><ul><li><strong>build-essential</strong>: A package containing a list of essential tools for building software.</li><li><strong>libssl-dev</strong>: A package for Secure Sockets Layer (SSL) development libraries.</li><li><strong>libffi-dev</strong>: A package for Foreign Function Interface (FFI) development libraries.</li><li><strong>python3-dev</strong>: Header files and a static library for Python 3, necessary for compiling Python extensions.</li><li><strong>python3-pip</strong>: The package installer for Python, allowing you to install and manage additional Python packages.</li><li><strong>libsasl2-dev</strong>: Development files for Cyrus SASL, which is used for authentication.</li><li><strong>libldap2-dev</strong>: Development files for the OpenLDAP libraries, necessary for integrating with LDAP directories.</li><li><strong>default-libmysqlclient-dev</strong>: Development files for MySQL client libraries, essential if you plan to use MySQL as the backend database for Superset.</li></ul><p>You can run the following command to install them for Apache Superset:</p><pre>sudo apt-get install build-essential libssl-dev libffi-dev python3-dev python3-pip libsasl2-dev libldap2-dev default-libmysqlclient-dev</pre><p>After installing the necessary dependencies, you should install setuptools.The setuptools package is an essential Python tool that aids in the installation, building, and distribution of Python packages. It ensures that your environment can handle the various Python modules and dependencies that Apache Superset requires. Without setuptools, you might encounter issues when trying to install or manage Python packages within your virtual environment.</p><p>By installing setuptools, you’re ensuring that your system is properly configured to manage Python packages efficiently, which is crucial for the smooth installation and operation of Apache Superset.</p><p>You should run the following command to install setuptools:</p><pre>sudo apt-get install python3-setuptools</pre><p>After installing setuptools, you should upgrade pip and setuptoolsby running the following command:</p><pre>pip3 install --upgrade pip<br><br>pip install --upgrade setuptools pip</pre><p>Then, you should create a virtual environment with the following command:</p><pre>python3 -m venv supersetenv</pre><p>Creating a virtual environment is a best practice for Python projects. It helps you manage dependencies by isolating your project’s packages from the global Python environment. This isolation prevents potential conflicts between package versions used by different projects and ensures that your Apache Superset installation remains clean and manageable.</p><p>For activating this virtual environment, you should run this command:</p><pre>source supersetenv/bin/activate</pre><p>When the virtual environment is activated, your command prompt will change to indicate that you are now working within the supersetenv environment. Any Python packages you install while this environment is active will be contained within it, ensuring that they do not interfere with other Python projects on your system.</p><p>Now, you should install the Pillow library with the following command:</p><pre>pip install Pillow</pre><p>Pillow is a powerful library for image processing in Python, which Apache Superset uses for handling image uploads and generating thumbnails. By installing Pillow, you ensure that Superset can effectively manage and process images, enhancing the overall functionality and user experience.</p><p><strong>To install Pillow and Superset within your virtual environment, make sure the environment is activated!</strong> (you should see the (supersetenv) prefix in your terminal prompt).</p><p>With Pillow installed, you have now prepared your environment for the Apache Superset installation, ensuring that all image-related functionalities will work seamlessly.</p><p>Now, we can proceed with installing Apache Superset itself.</p><p>You can install Apache Superset by running the following command:</p><pre>pip install apache-superset</pre><p>Next, you should set the FLASK_APP environment variable to superset by running the following command:</p><pre>export FLASK_APP=superset</pre><p>Setting the FLASK_APP environment variable tells Flask (the web framework that powers Apache Superset) where to find your application. This is necessary for managing and running the Superset application.</p><p>After that, you should generate a secret key using OpenSSL by running the following command:</p><pre>openssl rand -base64 42</pre><p><strong>This command generates a random string of characters, which will be used as a secret key for both authentication and connecting Elasticsearch with Superset configurations.</strong></p><p><strong>It’s important to save this key securely, as you’ll need it in the next steps and parts!!</strong></p><p>Then, you should set the SUPERSET_SECRET_KEY environment variable by running the following command, replacing with the secret key you generated and saved in the previous step:</p><pre>export SUPERSET_SECRET_KEY=dlkfnrgernegnerge2342/sdnoewe</pre><p>With SUPERSET_SECRET_KEY properly configured, you&#39;re now ready to proceed with configuring Apache Superset to connect to your data sources and setting up authentication methods. This will enable you to start creating dashboards and visualizations with Superset on your Ubuntu 22.04 instance.</p><p>Now, you should run the following command to apply any database migrations needed by Apache Superset:</p><pre>superset db upgrade</pre><p>This command updates the Superset database schema to the latest version. It’s essential to run this command after installing or upgrading Apache Superset to ensure that the database structure is up-to-date and compatible with the current version of Superset.</p><p>During this process, Superset will apply any necessary changes to the database schema, such as creating or updating tables. It’s normal to see some output indicating the migration steps being performed.</p><p>Once the superset db upgrade command completes successfully, your Superset database will be ready to use with the latest schema changes applied. This step is crucial for the proper functioning of Superset and for enabling its various features and functionalities.</p><p>With the database upgrade completed, you’re now ready to proceed with creating an admin user and starting the Apache Superset web server. This will allow you to begin using Superset for data visualization and exploration on your Ubuntu 22.04 instance.</p><p>Next, you should create an admin user for Apache Superset by running the following command:</p><pre>superset fab create-admin</pre><p>This command will prompt you to enter details for the admin user, including username, first name, last name, email address, and password. Follow the prompts and fill in the required information accordingly.</p><p>Here’s how you can fill in the prompts:</p><ul><li><strong>Username</strong>: Enter a username for the admin user.</li><li><strong>First name</strong>: Enter the first name of the admin user.</li><li><strong>Last name</strong>: Enter the last name of the admin user.</li><li><strong>Email address</strong>: Enter the email address of the admin user.</li><li><strong>Password</strong>: Enter a secure password for the admin user.</li></ul><p>After filling in all the required information, Superset will create the admin user in the database. This admin user will have full access to Superset and can manage users, databases, dashboards, and other settings within the application.</p><p>Creating an admin user is essential for managing and administering Apache Superset. It allows you to configure and customize Superset according to your needs and preferences.</p><p>Now, you should initialize Apache Superset by running the following command:</p><pre>superset init</pre><p>Finally, you can start the Apache Superset web server by running the following command:</p><pre>superset run -h 0.0.0.0 -p 8080</pre><p>Here’s what each option does:</p><ul><li><strong>-h 0.0.0.0</strong>: Specifies the hostname or IP address on which Superset will listen. 0.0.0.0 means it will listen on all available network interfaces, allowing access from any IP address.</li><li><strong>-p 8080</strong>: Specifies the port number (8080 in this case) on which Superset will run. You can choose a different port if 8080 is already in use.</li></ul><p>After running this command, Superset will start and you should see output in your terminal indicating that the server is running. You can now open a <strong>Firefox</strong> web browser and navigate to <a href="http://localhost:8099/">http://&lt;AWS_EC2_IP&gt;:808</a>0</p><p>Apache Superset works on Firefox, so you can open it by this browser.</p><p><strong>If you are running Apache Superset on an AWS EC2 instance, you may need to adjust the security group configuration to allow inbound traffic on port 8080.</strong></p><p>You have successfully set up Apache Superset on your Ubuntu instance. You can now log in using the username and password you created during the setup process.</p><p>If you want to connect Apache Superset to Elasticsearch, follow these steps:</p><ol><li>Click on the <strong>Datasets</strong> menu in the top navigation bar of Superset.</li><li>Click on <strong>+ New Dataset</strong> to create a new dataset.</li><li>Choose <strong>Elasticsearch</strong> as the database type.</li><li>Fill in the connection information using one of the following connection strings, depending on whether you are using HTTP or HTTPS, replacing {user}, {password}, and {host} with your Elasticsearch credentials, and save it:</li></ol><ul><li>For HTTP: elasticsearch+http://{user}:{password}@{host}:9200/</li><li>For HTTPS: elasticsearch+https://{user}:{password}@{host}:9200/</li></ul><p><strong>Note: </strong>The default credentials for Elasticsearch may vary depending on the version and installation source. Commonly used default credentials are:</p><ul><li>Username: elastic</li><li>Password: changeme</li></ul><p>Apache Superset will then connect to your Elasticsearch instance, allowing you to explore and visualize data stored in Elasticsearch using Superset’s powerful dashboarding capabilities!</p><p>Congratulations on successfully setting up Apache Superset on your Ubuntu 22.04 instance!</p><p>You are now ready to leverage its powerful features for data visualization and exploration. By following this guide, you have learned how to install Superset, connect it to Elasticsearch, and start creating insightful dashboards.</p><p>Looking ahead, I am planning to write more posts on related topics, including launching Apache Airflow for workflow automation, setting up a DAG (Directed Acyclic Graph) code editor, and using Airflow to fetch APIs and store data in an S3 bucket.</p><p>Stay tuned for these upcoming posts by following my blog. If you have any questions, feedback, or topics you would like me to cover, feel free to leave a comment below.</p><p>Thank you for reading, and happy data exploring with Apache Superset!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f59fa2a1400" width="1" height="1" alt=""><hr><p><a href="https://blog.devgenius.io/how-to-launch-apache-superset-on-ubuntu-22-04-a-complete-tutorial-4f59fa2a1400">How to Launch Apache Superset on Ubuntu 22.04: A Complete Tutorial</a> was originally published in <a href="https://blog.devgenius.io/">Dev Genius</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamline Your Data Pipelines: Apache NiFi in Action]]></title>
            <link>https://medium.com/@busekaylan/streamline-your-data-pipelines-apache-nifi-in-action-e9c5e50dc284?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/e9c5e50dc284</guid>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[apache-nifi]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Sun, 19 May 2024 20:37:09 GMT</pubDate>
            <atom:updated>2024-05-19T20:37:09.508Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZYlgJRO0FrXgmEWC58k4UQ.png" /></figure><p>Hello and welcome back to our blog series on data integration and visualization!</p><p>In our previous blog posts, we explored the steps to launch Apache NiFi on EC2, as well as deploying Elasticsearch and Kibana on EC2. Now, it’s time to dive deeper into the capabilities of Apache NiFi and demonstrate its power in creating seamless data flows.</p><p>Apache NiFi is a robust, open-source tool designed for automating and managing the flow of data between systems. It excels in moving data from diverse sources to various destinations, transforming and enriching it along the way. In this post, we’ll walk through a practical example of using NiFi to construct a data pipeline that ingests data from AWS S3 and sends it to Elasticsearch, where it can be visualized in Kibana.</p><p>We’ll cover the essential steps to set up this data flow, highlighting key features and configurations in NiFi that enable efficient data ingestion, transformation, and routing. By the end of this guide, you’ll have a solid understanding of how to leverage NiFi to bridge data between AWS S3 and Elasticsearch, empowering you to visualize and analyze your data effortlessly in Kibana. Whether you’re new to NiFi or looking to expand your data integration skills, this tutorial will provide valuable insights and practical knowledge for your projects.</p><p>If you don’t know how to launch and start Apache NiFi, you can read my previous blog post on how to launch and configure Apache NiFi on EC2 by following this link:</p><p><a href="https://medium.com/@busekaylan/mastering-data-ingestion-apache-nifi-setup-on-ubuntu-22-04-ec2-b66aa654883c">Mastering Data Ingestion: Apache NiFi Setup on Ubuntu 22.04 EC2 | by Buse Kaylan | May, 2024 | Medium</a></p><p>Let’s get started on building this data pipeline and see how NiFi can streamline your data management tasks!</p><p>When we open the NiFi page, we are greeted by a user-friendly interface. This checkered canvas is where we create our data flows using various processors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/807/1*E_-dGVoo8hwW2p1nniER-w.png" /></figure><p>At the top of the page, there is a components toolbar with several important buttons. Here are the main components and their uses:</p><ol><li><strong>Processor: </strong>The core building block of NiFi, processors are used to execute various tasks such as ingesting, routing, transforming, and processing data. Each processor has its own specific function and can be configured with different properties.</li><li><strong>Input Port: </strong>Used to receive data from external sources or other NiFi instances. Input ports are essential when data needs to be ingested into a process group.</li><li><strong>Output Port:</strong> Used to send data out to external destinations or other NiFi instances. Output ports are crucial for exporting data from a process group.</li><li><strong>Process Group: </strong>A way to organize and encapsulate a set of processors and other components into a single unit. Process groups help in managing complex data flows by breaking them down into smaller, more manageable sections.</li><li><strong>Remote Process Group: </strong>Allows NiFi to connect and interact with remote instances of NiFi. This is useful for distributing data flows across multiple NiFi instances in different locations.</li><li><strong>Funnel: </strong>Used to merge data from multiple connections into a single stream. Funnels help in consolidating data flows for easier management.</li><li><strong>Template: </strong>Enables you to create and reuse predefined configurations of processors, process groups, and connections. Templates save time and ensure consistency when deploying similar data flows.</li><li><strong>Label: </strong>Provides a way to add descriptive text to the canvas. Labels are useful for documenting and organizing the components within your data flow.</li></ol><p>At the left of the page, there is a <strong>“Navigate”</strong> window. This window shows an overview of your entire NiFi canvas, allowing you to quickly navigate to different parts of your data flow. It provides a mini-map of your canvas, making it easier to manage and visualize large and complex data flows. By clicking and dragging within the Navigate window, you can move to different sections of your data flow without having to zoom in and out on the main canvas.</p><p>In this example, we use processors to build our data flow. Processors will be configured to handle data ingestion from AWS S3, transform the data as needed, and then route it to Elasticsearch for indexing. This setup allows us to visualize and analyze the data in Kibana.</p><p>Firstly, we should add the <strong>ListS3</strong> processor for this example because it allows us to list objects in an AWS S3 bucket. With this processor, we can retrieve metadata about the objects stored in S3, which is the first step in our data ingestion process.</p><p>The <strong>ListS3</strong> processor is essential because it initiates the data flow by identifying the files in the S3 bucket that need to be processed. This processor periodically polls the specified S3 bucket and generates FlowFiles for each object it finds, which can then be processed by subsequent processors.</p><p>You can add the processor using the drag-and-drop method with the <strong>“Processor”</strong> button. Here’s how to do it:</p><ol><li>Drag and drop <strong>“Processor”</strong> button in the components toolbar at the top of the page.</li><li>A new window will appear, allowing you to search for and select the desired processor. Type <strong>“ListS3”</strong> in the search bar and select the ListS3 processor from the list.</li><li>You can see the ListS3 processor onto the canvas.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*XRyiXFFDL4H-w7jV-oGfoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/564/1*U6pUzOqak4Wxh0a-OkcqqA.png" /></figure><p>Once the ListS3 processor is on the canvas, you need to configure it:</p><ul><li><strong>Bucket: </strong>Specify the name of the S3 bucket you want to list.</li><li><strong>Access Key and Secret Key:</strong> Provide your AWS credentials (if you don’t use public bucket).</li><li><strong>Region:</strong> Specify the AWS region where your S3 bucket is located.</li></ul><p>After configuring the <strong>ListS3</strong> processor, it will periodically list the objects in the specified S3 bucket and pass this information to the next processor in the flow. This setup is crucial for automating the data ingestion process from S3 to Elasticsearch and Kibana.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/545/1*pG9uKWItMU5NiZ_oZMEBUA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*vpRhYzXYw23i9meazVI43A.png" /></figure><p>You should also configure the<strong> Scheduling</strong> of your ListS3 processor to control how frequently it polls the S3 bucket for new objects. Here’s how to do it:</p><ol><li><strong>Open the Configuration Window: </strong>Double-click on the ListS3 processor to open its configuration window.</li><li><strong>Navigate to the Scheduling Tab: </strong>Click on the “Scheduling” tab within the configuration window.</li><li><strong>Set the Run Schedule: </strong>In the “Run Schedule” field, specify how often the processor should run. For example, you might set it to 5 min to have the processor run every five minutes. If you increase your &quot;Run Schedule&quot; to a higher value, such as 100 seconds or more, you can reduce the load on your NiFi instance and the S3 service, which is particularly useful if the S3 bucket doesn’t receive new data frequently. Conversely, setting a lower value (e.g., 30 seconds) can ensure that new data is ingested quickly, but may increase the load on your system.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*F5BHPZbjBTpyXO_ua_bS2A.png" /></figure><p>Next, we should add the <strong>FetchS3Object</strong> processor in the same way. This processor allows us to retrieve the actual content of the objects listed by the ListS3 processor. By fetching the data from the S3 bucket, we can then process, transform, and route it as needed in subsequent steps of our data flow.</p><p>The <strong>FetchS3Object </strong>processor is essential because it takes the metadata provided by the ListS3 processor and uses it to download the actual data from S3. This processor ensures that the content of each object is available for further processing in our NiFi flow.</p><p>You can add the FetchS3Object processor using the drag-and-drop method with the <strong>“Processor”</strong> button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*VNCSJ5T5GdLZQbjTFDNoog.png" /></figure><p>Once the <strong>FetchS3Object</strong> processor is on the canvas, you need to configure it:</p><ul><li><strong>Bucket:</strong> This should be the same S3 bucket specified in the ListS3 processor.</li><li><strong>Access Key and Secret Key:</strong> Provide your AWS credentials (no need for this example)</li><li><strong>Region:</strong> Specify the AWS region where your S3 bucket is located.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*hFw1PbWNTQT4BOgKiYO5tQ.png" /></figure><p>To link the ListS3 processor to the <strong>FetchS3Object processor</strong>, draw a connection between them:</p><ol><li>Click on the arrow icon at the right edge of the <strong>ListS3</strong> processor.</li><li>Drag the arrow to the <strong>FetchS3Object</strong> processor and release.</li><li>In the dialog that appears, select the appropriate relationships (e.g., <strong>“success”</strong>) and click<strong> “Add.”</strong></li></ol><p>This connection ensures that the objects listed by the ListS3 processor are fetched by the FetchS3Object processor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*LEGMQRoQWCElW0vqIJAuWg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*zQHvD7yDBDoK7T04I0IjXQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/1*LKDQJU_UBealI9wlomGFYA.png" /></figure><p>For handling failure files in your data flow, you can follow two approaches. The first approach involves configuring the <strong>FetchS3Object </strong>processor to terminate FlowFiles upon failure, and the second approach involves creating a new queue to manage and review failure data.</p><h4>Approach 1: Terminate Failure Files</h4><ol><li><strong>Open the Configuration Window:</strong> Double-click on the FetchS3Object processor to open its configuration window.</li><li><strong>Navigate to the Settings Tab:</strong> Click on the “Settings” tab within the configuration window.</li><li><strong>Terminate Relationships:</strong> In the “Settings” tab, you will see a section for “Automatically Terminate Relationships.” Check the box next to “failure.” This setting ensures that any FlowFiles that encounter a failure during the fetch operation will be terminated immediately, preventing them from clogging the data flow.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*n-5yrieMaW4hgN4jTaVUyg.png" /></figure><h4>Approach 2: Create a Queue for Failure Data</h4><ol><li><strong>Create a Queue:</strong> Add a queue to handle the failure data. You can do this with drag to arrow from the processor to the right edge</li><li><strong>Configuring to the Queue:</strong> In the dialog that appears, select the <strong>“failure”</strong> relationship and click<strong> “Add”.</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*B_hAvJFj7_iuBhMf4_wYoA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*6uUoLYRD8p8yGWH3iq1Glw.png" /></figure><p>Once you have configured the <strong>ListS3</strong> and <strong>FetchS3Object</strong> processors, you can start it to begin listing objects in your S3 bucket:</p><ol><li><strong>Right-Click on the Processor:</strong> Right-click on the ListS3 processor on the canvas.</li><li><strong>Click “Start”</strong>: In the context menu that appears, click on “Start.” and <strong>“Refresh”</strong> the canvas.</li></ol><p>In this way, the <strong>ListS3</strong> processor will begin to run according to the schedule you have set, polling the specified S3 bucket and generating FlowFiles for each object it lists. These FlowFiles will then be passed along to the next processor in the data flow, such as <strong>FetchS3Object</strong>, for further processing. Starting the processor initiates the automated data ingestion process, allowing NiFi to continuously monitor and process new data as it becomes available in the S3 bucket.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*5SbKLCX26tdW7avj6V5ndQ.png" /></figure><p>After refreshing your page, you can see the data ingestion into<strong> “success”</strong> part. If you want to show your file list, you can right-click to the <strong>“Queued”</strong> and click to <strong>“list queue”</strong> button:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/445/1*EPRtWGwhK6HZn4zEos4p9Q.png" /></figure><p>Now, we should add another processor, which is <strong>ConvertRecord</strong>. This processor is used to convert data from one format to another, such as JSON to CSV, Avro to JSON, and so on. This is particularly useful when the data retrieved from S3 is in a format that needs to be transformed before it can be indexed into Elasticsearch.</p><p>While adding this processor, you can follow similar steps as with the previous processors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*PGDzs38tF8bq6I7Ob3aBrw.png" /></figure><p>Once the ConvertRecord processor is on the canvas, you need to configure it:</p><ol><li><strong>Double-Click to Configure:</strong> Double-click on the ConvertRecord processor to open its configuration window.</li><li><strong>Properties Tab:</strong> Navigate to the “Properties” tab.</li><li><strong>Set the Record Reader and Writer:</strong></li></ol><ul><li><strong>Record Reader:</strong> Specify the controller service that reads the input data format (e.g., a JSON Reader if your data is in JSON format).</li><li><strong>Record Writer:</strong> Specify the controller service that writes the output data format (e.g., a CSV Writer if you need the data in CSV format).</li></ul><p>In this example, we use “<strong>JsonTreeReader</strong>” as the Record Reader and “<strong>JsonRecordSetWriter</strong>” as the Record Writer. The JsonTreeReader will parse the incoming JSON data, and the JsonRecordSetWriter will format the processed data back into JSON, which can then be sent to Elasticsearch for indexing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*uy_H2QWfVzgfo90Pd7_WBQ.png" /></figure><p>Next, we should enable these controller services to ensure they are active and ready to use:</p><ul><li>Click on the gear icon next to the JsonTreeReader/JsonRecordSetWriter property.</li><li>In the controller services configuration window, find JsonTreeReader/JsonRecordSetWriter, right-click on it, and select “Enable.”</li></ul><p>Now, you can connect the <strong>FetchS3Object</strong> processor to the <strong>ConvertRecord</strong> processor with a “success” relationship. This ensures that the data fetched from S3 is passed to the ConvertRecord processor for format conversion.</p><ul><li>Drag the arrow to the ConvertRecord processor and release.</li><li>In the dialog that appears, select the “success” relationship and click “Add.”</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*MhgKKt65lFTeg00wqPE5jA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*2UvewRLskSQYAk8G8TYD0g.png" /></figure><p>By connecting the processors in this way, you ensure that only successfully fetched data is passed along to the ConvertRecord processor. This step is crucial for maintaining a smooth and efficient data flow, allowing each processor to handle its specific task sequentially.</p><p>For handling failures in the <strong>ConvertRecord</strong> processor, you can follow a similar approach as with the <strong>FetchS3Object</strong> processor by creating a failure queue:</p><ol><li><strong>Create a Failure Queue for ConvertRecord:</strong></li></ol><ul><li>Click on the arrow icon at the right edge of the <strong>ConvertRecord</strong> processor.</li><li>Drag the arrow to an empty space on the canvas and release.</li><li>In the dialog that appears, select the “<strong>failure</strong>” relationship and click <strong>“Add”.</strong></li></ul><p>Then, you have connected the <strong>FetchS3Object</strong> processor to the <strong>ConvertRecord</strong> processor, you can start the <strong>FetchS3Object</strong> processor to initiate the data flow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*52qxJmCkm65ivuqu-1F86w.png" /></figure><p>After starting the<strong> FetchS3Object </strong>processor and confirming that the data flow is successful, the next step is to connect the <strong>ConvertRecord</strong> processor to the <strong>PutElasticsearchHttp</strong> processor. This processor is used to send the converted data to an Elasticsearch cluster for indexing.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/797/1*SoSUUgiodGgFlxlc7G7SEg.png" /></figure><p>For configuring <strong>PutElasticsearchHttp</strong> processor, you should Specify the URL of your Elasticsearch cluster. This URL typically follows the format <strong>http://XX.XX.XX.XX:9200</strong>, where XX.XX.XX.XX is the IP address or hostname of your Elasticsearch server.</p><p>If you’re not familiar with launching and starting Elasticsearch, you can visit my previous blog post from this link for detailed instructions:</p><p><a href="https://medium.com/@busekaylan/elasticsearch-in-the-cloud-how-to-set-up-on-aws-ec2-9ebc886ee27c">Elasticsearch in the Cloud: How to Set Up on AWS EC2 | by Buse Kaylan | May, 2024 | Medium</a></p><p>In that post, I covered the steps to launch and start Elasticsearch on your instance, providing you with the necessary knowledge to configure the PutElasticsearchHttp processor effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/757/1*aCM0kIggTE70eyM_nVv7Ig.png" /></figure><p>While configuring the <strong>PutElasticsearchHttp</strong> processor, you can specify the “<strong>index</strong>” parameter to define the Elasticsearch index where you want to store the data ingested through this processor. This parameter determines the destination index for your data within Elasticsearch. For this example, you can add your name or something else:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*kFEoUl3tUGe_DkyiKuVtjQ.png" /></figure><p>After configuring the <strong>ConvertRecord</strong> and <strong>PutElasticsearchHttp</strong> processors, you should connect them using the “success” relationship. Similarly, you should add a failure queue for the PutElasticsearchHttp processor to handle any indexing failures.</p><p>At the conclusion of your pipeline, it’s essential to incorporate a<strong> funnel</strong> to consolidate and direct the FlowFiles. To add a funnel, simply drag and drop the funnel icon from the components toolbar onto the canvas.</p><p>By establishing connections between the processors using the “success” relationship, you guarantee that successfully converted data flows seamlessly to the PutElasticsearchHttp processor for indexing into Elasticsearch.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/448/1*EVA4dcAuXxY9wg-7mZdOLw.png" /></figure><p>In the final version of your pipeline, this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/575/1*BE9BAGhvD-8NElBGT8JG8w.png" /></figure><p>After successfully ingesting data in NiFi, you can start your Kibana instance from your EC2 and connect to it using this URL respect to your IP address: http://XX.XX.XX.XX:5601.</p><p>If you’re not familiar with this process, you can refer to my previous blog post from below link where I detailed how to launch and start your Kibana instance:</p><p><a href="https://medium.com/@busekaylan/optimize-your-aws-workflow-installing-kibana-on-ubuntu-22-04-ec2-instance-bb36727480b5">Optimize Your AWS Workflow: Installing Kibana on Ubuntu 22.04 EC2 Instance | by Buse Kaylan | May, 2024 | Medium</a></p><p>Once you’re in Kibana, you’ll see a list of your Elasticsearch index names. This means your data is organized and ready to be visualized. Kibana lets you create all sorts of cool charts and maps to help you understand your data better:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/947/1*Jjj2Tdk5NCi90ZxYau0kFQ.png" /></figure><p>In conclusion, Apache NiFi serves as a powerful tool for orchestrating data flows, seamlessly integrating various data sources and destinations. By following the steps outlined in this guide, you’ve learned how to harness NiFi’s capabilities to effortlessly transfer data from AWS S3 to Elasticsearch and Kibana, setting the stage for insightful data visualization and analysis.</p><p>But our journey doesn’t end here. In upcoming blog posts, I’ll delve into launching and configuring other essential tools like Superset and Airflow. You can look forward to discovering how Airflow can be leveraged for efficient data ingestion and much more. Stay tuned for further exploration into the world of data engineering and analytics!</p><p>If you have any questions or topics you’d like to see covered, feel free to reach out. Until next time, happy data streaming!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e9c5e50dc284" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Optimize Your AWS Workflow: Installing Kibana on Ubuntu 22.04 EC2 Instance]]></title>
            <link>https://medium.com/@busekaylan/optimize-your-aws-workflow-installing-kibana-on-ubuntu-22-04-ec2-instance-bb36727480b5?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb36727480b5</guid>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[kibana]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Sat, 11 May 2024 20:40:36 GMT</pubDate>
            <atom:updated>2024-05-11T20:40:36.670Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DOpuXEoKVTAxFxHMRLs18w.png" /></figure><p>Welcome back, data enthusiasts! If you’ve been following along, you know we’ve embarked on an exciting journey exploring the realm of data analytics and management. From setting up Spark with PySpark for data processing, to orchestrating data flows with Apache NiFi, and harnessing the power of Elasticsearch for indexing and searching, we’ve covered a lot of ground. Today, we’re delving into another integral component of our data ecosystem: Kibana. In this installment, I’ll guide you through the process of launching Kibana on an Ubuntu 22.04 AWS EC2 instance, completing the final piece of our puzzle.</p><p>Let’s elevate our data insights to new heights!</p><p>Before accessing your EC2 instance, it’s essential to configure the security settings in your AWS account to allow access to the Kibana service. This involves adding a security rule that permits inbound traffic on port 5601, which is the default port for Kibana.</p><p>To do this, you’ll navigate to the AWS Management Console and access the security group associated with your EC2 instance. Then, you’ll add an inbound rule that allows traffic from your desired source (e.g., your IP address or 0.0.0.0) on port 5601.</p><p>By configuring the security group in this way, you ensure that only authorized users or systems can access Kibana running on your EC2 instance, enhancing the security of your data infrastructure.</p><p>Once the security rule is added and applied, you can proceed to connect to your EC2 instance and access Kibana with confidence, knowing that access is restricted to authorized entities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P1dzY4zqpQ6CAvdV583EPg.png" /></figure><p>After connecting to your instance, your first step is to obtain the relevant Kibana documentation from the official website. In this instance, we’ll be downloading Kibana version 7.17.0. It’s crucial to maintain compatibility between Elasticsearch and Kibana versions. Since we previously installed Elasticsearch 7.17, we’ll ensure compatibility by installing Kibana 7.17.0. If you’re considering a different Kibana version, it’s essential to verify its compatibility with your Elasticsearch version. You can refer to the compatibility matrix provided by Elasticsearch for this purpose. For checking compatibility of versions, you can visit <a href="https://www.alibabacloud.com/help/en/es/product-overview/compatibility-matrixes">Compatibility matrixes — Elasticsearch — Alibaba Cloud Documentation Center</a></p><p>To download Kibana 7.17.0, execute the following command. This command will fetch the Kibana 7.17.0 package for the AMD64 architecture. Make sure to adjust the command accordingly if you’re using a different architecture.</p><pre>wget https://artifacts.elastic.co/downloads/kibana/kibana-7.17.0-amd64.deb</pre><p>After downloading the Kibana package, it’s a good practice to verify its integrity using a checksum. The shasum command with the -a 512 flag calculates the SHA-512 checksum of the downloaded file. By comparing this checksum with the one provided by the official source, you can ensure that the downloaded file hasn&#39;t been tampered with or corrupted during the download process. This step adds an extra layer of security to your installation process and helps prevent potential issues that could arise from using a compromised package. Here&#39;s the command to calculate the SHA-512 checksum for the downloaded Kibana package:</p><pre>shasum -a 512 kibana-7.17.0-amd64.deb</pre><p>After verifying the integrity of the downloaded Kibana package, the next step is to install it using the dpkg package manager. The dpkg -i command is used to install Debian packages, and with sudo, it ensures that the installation is performed with administrative privileges, allowing system-level changes to be made. Running this command will initiate the installation process for Kibana on your Ubuntu system. The installation process will handle tasks such as unpacking the package, configuring files, and setting up Kibana to run as a service on your system.</p><p>Here’s the command to install the downloaded Kibana package:</p><pre>sudo dpkg -i kibana-7.17.0-amd64.deb</pre><p>After installing Kibana, the next step is to configure it according to your requirements. This is typically done by editing the kibana.yml configuration file. The sudo nano /etc/kibana/kibana.yml command opens the kibana.yml file for editing using the Nano text editor with administrative privileges (sudo).</p><p>The kibana.yml file contains various settings, including defining the server host, specifying Elasticsearch server URLs, configuring logging parameters, and more. This flexibility allows you to customize Kibana&#39;s behavior to suit your environment.</p><p>To edit the kibana.yml file, execute the following command:</p><pre>sudo nano /etc/kibana/kibana.yml</pre><p>In the kibana.yml file, you&#39;ll make adjustments to specific sections. First of all, you should set server.host to &quot;0.0.0.0&quot; to allow Kibana to listen on all available network interfaces. Additionally, you should configure elasticsearch.hosts to specify the URL of your Elasticsearch instance, typically including the AWS public IP address and port number [&quot;https://AWS_Public_IP:9200&quot;]</p><p>Once you’ve made the necessary modifications, save the changes to the kibana.yml file and exit the Nano editor. To apply these configurations, you&#39;ll need to restart the Kibana service. This ensures that your adjustments take effect and enables Kibana to operate seamlessly within your data infrastructure.</p><p>Customizing the kibana.yml file according to your requirements is essential for optimizing Kibana&#39;s performance and functionality, enabling you to leverage its capabilities effectively for data visualization and analysis.</p><p>After making the necessary configurations in the kibana.yml file, the next step is to enable the Kibana service to ensure it starts automatically upon system boot. This is accomplished by running the following command:</p><pre>sudo systemctl enable kibana</pre><p>Executing this command registers Kibana as a systemd service, allowing it to start automatically when the system boots up. This ensures that Kibana remains available and operational without manual intervention, enhancing the reliability of your data infrastructure.</p><p>Once enabled, you can start the Kibana service using following command:</p><pre>sudo systemctl start kibana</pre><p>Well done, you’re all set! Now you can access your Kibana instance via the following link:</p><p>https://AWS_Public_IP:5601/</p><p>By navigating to this URL in your web browser, you’ll be able to access the Kibana interface and begin exploring your data for visualization and analysis. Ensure that your AWS public IP address is substituted appropriately in the link to access Kibana from your browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZa0ENhSbHKv8qatnM1WnQ.png" /></figure><p>In the upcoming blog posts, we’ll delve into NiFi, exploring how we can leverage it to extract data from AWS S3, process it, and then seamlessly ingest it into Elasticsearch. Subsequently, we’ll discuss how to visualize this data by transferring it to Kibana, where we’ll craft insightful dashboards. Through this process, we’ll construct an end-to-end ETL pipeline example, showcasing the power of orchestrating data workflows.</p><p>Additionally, we’ll delve into the installation and configuration of Superset, a powerful tool for data exploration and visualization. By examining its setup and usage, we’ll further expand our toolkit for analyzing and presenting data effectively.</p><p>As we embark on this journey of data exploration and integration, we aim to equip ourselves with comprehensive knowledge and practical skills to harness the full potential of our data infrastructure.</p><p>Stay tuned for an enlightening dive into the world of data pipelines and visualization tools, where we’ll unlock new insights and possibilities!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb36727480b5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elasticsearch in the Cloud: How to Set Up on AWS EC2]]></title>
            <link>https://medium.com/@busekaylan/elasticsearch-in-the-cloud-how-to-set-up-on-aws-ec2-9ebc886ee27c?source=rss-3f074004b6a6------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ebc886ee27c</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[big-data]]></category>
            <dc:creator><![CDATA[Buse Kaylan]]></dc:creator>
            <pubDate>Mon, 06 May 2024 23:45:04 GMT</pubDate>
            <atom:updated>2024-05-06T23:45:04.258Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QgqBEyJIkcsU7nmgUiyCtQ.png" /></figure><p>Welcome back, cloud enthusiasts! In our journey through Amazon Web Services (AWS), we’ve explored the ins and outs of launching EC2 instances, mastered Spark for lightning-fast data processing, and harnessed NiFi’s data flow prowess. Today, we take an exciting turn into Elasticsearch — a powerful search and analytics engine that promises to revolutionize how we explore and understand our data.</p><p>Picture this: effortlessly finding the needle in the haystack, not just efficiently, but at lightning speed. That’s what Elasticsearch offers. With its distributed design, near-real-time indexing, and advanced search features, it’s a game-changer for developers and businesses alike. And what better platform to unleash its power than on AWS EC2 instances, running the latest Ubuntu 22.04?</p><p>In this guide, we’ll walk you through launching and setting up Elasticsearch on EC2 instances powered by Ubuntu 22.04. Whether you’re a seasoned developer looking to enhance your search capabilities or a data enthusiast eager to dive into distributed analytics, this guide is your ticket to success.</p><p>So, buckle up and get ready for an adventure as we unravel the mysteries of Elasticsearch on AWS EC2. By the end, you’ll have the knowledge and tools to build scalable, efficient search solutions that elevate your applications and data pipelines to new heights.</p><p>Join us on this journey as we demystify Elasticsearch — your gateway to unlocking the true potential of your data in the cloud.</p><p>Let’s start by ensuring our AWS EC2 security group settings are set up to allow traffic on the necessary ports for Elasticsearch. Begin by navigating to the AWS Management Console and selecting EC2. Once there, go to the Instances section and choose the relevant instance to view its details. Scroll down to find the Security Groups section and click on it to access the security group settings. In this section, you’ll need to adjust the inbound rules to accommodate Elasticsearch’s ports. Create a new rule for port 9200, a commonly used port for Elasticsearch, and specify a trusted IP address or range as the source, rather than allowing traffic from any IP address (0.0.0.0/0). This step ensures that incoming traffic on port 9200, necessary for accessing the Elasticsearch web interface, is limited to trusted sources. Once the inbound rules are updated, you’re ready to proceed with deploying and configuring Elasticsearch on your Ubuntu 22.04 EC2 instance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sLBDrsgSaE_GAd-vEFlq2g.png" /></figure><p>After connecting to our EC2 instance, it’s essential to switch to the root user before launching Elasticsearch. This step grants superuser privileges, enabling us to perform administrative tasks required for installing and configuring Elasticsearch effectively. Once you’ve switched to the root user, you’re ready to proceed with the deployment process. To do this, execute the following command:</p><pre>sudo su</pre><p>After switching to the root user, the next step is to download Elasticsearch. <strong>It’s important to note that</strong> if you plan to use Kibana for visualization, ensure compatibility between Elasticsearch and Kibana versions before proceeding. You can check compatibility information at the following link: <a href="https://www.alibabacloud.com/help/en/es/product-overview/compatibility-matrixes">Elasticsearch-Kibana Compatibility Matrix</a>. Failing to do so might lead to integration issues between Kibana and Elasticsearch.</p><p>By verifying compatibility in advance, you can avoid potential problems and ensure a smooth experience when integrating Kibana with Elasticsearch.</p><p>Now, let’s proceed with Elasticsearch 7.x. Use the following commands:</p><pre>curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --<br>dearmor -o /usr/share/keyrings/elastic.gpg</pre><p>As the next step in launching Elasticsearch, add the Elasticsearch 7.x repository to your system by executing the following command. This command adds the Elasticsearch 7.x repository to your system’s list of package sources, enabling you to install Elasticsearch and related packages via package managers like apt.</p><pre>echo &quot;deb [signed-by=/usr/share/keyrings/elastic.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main&quot; | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list</pre><p>Now, it’s essential to update your system to ensure that you have the latest package information. Execute the following command to update the package index. This command refreshes the local package index, allowing your system to fetch the latest package information from the configured repositories. It’s a necessary step before installing any new packages or updates, ensuring that you have access to the most recent versions available.</p><pre>apt update</pre><p>Next, install Elasticsearch on your system by executing the following command.</p><p>This command installs the Elasticsearch package, bringing the powerful search and analytics capabilities of Elasticsearch to your system. Once installed, Elasticsearch will be ready to use, but further configuration may be required depending on your specific use case. After the installation is complete, you can start and enable the Elasticsearch service to ensure it runs automatically on system boot. We’ll cover the configuration and startup process in the subsequent steps.</p><pre>sudo apt install elasticsearch</pre><p>The next step involves reloading the systemd manager configuration to ensure that any changes made to unit files are recognized. Execute the following command.</p><p>This command instructs systemd to reload its configuration files, making it aware of any recent changes. It’s often necessary after modifying unit files, such as service configuration files, to ensure that systemd manages the services correctly. After reloading the daemon, you can proceed to start and enable the Elasticsearch service, ensuring it runs smoothly on your system.</p><pre>systemctl daemon-reload</pre><p>The systemctl enable elasticsearch command is used to enable the Elasticsearch service to start automatically at boot time. By enabling the Elasticsearch service, you ensure that it starts automatically whenever the system boots up, providing uninterrupted access to Elasticsearch’s search and analytics capabilities. This ensures that Elasticsearch is always available, even after system reboots or power failures. Once enabled, you can start the Elasticsearch service using the systemctl start elasticsearch command to immediately start using it without needing to reboot the system.</p><pre>systemctl enable elasticsearch</pre><p>Once Elasticsearch is installed, it’s essential to configure its settings to optimize performance and security. Navigate to the Elasticsearch configuration file by executing the following command:</p><pre>vim /etc/elasticsearch/elasticsearch.yml</pre><p>One of the critical steps in setting up Elasticsearch on your AWS EC2 instance is configuring its settings to ensure optimal performance and connectivity. In this step, I’ll guide you through configuring the elasticsearch.yml file with essential parameters.</p><p>In this configuration:</p><ul><li>network.host: 0.0.0.0 allows Elasticsearch to accept connections from any IP address, enabling access from both local and external networks.</li><li>http.port: 9200 sets the HTTP port to 9200, which is the default port for client communication with Elasticsearch.</li><li>discovery.seed_hosts: [&quot;0.0.0.0&quot;, &quot;AWS_EC2_PUBLIC_IP&quot;] specifies the seed hosts for cluster discovery. Replace &quot;AWS_EC2_PUBLIC_IP&quot; with the public IP address of your AWS EC2 instance. This allows Elasticsearch nodes to discover each other within the cluster.</li></ul><pre># Configure network host to allow connections from any IP address<br>network.host: 0.0.0.0<br><br># Set the HTTP port to 9200 for client communication<br>http.port: 9200 <br><br># Specify the seed hosts for cluster discovery<br>discovery.seed_hosts: [&quot;0.0.0.0&quot;, &quot;AWS_EC2_PUBLIC_IP&quot;]</pre><p>Great job! You’re all set! Now, simply start Elasticsearch with the following command:</p><pre>systemctl start elasticsearch</pre><p>After that, you can access your Elasticsearch database by navigating to this link according to your AWS EC2 Public IP: https://AWS_EC2_PUBLIC_IP:9200</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*h9OiVfShWCIw1bgtfq0jpA.png" /></figure><p>Congratulations on completing the setup! You’re now ready to unleash the power of Elasticsearch on your AWS EC2 instance.</p><p>As we wrap up this guide, you’ve now embarked on a journey to harness the immense power of Elasticsearch on your AWS EC2 instance. With Elasticsearch deployed, you’re on the path to unlocking actionable insights from your data like never before. But this is just the beginning!</p><p>Stay tuned for my upcoming blog posts, where we’ll dive deeper into the world of data engineering and ETL. Next up, we’ll explore launching Kibana for stunning visualizations that bring your data to life, followed by a guide on setting up Superset for interactive data exploration. With Elasticsearch paving the way, and Kibana and Superset on the horizon, you’re poised to revolutionize the way you analyze and leverage your data.</p><p>Get ready to embark on an exciting journey of discovery and empowerment!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ebc886ee27c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>