<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Victor Koncurat</title>
    <description>The latest articles on DEV Community by Victor Koncurat (@victorkoncurat).</description>
    <link>https://dev.to/victorkoncurat</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4269404%2F6cf7c844-3640-4122-89ec-56045f46ddab.png</url>
      <title>DEV Community: Victor Koncurat</title>
      <link>https://dev.to/victorkoncurat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/victorkoncurat"/>
    <language>en</language>
    <item>
      <title>Building a Lightweight HTTP Health &amp; Latency Monitor in Python</title>
      <dc:creator>Victor Koncurat</dc:creator>
      <pubDate>Fri, 27 Nov 2026 17:11:43 +0000</pubDate>
      <link>https://dev.to/victorkoncurat/building-a-lightweight-http-health-latency-monitor-in-python-46d1</link>
      <guid>https://dev.to/victorkoncurat/building-a-lightweight-http-health-latency-monitor-in-python-46d1</guid>
      <description>&lt;p&gt;Monitoring critical web services and APIs shouldn't require deploying a heavy observability stack. When testing distributed endpoints or tracking response times across multiple environments, a lightweight, dependency-minimal CLI utility gives you immediate visibility into uptime and latency SLAs.&lt;/p&gt;

&lt;p&gt;I built an open-source &lt;strong&gt;HTTP Endpoint Health &amp;amp; Latency Monitor&lt;/strong&gt; in Python to automate endpoint health checks using a declarative YAML configuration file.&lt;/p&gt;

&lt;h3&gt;
  
  
  Core Capabilities
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Declarative YAML Configuration:&lt;/strong&gt; Define target URLs, expected HTTP status codes, and custom latency thresholds in a clean, human-readable &lt;code&gt;config.yaml&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sub-Millisecond Latency Measurement:&lt;/strong&gt; Tracks round-trip response times using &lt;code&gt;time.perf_counter()&lt;/code&gt; to flag endpoints that return &lt;code&gt;200 OK&lt;/code&gt; but violate response-time SLAs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Structured Terminal &amp;amp; Log Output:&lt;/strong&gt; Outputs clear pass/warn/fail status summaries suitable for cron jobs, CI/CD smoke tests, or lightweight server monitoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example Configuration (&lt;code&gt;config.yaml&lt;/code&gt;)
&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;endpoints:
  - name: "Primary API Gateway"
    url: "[https://api.example.com/health](https://api.example.com/health)"
    expected_status: 200
    max_latency_ms: 500

  - name: "Authentication Service"
    url: "[https://auth.example.com/status](https://auth.example.com/status)"
    expected_status: 200
    max_latency_ms: 350&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;
  
  
  Core Health Check Implementation
&lt;/h3&gt;

&lt;p&gt;Using Python's &lt;code&gt;requests&lt;/code&gt; library alongside &lt;code&gt;PyYAML&lt;/code&gt;, the core validation loop evaluates both HTTP status integrity and latency thresholds in a single pass:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;import time
import requests
import yaml

def check_endpoint(endpoint: dict) -&amp;gt; dict:
    url = endpoint["url"]
    expected_status = endpoint.get("expected_status", 200)
    max_latency = endpoint.get("max_latency_ms", 500)

    start = time.perf_counter()
    try:
        response = requests.get(url, timeout=5)
        latency_ms = round((time.perf_counter() - start) * 1000, 2)
        status_ok = response.status_code == expected_status
        latency_ok = latency_ms &amp;lt;= max_latency

        return {
            "name": endpoint["name"],
            "status": response.status_code,
            "latency_ms": latency_ms,
            "healthy": status_ok and latency_ok,
        }
    except requests.RequestException as exc:
        return {
            "name": endpoint["name"],
            "status": "ERROR",
            "latency_ms": None,
            "healthy": False,
            "error": str(exc),
        }

if __name__ == "__main__":
    with open("config.yaml", "r", encoding="utf-8") as f:
        config = yaml.safe_load(f)

    for target in config.get("endpoints", []):
        result = check_endpoint(target)
        state = "PASS" if result["healthy"] else "FAIL"
        print(f"[{state}] {result['name']} -&amp;gt; Status: {result['status']} | Latency: {result['latency_ms']}ms")&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;
  
  
  Source Code &amp;amp; Links
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;GitHub Profile &amp;amp; Repositories:&lt;/strong&gt; &lt;a href="https://github.com/victor-koncurat" rel="noopener noreferrer"&gt;github.com/victor-koncurat&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Full Bio &amp;amp; Projects:&lt;/strong&gt; &lt;a href="https://victorkoncurat.wordpress.com/about/" rel="noopener noreferrer"&gt;victorkoncurat.wordpress.com/about&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Technical Writing on Substack:&lt;/strong&gt; &lt;a href="https://victorkoncurat.substack.com" rel="noopener noreferrer"&gt;victorkoncurat.substack.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>python</category>
      <category>devops</category>
      <category>webdev</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
