<?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 Sudarshan Jaikrishnan on Medium]]></title>
        <description><![CDATA[Stories by Sudarshan Jaikrishnan on Medium]]></description>
        <link>https://medium.com/@sudarshan_jai?source=rss-ae9f0e928542------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lTIIlmFu4-rOVb_QWci_vw.jpeg</url>
            <title>Stories by Sudarshan Jaikrishnan on Medium</title>
            <link>https://medium.com/@sudarshan_jai?source=rss-ae9f0e928542------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 02:33:49 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sudarshan_jai/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[Achieving Fully Dynamic Prometheus Service Discovery — Without Kubernetes, Without Consul, Without…]]></title>
            <link>https://medium.com/@sudarshan_jai/achieving-fully-dynamic-prometheus-service-discovery-without-kubernetes-without-consul-without-34615bd28579?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/34615bd28579</guid>
            <category><![CDATA[grafana-prometheus]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[devops-tool]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Mon, 01 Dec 2025 17:35:01 GMT</pubDate>
            <atom:updated>2025-12-01T17:35:01.069Z</atom:updated>
            <content:encoded><![CDATA[<h3>Achieving Fully Dynamic Prometheus Service Discovery — Without Kubernetes, Without Consul, Without CloudMagic</h3><p><em>A practical guide to auto-registering and auto-deregistering servers for Prometheus monitoring</em></p><p>Infrastructure that expands dynamically is impressive. Until your monitoring fails.</p><p>When employing Prometheus + Node Exporter outside of a Kubernetes setup (such as metal, VMs, DigitalOcean, tailored environments and so forth) you soon encounter a common challenge:</p><blockquote>“My servers. Disappear. Their IP addresses shift. Prometheus targets fail. I’m unable to update configurations each day.”</blockquote><p>CloudWatch handles this automatically for those using AWS. However what if your environment isn’t based on AWS?</p><p>In weeks I developed a fully automated cloud-independent service discovery system, for Prometheus. Compatible everywhere requiring no unique orchestration layer and seamlessly incorporating autoscaling.</p><p>In this article I will demonstrate how it operates.</p><h3>The Problem</h3><h4>In autoscaling environments:</h4><p>1. Additional nodes are activated</p><p>2. Outdated nodes shut down</p><p>3. IPs are never the same</p><p>4. Node exporter operates on each node</p><p>5. Prometheus depends on fixed targets or cloud-native service discovery integrations</p><blockquote>Maintaining the Prometheus configuration up-to-date turns into a nightmare, without Kubernetes service discovery or AWS EC2 SD.</blockquote><p><strong>The majority of teams eventually choose one of the following:</strong></p><p>1. Hard-coding IPs</p><p>2. Writing cron jobs to rewrite prometheus.yml</p><p>3. Restarting Prometheus every time</p><p>4. Accepting broken dashboards</p><p><strong>There’s a better way.</strong></p><h3><strong>The Solution — Build Your Own Service Discovery API</strong></h3><p>We developed a Service Discovery API based on Flask that Prometheus accesses via file_sd_configs.</p><p>The design is structured as follows:</p><p>Architecture Diagram (conceptual)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oEN5Ae8B49WMFZK-5VMwfg.png" /></figure><h4>How It Functions (Basic Overview)</h4><h4><strong>1. When a server starts</strong></h4><p>A systemd service triggers <strong>register_node.sh</strong></p><p>It sends a request to the Flask API:</p><pre>POST /register<br><br>{<br><br>&quot;group&quot;: &quot;audiocry-prod&quot;,<br><br>&quot;targets&quot;: [<br><br>&quot;164.52.xx.xx:9100&quot;,<br><br>&quot;164.52.xx.xx:9101&quot;,<br><br>&quot;164.52.xx.xx:9400&quot;<br><br>]<br><br>}</pre><p>Flask modifies audiocry-prod.json</p><p>Prometheus identifies the modification in, under 5 seconds automatically</p><p>Dashboards instantly display the server</p><h4><strong>2. At the moment the server powers off</strong></h4><p>Systemd executes automatically:</p><pre>ExecStop=/opt/deregister_node.sh</pre><p>The script calls:</p><pre>POST /deregister</pre><p>Flask deletes the node from the destination list.</p><p>No more stale nodes in Prometheus.</p><h4>3. Prometheus Setup</h4><p>Applications of Prometheus:</p><pre>file_sd_configs:<br>  - files:<br>      - /etc/prometheus/targets/*.json</pre><p>Prometheus constantly monitors this directory. Reads the refreshed targets.</p><p>This functions, across server groups:</p><pre>example-prod.json<br>example-staging.json</pre><p>Each with its own dynamic target list.</p><h4>The Reason This Method Is So Effective</h4><blockquote><em>Prometheus does not restart</em></blockquote><blockquote><em>Modifications are automatically identified.</em></blockquote><blockquote><em>Works on any cloud / bare metal</em></blockquote><blockquote><em>Not tied to AWS/GCP/DO/K8s.</em></blockquote><blockquote><em>Zero dependency</em></blockquote><blockquote><em>Just Python + Flask + systemd scripts.</em></blockquote><blockquote><em>Seamless autoscaling</em></blockquote><blockquote><em>Servers self-register, during startup.</em></blockquote><blockquote><em>Clean de-registration</em></blockquote><blockquote><em>No “ghost” IPs in Prometheus targets.</em></blockquote><blockquote><em>Supports ports (E.g., Node Exporter + custom exporters)</em></blockquote><blockquote><em>Zero manual maintenance</em></blockquote><h3>Implementation Overview</h3><p>(Feel free to substitute these placeholders with your scripts)</p><h4>Flask SD Server</h4><p>Manages registration, deregistration and listing requests</p><p>Folder: /etc/prometheus/targets/</p><p>Every group possesses its file:</p><pre>/etc/prometheus/targets/example-prod.json<br>/etc/prometheus/targets/example-staging.json</pre><p>The API just modifies those JSON documents.</p><h4>Node Registration Script</h4><p>Executes, on startup identifies the servers IP address. Transmits it for registration.</p><pre>#!/bin/bash<br><br># ====== CONFIGURATION ======<br>SD_SERVER=&quot;http://&lt;FLASK_SD_IP&gt;:5050&quot;<br>GROUP=&quot;audiocry-prod&quot;<br>PORTS=(&quot;9100&quot; &quot;9101&quot; &quot;9400&quot;)<br># ===========================<br><br>IP=$(hostname -I | awk &#39;{print $1}&#39;)<br><br>for port in &quot;${PORTS[@]}&quot;; do<br>  curl -s -X POST &quot;$SD_SERVER/register&quot; \<br>       -H &quot;Content-Type: application/json&quot; \<br>       -d &quot;{\&quot;group\&quot;: \&quot;$GROUP\&quot;, \&quot;ip\&quot;: \&quot;$IP\&quot;, \&quot;port\&quot;: \&quot;$port\&quot;}&quot;<br>done</pre><h4>Deregistration Script</h4><p>Triggered on shutdown.</p><pre>#!/bin/bash<br><br># ====== CONFIGURATION ======<br>SD_SERVER=&quot;http://&lt;FLASK_SD_IP&gt;:5050&quot;<br>GROUP=&quot;audiocry-prod&quot;<br>PORTS=(&quot;9100&quot; &quot;9101&quot; &quot;9400&quot;)<br># ===========================<br><br>IP=$(hostname -I | awk &#39;{print $1}&#39;)<br><br>for port in &quot;${PORTS[@]}&quot;; do<br>  curl -s -X POST &quot;$SD_SERVER/deregister&quot; \<br>       -H &quot;Content-Type: application/json&quot; \<br>       -d &quot;{\&quot;group\&quot;: \&quot;$GROUP\&quot;, \&quot;ip\&quot;: \&quot;$IP\&quot;, \&quot;port\&quot;: \&quot;$port\&quot;}&quot;<br>done</pre><h4>Node Exporter Installation</h4><p>(Standard Node Exporter installation, automated for the AMI/template)</p><h4>systemd Units</h4><p>Two important services:</p><pre>register_node.service     (WantedBy=multi-user.target)<br><br>deregister_node.service   (ExecStop for safe shutdown)</pre><p>Create: /etc/systemd/system/register_node.service</p><pre>[Unit]<br>Description=Register Node with Prometheus SD<br>After=network-online.target<br><br>[Service]<br>Type=oneshot<br>ExecStart=/opt/register_node.sh<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>Create: /etc/systemd/system/deregister_node.service</p><pre>[Unit]<br>Description=Deregister Node from Prometheus SD<br>DefaultDependencies=no<br>Before=shutdown.target reboot.target halt.target<br><br>[Service]<br>Type=oneshot<br>ExecStart=/opt/deregister_node.sh<br><br>[Install]<br>WantedBy=shutdown.target reboot.target halt.target</pre><h4>Dashboards? Yes — Completely Automated</h4><p>After activating the targets we expand the Grafana dashboards</p><p>Each server within each autoscaling group receives metrics automatically with no need, for configuration adjustments.</p><h3>Closing Remarks.</h3><blockquote>Observability That Truly Feels “Cloud Native”</blockquote><p>This configuration essentially provides you with:</p><blockquote>AWS-style auto-discovery</blockquote><blockquote>Kubernetes-like dynamic targets</blockquote><blockquote>Consul-like service registration</blockquote><blockquote>Without running any of those systems</blockquote><blockquote>It is light, in weight, dependable, easy to maintain and not tied to any cloud platform.</blockquote><p>If your infrastructure scales dynamically and you want Prometheus to keep up — this architecture is a game-changer.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34615bd28579" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[btop and Why You Need It]]></title>
            <link>https://medium.com/@sudarshan_jai/btop-and-why-you-need-it-a011a631b927?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/a011a631b927</guid>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[btop]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Mon, 03 Feb 2025 06:46:50 GMT</pubDate>
            <atom:updated>2025-02-03T06:46:50.856Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0tPamb-DmS74Ru3yUwhsRA.png" /></figure><p>System monitoring tools are a staple in every developer’s toolkit. Whether you’re debugging performance issues, optimizing resource usage, or simply keeping an eye on your system, tools like top and htop have long been the go-to choices. But there&#39;s a new player in town that takes system monitoring to the next level: btop. Often referred to as &quot;htop on steroids,&quot; btop is a game-changer for anyone looking for a sleek, feature-rich, and intuitive monitoring experience.</p><h3>What is btop?</h3><p>btop is a modern resource monitor that provides a visually stunning and highly interactive interface for monitoring system performance. It’s designed for Linux, macOS, and FreeBSD systems and offers real-time tracking of CPU, memory, disk, network, and process metrics. Created by <strong>Aristocratos</strong> and powered by contributions from a dedicated community on GitHub, btop builds upon the legacy of traditional monitoring tools while adding a fresh coat of paint and a host of advanced features.</p><h3>Why You Need btop</h3><h3>1. User-Friendly Interface</h3><p>One of the standout features of btop is its beautifully designed interface. Unlike the utilitarian look of top or the more polished but still text-heavy htop, btop incorporates:</p><ul><li>Dynamic and colorful graphs for real-time metrics.</li><li>An intuitive layout that separates CPU, memory, disk, and network usage into easily readable sections.</li><li>Smooth animations and transitions, making navigation a breeze.</li></ul><p>This design not only looks great but also reduces cognitive load, allowing you to quickly grasp your system’s performance at a glance.</p><h3>2. Advanced Features</h3><p>btop isn&#39;t just about aesthetics; it’s packed with features that make it a powerful tool for both casual users and sysadmins:</p><ul><li><strong>Real-Time Filtering:</strong> Instantly search for processes by name or PID.</li><li><strong>Detailed Process Information:</strong> Dive deeper into each process to see CPU and memory usage, thread counts, and more.</li><li><strong>Custom Sorting:</strong> Sort processes by CPU, memory, or disk usage with just a keypress.</li><li><strong>Network Monitoring:</strong> Get detailed stats on upload/download speeds and total data usage.</li><li><strong>Configurable Options:</strong> Tailor btop to your needs with its highly customizable settings, from update frequency to theme colors.</li></ul><h3>3. Ease of Use</h3><p>With intuitive keyboard shortcuts, btop makes navigation and customization simple. Whether you&#39;re killing a misbehaving process, adjusting display settings, or scrolling through detailed graphs, everything feels smooth and responsive.</p><h3>4. Lightweight and Fast</h3><p>Despite its rich feature set and stunning visuals, btop is surprisingly lightweight. It’s optimized for performance, ensuring that the monitor itself doesn’t become a drain on system resources.</p><h3>5. Cross-Platform Support</h3><p>btop runs seamlessly on Linux, macOS, and FreeBSD, making it a versatile tool for developers and system administrators working across different environments.</p><h3>How btop Outshines htop and Others</h3><p>While htop has been a trusted tool for years, btop takes everything great about it and amplifies it:</p><p>FeaturehtopbtopVisual AppealMinimal color codingFull-color dynamic graphsNavigationBasicSmooth animationsCustomization OptionsLimitedExtensiveProcess FilteringBasicInstant real-time searchDisk and Network MonitoringLimitedDetailed graphs and statsEase of ConfigurationManual editingInteractive in-app menu</p><p>In essence, btop isn’t here to replace htop; it’s here to elevate the experience. If you’ve ever wished for a resource monitor that’s as functional as it is beautiful, btop is the answer.</p><h3>A Shoutout to the Creators and Contributors</h3><p>btop wouldn’t exist without the hard work of <strong>Aristocratos</strong>, the mind behind this remarkable tool. Additionally, the vibrant GitHub community deserves credit for their contributions, from bug fixes and feature suggestions to documentation improvements. This collaborative effort has resulted in a tool that’s not only powerful but also constantly evolving.</p><p>If you’re interested in supporting or contributing to the project, check out the <a href="https://github.com/aristocratos/btop">btop GitHub repository</a>. Open-source projects like this thrive on community involvement, so don’t hesitate to get involved!</p><h3>How to Get Started</h3><p>Installing btop is straightforward. For most Linux distributions, you can use a package manager:</p><pre>sudo apt install btop        # Debian/Ubuntu<br>sudo dnf install btop        # Fedora<br>brew install btop            # macOS (via Homebrew)</pre><p>You can also compile it from source by following the instructions on the <a href="https://github.com/aristocratos/btop">GitHub page</a>.</p><h3>Conclusion</h3><p>In a world where system monitoring tools are often utilitarian and uninspired, btop stands out as a breath of fresh air. With its stunning visuals, advanced features, and user-friendly design, it’s a must-have for anyone who cares about system performance. Whether you’re a casual user or a seasoned sysadmin, btop is bound to become your new favorite monitoring tool.</p><p>So, why settle for less? Give btop a try and experience the future of resource monitoring today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a011a631b927" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Future of 3D Printing in India: Opportunities and Growth]]></title>
            <link>https://medium.com/@sudarshan_jai/the-future-of-3d-printing-in-india-opportunities-and-growth-bb2b89bfa4d6?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb2b89bfa4d6</guid>
            <category><![CDATA[business]]></category>
            <category><![CDATA[3d-printing]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[future-technology]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 14:05:50 GMT</pubDate>
            <atom:updated>2024-09-16T14:05:50.092Z</atom:updated>
            <content:encoded><![CDATA[<p>In recent years, the global 3D printing market has seen remarkable expansion, with India positioning itself as a growing hub in this technology. From healthcare to automotive, industries are rapidly adopting 3D printing solutions due to its advantages in customization, speed, and cost-efficiency.</p><h3>A Growing Market</h3><p>The Indian 3D printing market is expected to grow at an impressive Compound Annual Growth Rate (CAGR) of over 20% between 2023 and 2030. This growth is driven by increasing demand from industries such as <strong>healthcare</strong>, <strong>aerospace</strong>, <strong>education</strong>, and <strong>consumer goods </strong>With innovations in materials and technology, the future of 3D printing in India is promising.</p><h4>Major Players in the Indian Market</h4><p>Prominent companies in the 3D printing industry include <strong>Wipro 3D</strong>, <strong>Stratasys Ltd.</strong>, and <strong>HP Inc.</strong> These players have a strong presence in industries like aerospace, healthcare, and education, providing industrial-grade printers with cutting-edge technology</p><p><strong>Global 3D printing products and services market size from 2020 to 2026</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*HeTKruBDsDtEoUGP1yPL2Q.png" /></figure><h3>Industry-Wise Adoption</h3><p><strong>Healthcare</strong>: The Indian healthcare sector has increasingly adopted 3D printing for <strong>custom prosthetics</strong>, <strong>implants</strong>, and <strong>surgical tools</strong>. The market for 3D-printed medical devices alone is expected to grow from $54 million in 2022 to $222 million by 2030, at a CAGR of 17.8%​. Medical applications such as bio-printing and custom medical devices are poised to significantly impact patient care, improving outcomes and reducing costs.</p><p><strong>Automotive &amp; Aerospace</strong>: 3D printing is revolutionizing automotive and aerospace industries by offering lightweight, customizable components. These industries benefit from 3D printing’s ability to rapidly prototype and manufacture complex parts, reducing production time and costs​</p><h3>Export Potential</h3><p>India’s 3D printing market isn’t just growing domestically. The <strong>USA</strong> is identified as a top export market for Indian 3D printers, followed by <strong>Indonesia</strong>, <strong>Vietnam</strong>, and <strong>Brazil</strong>. This highlights India’s potential to become a major global player in the additive manufacturing space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*NNesOKnKDYIcHdk4flV2yw.png" /></figure><h3>Challenges and Opportunities</h3><p>Despite rapid growth, the Indian 3D printing industry faces challenges such as high initial costs, limited local production, and a lack of skilled professionals. The market remains highly dependent on imported materials and technology​. However, <strong>government initiatives</strong> like the <strong>Make in India</strong> program aim to boost local manufacturing and reduce reliance on imports.</p><p>At the same time, the cost of 3D printing continues to decline due to advances in technology and economies of scale. The increasing affordability of both printers and materials opens up the potential for broader adoption across industries​.</p><h3>The Road Ahead</h3><p>As the market matures, more industries are expected to adopt 3D printing. With <strong>global companies</strong> investing in Indian startups and <strong>local firms</strong> scaling up, the country is poised to become a leader in <strong>additive manufacturing</strong>. The combination of decreasing costs, increasing awareness, and favorable government policies make 3D printing an exciting industry to watch in India.</p><p>In conclusion, India’s 3D printing market is on a growth trajectory, driven by advancements in technology, increased adoption across industries, and a strong export potential. As costs decline and the market matures, the country is set to play a significant role in the global additive manufacturing landscape.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/626/0*8hVsE_QCklHXIGKs.jpg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb2b89bfa4d6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Metric Filters in AWS CloudWatch Logs]]></title>
            <link>https://medium.com/@sudarshan_jai/creating-metric-filters-in-aws-cloudwatch-logs-87b5088af483?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/87b5088af483</guid>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[sre]]></category>
            <category><![CDATA[cloudwatch-logs]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Fri, 13 Sep 2024 16:19:30 GMT</pubDate>
            <atom:updated>2024-09-13T16:19:30.983Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*xO6mZ1U6wx89OQnQ1eDFfA.png" /></figure><p>CloudWatch Logs metric filters allow you to extract specific patterns from log data and convert them into CloudWatch metrics. These metrics can be used for alarms, monitoring, and visualizations in AWS CloudWatch.</p><p>This guide covers:</p><ol><li><strong>Understanding Metric Filters</strong></li><li><strong>Metric Filter Syntax</strong></li><li><strong>Steps to Create Metric Filters</strong></li><li><strong>Examples of Metric Filters</strong></li><li><strong>Testing and Monitoring Metrics</strong></li></ol><h3>Understanding Metric Filters</h3><p>Metric filters in AWS CloudWatch Logs scan log events in your log groups and extract meaningful data based on specified patterns. These extracted data points are published as CloudWatch metrics, which can trigger alarms or be visualized on CloudWatch dashboards.</p><h3>Metric Filter Syntax</h3><p>A metric filter uses a simple pattern-matching syntax. Below is a breakdown of the syntax structure.</p><h4>Basic Syntax</h4><pre>[FieldName1=Value1, FieldName2=Value2]</pre><ul><li><strong>FieldName</strong>: Any name you define for matching parts of the log event.</li><li><strong>Value</strong>: The value associated with the field. It can be a specific value or a wildcard *.</li></ul><h4>Wildcards</h4><ul><li><strong>*</strong>: Matches zero or more characters in a log event.</li></ul><h4>Logical Operators</h4><ul><li><strong>?</strong>: Matches exactly one character.</li><li><strong>[&lt;num&gt;]</strong>: Captures and extracts numeric fields.</li></ul><h4>Example</h4><p>If you have an Apache access log and want to extract the status code, you can use:</p><pre>[host, ident, user, timestamp, request, statusCode=200, size]</pre><h3>Steps to Create Metric Filters</h3><h4>Step 1: Access CloudWatch Logs</h4><ol><li>Open the <a href="https://aws.amazon.com/console/">AWS Management Console</a>.</li><li>Navigate to <strong>CloudWatch</strong>.</li><li>In the CloudWatch Dashboard, select <strong>Logs</strong> from the left panel.</li></ol><h4>Step 2: Select a Log Group</h4><ol><li>From the list of log groups, select the one where you want to create the metric filter.</li><li>Choose the specific log group to apply the metric filter.</li></ol><h4>Step 3: Create a Metric Filter</h4><ol><li>In the selected log group, choose <strong>Actions</strong> &gt; <strong>Create metric filter</strong>.</li><li>In the <strong>Create Metric Filter</strong> page:</li></ol><ul><li>In the <strong>Filter Pattern</strong> field, define your pattern using the syntax provided above.</li><li>Click <strong>Test Pattern</strong> to validate it against recent log data.</li></ul><h4>Step 4: Define Filter Name and Metric</h4><ol><li>Provide a <strong>Filter Name</strong> for your filter.</li><li>Specify the <strong>Metric Namespace</strong>, which is like a category for grouping metrics.</li><li>Define the <strong>Metric Name</strong>.</li><li>Set the <strong>Metric Value</strong> — the default is 1, but you can set it to any number.</li><li>Choose <strong>Create Filter</strong> to finalize.</li></ol><h3>Examples of Metric Filters</h3><h4>Example 1: 404 Error in Apache Access Logs</h4><p>If your Apache logs look like this:</p><pre>127.0.0.1 - - [23/Jul/2024:10:22:04] &quot;GET /nonexistent-page HTTP/1.1&quot; 404 150</pre><p>Use the following pattern to track 404 errors:</p><pre>[host, ident, user, timestamp, request, statusCode=404, size]</pre><h4>Example 2: Tracking Error Messages</h4><p>For logs containing the string “ERROR”, the pattern would be:</p><pre>&quot;ERROR&quot;</pre><p>This pattern filters out log events that contain the word “ERROR”.</p><h4>Example 3: Matching JSON Log Events</h4><p>For structured JSON logs, if you’re tracking a field called status with a value failed, the pattern would be:</p><pre>{ $.status = &quot;failed&quot; }</pre><h4>Example 4: Extracting Numeric Data</h4><p>To extract and create a metric based on a numeric value (e.g., response time):</p><pre>[request=&quot;*&quot;, responseTime=*]</pre><p>This pattern matches all logs with a request field and captures any value for responseTime.</p><h3>Testing and Monitoring Metrics</h3><h4>Testing Your Filter</h4><ol><li>Once your metric filter is created, test it by reviewing if it captures log events correctly.</li><li>Navigate to <strong>Logs Insights</strong> in the CloudWatch Console.</li><li>Query the logs using relevant fields to validate your filter pattern.</li></ol><h4>Monitoring Metrics</h4><ol><li>Open the <strong>CloudWatch Console</strong>.</li><li>Navigate to <strong>Metrics</strong>.</li><li>Look under the <strong>Namespace</strong> where your metric was created.</li><li>Select the metric and add it to a dashboard, or set alarms based on thresholds.</li></ol><h3>Conclusion</h3><p>CloudWatch metric filters are powerful tools for creating custom metrics from your log data. By understanding the syntax and following the steps provided, you can easily create metric filters tailored to your log format. These metrics can then be used for monitoring, alerting, and visualization to keep track of system health and performance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=87b5088af483" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitoring OTP Requests: A Guide to Visualizing Logs with AWS RDS, Python, Fluentd, and Kibana]]></title>
            <link>https://medium.com/@sudarshan_jai/monitoring-otp-requests-a-guide-to-visualizing-logs-with-aws-rds-python-fluentd-and-kibana-4405f81a69f0?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/4405f81a69f0</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[rds]]></category>
            <category><![CDATA[otp-services]]></category>
            <category><![CDATA[2-factor-authentication]]></category>
            <category><![CDATA[kibana]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Sat, 07 Sep 2024 17:58:02 GMT</pubDate>
            <atom:updated>2024-09-07T17:58:02.865Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s data-driven world, monitoring and visualizing logs is crucial for identifying potential security threats and understanding system usage. In this article, I’ll walk you through how to set up a logging and visualization system for OTP (One-Time Password) requests using AWS RDS, Python, Fluentd (TD Agent), and Kibana. By the end, you’ll be able to track and analyze OTP requests, spotting any anomalies or potential attacks.</p><h3>1. Overview</h3><p>Our goal is to:</p><ol><li><strong>Fetch OTP request data from AWS RDS.</strong></li><li><strong>Log the data to a file on a server.</strong></li><li><strong>Send the logs to Elasticsearch using Fluentd.</strong></li><li><strong>Visualize the data in Kibana.</strong></li></ol><h3>2. Fetch OTP Requests from AWS RDS</h3><p>We’ll start by writing a Python script to fetch OTP request data from AWS RDS. This script will run as a cron job to regularly query the RDS database and log the results.</p><p><strong>Python Script: </strong><strong>query_and_log.py</strong></p><pre>import pymysql<br>import time<br># Database connection details<br>connection = pymysql.connect(<br>    host=&#39;your-rds-endpoint&#39;,<br>    user=&#39;your-username&#39;,<br>    password=&#39;your-password&#39;,<br>    db=&#39;your-database-name&#39;<br>)<br>def fetch_data():<br>    with connection.cursor() as cursor:<br>        cursor.execute(&quot;SELECT email, primary_number FROM table name ORDER BY created_at DESC LIMIT 200;&quot;)<br>        result = cursor.fetchall()<br>        return result<br>if __name__ == &quot;__main__&quot;:<br>    data = fetch_data()<br>    timestamp = time.strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)<br>    <br>    with open(&quot;/var/log/otp_requests.log&quot;, &quot;a&quot;) as log_file:<br>        for row in data:<br>            log_file.write(f&quot;{timestamp},{row[0]},{row[1]}\n&quot;)</pre><p><strong>Setting Up Cron Job</strong> (optional)</p><p>Add the following line to your crontab (crontab -e) to run the script every 5 minutes:</p><pre>*/5 * * * * /usr/bin/python3 /path/to/query_and_log.py</pre><h3>3. Send Logs to Elasticsearch Using Fluentd</h3><p>We’ll use Fluentd (TD Agent) to ship logs from our server to Elasticsearch. Here’s how you can configure Fluentd:</p><p><strong>Fluentd Configuration: </strong><strong>/etc/td-agent/td-agent.conf</strong></p><pre>&lt;source&gt;<br>  @type tail<br>  path /var/log/otp_requests.log<br>  pos_file /var/log/td-agent/otp_requests.pos<br>  tag otp.production<br>  format /(?&lt;timestamp&gt;[^,]+),(?&lt;email&gt;[^,]+),(?&lt;primary_number&gt;[^\n]+)/<br>&lt;/source&gt;<br><br>&lt;match otp.production&gt;<br>  @type elasticsearch<br>  host yourELK---endpoint<br>  port 443<br>  scheme https<br>  logstash_format true<br>  logstash_prefix otp-production<br>  type_name fluentd<br>  log_es_400_reason true<br>  &lt;buffer&gt;<br>    flush_interval 10s<br>    retry_forever true<br>    retry_type exponential_backoff<br>  &lt;/buffer&gt;<br>&lt;/match&gt;</pre><h3>4. Visualize Data in Kibana</h3><p>With your data now in Elasticsearch, you can visualize it using Kibana.</p><p><strong>Steps to Visualize Data:</strong></p><ol><li><strong>Create an Index Pattern</strong>:</li></ol><ul><li>Go to <strong>Management</strong> &gt; <strong>Index Patterns</strong> in Kibana.</li><li>Create a new index pattern with otp-production*.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*-X3LkWHUc-m5lan-" /></figure><ol><li><strong>Create a Visualization</strong>:</li></ol><ul><li>Go to <strong>Visualize</strong> &gt; <strong>Create Visualization</strong>.</li><li>Choose <strong>Bar Chart</strong> or <strong>Data Table</strong>.</li></ul><ol><li><strong>Configure the Visualization</strong>:</li></ol><ul><li><strong>Bar Chart</strong>:</li><li><strong>X-Axis</strong>: Add a Terms aggregation on the email field.</li><li><strong>Y-Axis</strong>: Use Count to show the number of requests per email.</li><li><strong>Data Table</strong>:</li><li><strong>Buckets</strong>: Add a Terms aggregation on the email field.</li><li><strong>Metrics</strong>: Use Count.</li></ul><ol><li><strong>Save and Add to Dashboard</strong>:</li></ol><ul><li>Save your visualization.</li><li>Add it to a Kibana dashboard to monitor OTP request trends.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*r6_Yyh0-jSSlLgma" /></figure><h3>Conclusion</h3><p>By setting up this system, you can effectively monitor OTP requests and detect any unusual patterns or potential security threats. The combination of Python for data extraction, Fluentd for log shipping, and Kibana for visualization provides a powerful toolkit for comprehensive log analysis.</p><p>Feel free to adjust the script and configurations based on your specific requirements and environment. Happy monitoring!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4405f81a69f0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring Essential ELK DevTool Commands]]></title>
            <link>https://medium.com/@sudarshan_jai/exploring-essential-elk-devtool-commands-cd96c6d1812a?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd96c6d1812a</guid>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[elasticsearch]]></category>
            <category><![CDATA[commands]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Fri, 14 Jun 2024 14:03:14 GMT</pubDate>
            <atom:updated>2024-06-14T16:57:57.552Z</atom:updated>
            <content:encoded><![CDATA[<p>When working with Elasticsearch, Logstash, and Kibana (ELK Stack), having a solid grasp of various DevTool commands is crucial for effective data management and cluster operations. This blog post will delve into a set of essential ELK DevTool commands, categorizing them based on their functionalities and providing concise explanations for each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*--aKE_-Gad5aegu2vHxR8w.jpeg" /></figure><h3>Data Querying</h3><p>Data querying forms the backbone of ELK operations. One of the fundamental commands is retrieving all documents within an index, enabling a comprehensive view of the stored data:</p><pre>GET _search<br>{<br>  &quot;query&quot;: {<br>    &quot;match_all&quot;: {}<br>  }<br>}</pre><p>Similarly, for targeted searches within a specific index, we can refine our queries to fetch a subset of documents based on defined criteria:</p><pre>GET /example-index/_search<br>{<br>  &quot;from&quot;: 0, <br>  &quot;size&quot;: 10, <br>  &quot;_source&quot;: true,<br>  &quot;query&quot;: {<br>    &quot;match_all&quot;: {}<br>  }<br>}</pre><h3>Index Management</h3><p>Managing indices effectively is essential for maintaining a streamlined and optimized Elasticsearch environment. Commands like deleting an index or closing an index are vital for cleaning up or managing storage:</p><pre>DELETE /example-index-*<br>POST /example-index/_close</pre><h3>Cluster Management</h3><p>Cluster management commands are pivotal for maintaining the health and performance of the ELK stack. Viewing and updating cluster settings allows administrators to fine-tune their environment:</p><pre>GET /_cluster/settings<br>PUT /_cluster/settings<br>{<br>  &quot;persistent&quot;: {<br>    &quot;xpack.monitoring.collection.interval&quot;: &quot;10s&quot;,<br>    &quot;xpack.monitoring.history.duration&quot;: &quot;7d&quot;<br>  }<br>}</pre><p>Commands for rerouting the cluster or checking its health status ensure that data allocation and system integrity are consistently monitored:</p><pre>POST /_cluster/reroute?pretty<br>{<br>    &quot;commands&quot; : [<br>        {<br>          &quot;allocate_empty_primary&quot; : {<br>                &quot;index&quot; : &quot;example-index&quot;, <br>                &quot;shard&quot; : 0,<br>                &quot;node&quot; : &quot;node-1&quot;, <br>                &quot;accept_data_loss&quot; : &quot;true&quot;<br>          }<br>        }<br>    ]<br>}<br>GET /_cluster/health</pre><h3>Snapshot Management</h3><p>Snapshot management is a crucial aspect of data backup and recovery in Elasticsearch. Creating a snapshot repository and managing snapshots allows for safe and efficient data recovery:</p><pre>PUT /_snapshot/example-repository<br>{<br>  &quot;type&quot;: &quot;fs&quot;,<br>  &quot;settings&quot;: {<br>    &quot;location&quot;: &quot;/mnt/es_data/lib/elasticsearch/&quot;<br>  }<br>}<br><br>GET /_snapshot<br>GET /_cat/snapshots</pre><p>Restoring snapshots, whether with immediate completion or specific indices, ensures that data can be quickly restored to a known good state:</p><pre>POST /_snapshot/example-repository/2022.12.14/_restore<br>{<br>  &quot;indices&quot;: &quot;example-index-2022.12.14&quot;<br>}<br>POST /_snapshot/example-repository/2023.05.02/_restore?wait_for_completion=true<br>{<br>  &quot;indices&quot;: &quot;example-index-2023.05.02&quot;<br>}</pre><h3>Index Template Management</h3><p>Managing index templates is vital for defining consistent index configurations across multiple indices. Creating or updating templates with specific settings and mappings helps maintain a uniform structure:</p><pre>PUT /_index_template/example-template<br>{<br>  &quot;index_patterns&quot;: [&quot;example-index-*&quot;],<br>  &quot;template&quot;: {<br>    &quot;mappings&quot;: {<br>      &quot;properties&quot;: {<br>        &quot;message&quot;: {<br>          &quot;type&quot;: &quot;text&quot;<br>        }<br>      }<br>    }<br>  }<br>}</pre><p>Deleting outdated templates ensures that only relevant and current configurations are applied:</p><pre>DELETE /_index_template/example-template</pre><h3>Shard and Node Management</h3><p>Shard and node management commands help maintain data distribution and node performance. Retrieving shard and node information ensures that administrators have a clear view of the system’s state:</p><pre>GET /_cat/shards<br>GET /_cat/nodes?v</pre><p>Commands for checking allocation information and updating index settings play a critical role in optimizing resource usage and maintaining cluster balance:</p><pre>GET /_cat/allocation?v&amp;pretty<br>PUT /_settings<br>{<br>    &quot;index.routing.allocation.disable_allocation&quot;: false<br>}</pre><h3>General Index Operations</h3><p>General index operations include retrieving comprehensive index information and deleting outdated indices or templates. These commands help maintain a clean and efficient Elasticsearch environment:</p><pre>GET /_cat/indices?v<br>GET /_cat/indices?h=index,creation.date.epoch&amp;format=json&amp;s=creation.date:asc&amp;pretty<br>DELETE /example-index-*<br>DELETE /_index_template/example-template</pre><p>By mastering these essential ELK DevTool commands, administrators can effectively manage their ELK stack, ensuring optimal performance, robust data management, and efficient cluster operations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd96c6d1812a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating a Thread Dump Script for Java Applications: A DevOps Guide]]></title>
            <link>https://medium.com/@sudarshan_jai/creating-a-thread-dump-script-for-java-applications-a-devops-guide-a17484d54f54?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/a17484d54f54</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[jvm]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[bash-script]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 15:42:29 GMT</pubDate>
            <atom:updated>2024-06-06T15:42:29.226Z</atom:updated>
            <content:encoded><![CDATA[<p>In the dynamic world of software development, maintaining the health and performance of applications is crucial. One essential aspect of this is diagnosing issues that arise during runtime, especially in Java applications. A thread dump can be an invaluable tool in such scenarios, providing a snapshot of all the threads running in a Java Virtual Machine (JVM). This blog post will explore a simple script for generating thread dumps, its utility in DevOps, its origins, and how thread dumps can be analyzed using online tools.</p><h3><strong>Understanding the Script</strong></h3><p>Let’s break down the provided script and understand its functionality.</p><pre>#!/bin/bash<br><br># Check if Java is installed and get the PID of the Java process<br>JAVA_PROCESS=$(ps aux | grep java | grep -v grep | awk &#39;{print $2}&#39;)<br>if [ -z &quot;$JAVA_PROCESS&quot; ]; then<br>    echo &quot;Java process not found.&quot;<br>    exit 1<br>fi<br><br># Generate a thread dump using jstack<br>TIMESTAMP=$(date +&quot;%Y-%m-%d_%H-%M-%S&quot;)<br>THREAD_DUMP_FILE=&quot;thread_dump_$TIMESTAMP.txt&quot;<br>jstack $JAVA_PROCESS &gt; $THREAD_DUMP_FILE<br><br># Check if the thread dump file was created successfully<br>if [ -f &quot;$THREAD_DUMP_FILE&quot; ]; then<br>    echo &quot;Thread dump saved to $THREAD_DUMP_FILE&quot;<br>else<br>    echo &quot;Failed to generate thread dump.&quot;<br>fi</pre><h3><strong>Script Breakdown</strong></h3><ol><li><strong>Checking for Java Process</strong>: The script begins by checking if a Java process is running. It does this by using the ps aux command to list all running processes and then filtering for the java process using grep. The process ID (PID) is extracted using awk.</li><li><strong>Generating the Thread Dump</strong>: If a Java process is found, the script proceeds to generate a thread dump. The jstack utility is used for this purpose. jstack prints Java stack traces of Java threads, and these traces are saved to a file named with a timestamp to ensure uniqueness.</li><li><strong>Verifying the Dump Creation</strong>: Finally, the script checks if the thread dump file was successfully created and provides appropriate feedback.</li></ol><h3><strong>Importance of Thread Dumps</strong></h3><p>Thread dumps are crucial for diagnosing and troubleshooting issues in Java applications. They provide a snapshot of the JVM’s thread state, which can help identify deadlocks, high CPU usage, and other performance-related issues. By analyzing thread dumps, developers and DevOps engineers can pinpoint the root cause of problems and implement solutions effectively.</p><h3><strong>Using the Script in DevOps</strong></h3><p>In a DevOps environment, automation and monitoring are key to maintaining application health. This script can be integrated into automated monitoring systems to periodically generate thread dumps or trigger them in response to specific alerts, such as high CPU usage or memory leaks. Here are some practical applications:</p><ul><li><strong>Automated Diagnostics</strong>: Integrate the script with monitoring tools like Nagios or Prometheus to automatically generate thread dumps when performance anomalies are detected.</li><li><strong>Scheduled Dumps</strong>: Use cron jobs to schedule regular thread dumps for periodic health checks.</li><li><strong>Incident Response</strong>: Include the script in incident response procedures to quickly gather diagnostic information when issues are reported.</li></ul><h3><strong>Analyzing Thread Dumps with Online Tools</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0WrTAbs9unq5KJpbpq0ggg.png" /></figure><p>After generating a thread dump, the next step is to analyze it to understand the state of the JVM. Various online tools can assist in this analysis by providing a user-friendly interface and advanced insights:</p><ul><li><strong>FastThread.io</strong>: This tool helps in quickly analyzing thread dumps by providing visualizations and identifying common issues like deadlocks and thread contention.</li><li><strong>ThreadDumpAnalyzer</strong>: A part of the Java Mission Control suite, this tool offers detailed analysis and insights into the state of your JVM.</li><li><strong>IBM Thread and Monitor Dump Analyzer</strong>: This tool provides comprehensive analysis and reporting on thread dumps, helping to identify performance bottlenecks and threading issues.</li></ul><h3>How to Use Online Tools</h3><ol><li><strong>Generate the Thread Dump</strong>: Use the script provided to generate a thread dump file.</li><li><strong>Upload the Thread Dump</strong>: Go to an online thread dump analysis tool, such as FastThread.io.</li><li><strong>Analyze the Results</strong>: Upload your thread dump file, and the tool will process and analyze it, providing detailed insights and visualizations.</li><li><strong>Review and Act</strong>: Review the findings to identify any issues, such as deadlocks or thread contention, and take appropriate actions to resolve them.</li></ol><h3>Origins of Thread Dumps and jstack</h3><p>The concept of thread dumps originates from the need to analyze the state of a program during its execution, particularly in multi-threaded environments like Java applications. The jstack utility, part of the JDK (Java Development Kit), was introduced by Sun Microsystems (now Oracle) to aid developers in debugging and optimizing their Java applications.</p><h3>Conclusion</h3><p>The provided script is a simple yet powerful tool for generating thread dumps in Java applications. By integrating it into your DevOps practices and leveraging online tools for analysis, you can enhance your application’s reliability and performance. Thread dumps, facilitated by tools like jstack, are indispensable for diagnosing and troubleshooting complex issues, ensuring that your applications run smoothly in production environments.</p><p>Feel free to adapt and extend this script to suit your specific needs, and always ensure that your diagnostic processes are robust and automated to the extent possible.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a17484d54f54" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NTP servers and how to setup your own]]></title>
            <link>https://medium.com/@sudarshan_jai/ntp-servers-and-how-to-setup-your-own-1ebd4fab84c3?source=rss-ae9f0e928542------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ebd4fab84c3</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[protocol]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[ntp-server]]></category>
            <dc:creator><![CDATA[Sudarshan Jaikrishnan]]></dc:creator>
            <pubDate>Wed, 01 May 2024 09:50:38 GMT</pubDate>
            <atom:updated>2024-05-01T09:50:38.327Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0dRPuclAQGuH7SGxXPnU_Q.png" /></figure><p><strong>What is NTP?</strong></p><p>NTP stands for Network Time Protocol, It is one of the oldest protocols still in use. This is a networking protocol used for clock synchronization among computer systems. This has been around since the 1980’s <a href="https://en.wikipedia.org/wiki/David_L._Mills">David L. Mills</a> A professor from the university of Delaware is credited as the man who designed the NTP.</p><p>The NTP is most commonly associated with the client-server model where the computers in a network are synchronized to within few milliseconds of coordinated universal time, commonly referred as UTC. Synchronizing time is one of the fundamentals of any network and hence the NTP is a quintessential component in the modern computing world. Currently NTP is at its 4th version (NTPv4).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/0*VkOQiT4PbtvIJMMh" /></figure><p>To better understand how NTP works here’s a guide to set up your own NTP host and clients.</p><h3>Setup</h3><p>In this project we will be setting up a host and a client to which it will connect to.</p><p>In this case we are using UBUNTU 18.04 LTS VMs for setup.</p><p><strong>Stage 1 : setting up your Host Server</strong></p><p><strong>Step 1</strong></p><p>Update the repository</p><pre>$ sudo apt-get update</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*N0VdeJpXuerebjeM" /></figure><p><strong>Step 2</strong></p><p>Install NTP server with apt-get</p><pre>$ sudo apt-get install ntp</pre><p>Verify the installation</p><pre>$ sntp --version</pre><p><strong>Step 3</strong></p><p>Open the configuration file and add the time server pools</p><pre>$ sudo nano /etc/ntp.conf</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VrLFLZQfTdDU18Uo" /></figure><p>We need to change the highlighted portion which is the time pools list</p><p>In this case im choosing India zone<br><a href="http://www.pool.ntp.org/">www.pool.ntp.org</a> visit this website for time pools</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*bfWU-6HWp8tSbEuc" /></figure><p><strong>Step 4</strong></p><p>Copy the pools and add it to the config file like so</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*HZWD-6Cdh3uIhfxy" /></figure><p><strong>Step 5</strong></p><p>Restart the NTP server</p><pre>$ sudo service ntp restart</pre><p>Then check NTP status</p><pre>$ sudo service ntp status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iC7FV5evH2dzmFpI" /></figure><p><strong>Step 6</strong><br>Configure firewall to allow clients to connect</p><pre>$ sudo ufw allow from any to any port 123 proto udp</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/0*pU9UHc7b4zsGm_i3" /></figure><p><strong>Stage 2 : Set up the client</strong></p><p><strong>Step 7</strong></p><p>Install ntpdate on client</p><p>The ntpdate command will let you manually check your connection configuration with the NTP-server.</p><pre>$ sudo apt-get install ntpdate</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/0*_HR5U2OESJ09GFsJ" /></figure><p><strong>Step 8</strong></p><p>Specify the ip and the host name in the client config file</p><pre>$ sudo nano /etc/hosts</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/0*MuQx4syKTlDM29Cc" /></figure><p><strong>Step 9</strong></p><p>Check if client time is synchronized with host</p><pre>$ sudo ntpdate NTP-server-host</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*nniuQtDjEi4WBnI8" /></figure><p><strong>Step 10</strong></p><p>Disable Systemd timesyncd service on client</p><p>Cos we need our client to sync with our NTP host</p><pre>$ sudo timedatectl set-ntp off</pre><p><strong>Step 11</strong></p><p>Install NTP on the client</p><pre>$ sudo apt-get install ntp</pre><p>Add server ntphost prefer iburst at the end of conf file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1023/0*olZT0P-DxlfSP-Z0" /></figure><p><strong>Step 13</strong></p><p>Restart the NTP service</p><pre>$ sudo service ntp restart</pre><p><strong>Step 14</strong></p><pre>$ ntpstat</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1017/0*QBUwhaooR0b1UjBL" /></figure><p>Host vs Client</p><p>We can see that the Host and client are in sync</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*00Wn74RaSm_ZMKkd" /></figure><p>Congratulations your machines are now synced</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ebd4fab84c3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>