<?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 jkelly on Medium]]></title>
        <description><![CDATA[Stories by jkelly on Medium]]></description>
        <link>https://medium.com/@code_jk?source=rss-edc3ea99f91------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kiWHVzppXmlLM4pPmwlnZw.jpeg</url>
            <title>Stories by jkelly on Medium</title>
            <link>https://medium.com/@code_jk?source=rss-edc3ea99f91------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 19:51:48 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@code_jk/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[Elixir/Phoenix Centralized HTTP Logging]]></title>
            <link>https://medium.com/bleacher-report-engineering/elixir-phoenix-centralized-http-logging-aa50efe3105b?source=rss-edc3ea99f91------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa50efe3105b</guid>
            <category><![CDATA[phoenix]]></category>
            <category><![CDATA[elixir]]></category>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[elk]]></category>
            <category><![CDATA[performance]]></category>
            <dc:creator><![CDATA[jkelly]]></dc:creator>
            <pubDate>Tue, 23 Aug 2016 20:54:16 GMT</pubDate>
            <atom:updated>2016-08-23T21:04:29.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MG6-2pQstfxwATrovDlLcg.png" /><figcaption>The power of centralized logging. Visualize the latency of all microservices in an entire environment in real time.</figcaption></figure><h4>Centralized Logging</h4><p>With horizontally scaled monoliths or services, the default logging behavior for most web frameworks has diminishing value with each new server. Out of the box, a framework typically has its logs written to STDOUT or a log file, which works great when first starting a project. However, once you start using your service in production debugging becomes a guessing game of hoping the server whose logs you are tailing happens to be the one to handle the request, and that traffic is low where you are able to see the log before more requests replace it on your screen.</p><p>Centralized logging solves this problem by having all your servers relay their logs to a centralized database. With all your logs going to one database, you gain all the database features for filtering and finding the exact information you need. Finding a single service’s issue or comparing and contrasting a service to other services even in different environments becomes trivial.</p><p>One of the software stacks for accomplishing this is called “ELK”. ELK is an abbreviation for Elasticsearch, Logstash, &amp; Kibana is one of the more popular solutions for centralized logging over the past few years. At Bleacher Report we outsourced the “ELK” software stack by using Logz (<a href="https://logz.io/">https://logz.io</a>), which is an ELK/logging software as a service. “ELK” is a very JVM centric stack so it made sense for us to have someone else do all the JVM tuning and setup, as we don’t use the JVM for our services.</p><p>In addition to Logz which gave us the functionality to format, view, and visualize our logs, we needed the functionality to send our logs to Logz. For that functionality we used Filebeat (<a href="https://www.elastic.co/products/beats/filebeat">https://www.elastic.co/products/beats/filebeat</a>) which is a logstash forwarder written in Golang by the “ELK” creators, Elastic. Our OPS team setup an AWS Elastic Beanstalk extension to have our log files rotated (so the log files don’t use all our disk space) and forwarded to Logz though Filebeat.</p><h4>Plug_logger_json</h4><p>After discovering Logz, I started to integrate it with one of our Elixir Phoenix applications but soon hit road blocks around formatting our logs into JSON (Logz’s recommended format) and logging more fields than what Phoenix’s Plug.Logger logs by default. I searched existing packages, but didn’t find the right fit for our use case so I then began creating plug_logger_json (<a href="https://github.com/bleacherreport/plug_logger_json">https://github.com/bleacherreport/plug_logger_json</a>).</p><p>The end result was that plug_logger_json formats an http log as JSON and logs the following fields about a request:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YCqn1QHMwxYYl1XVYmONQg.png" /></figure><p>In addition to the above fields, filebeat adds the field beat.hostname. This is a key part of our setup as our hostnames include the service name and environment which allows us to use that single field to filter by service or environment. A query of “beat.hostname: *prod*” will return metrics for all production instances. Likewise, a query of “beat.hostname: *stag-articles” will return metrics for all our staging article instances.</p><p>With these metrics being logged to logz, we’ve been able to do dashboard visualizations to:</p><ul><li>View 95 percentile response times for any given environment, service, host or controller action</li><li>View average response times for any given environment, service, host or controller action</li><li>View the percentage of our requests with any given HTTP status code (500 internal server error for example) and view the exact request (with sensitive information filtering) that caused the 500.</li><li>View the req/s for any given environment, service, host or controller action</li><li>View our most/least popular endpoints</li><li>View usage percentages for android, iOS, and web browsers</li><li>View CDN response times</li><li>Trace requests across microservices to find where an error occurred</li><li>and more</li></ul><p>Best of all, all these metrics can be viewed historically or in real time. Without first class New Relic Elixir support, we’ve still effectively built out our own application monitoring tools through Logz. This has been incredibly valuable as we’ve been able to standardize our logging across all our Elixir and Phoenix apps.</p><p>We’re already using this system in production for many of our Elixir services for monitoring and have even used it for performance testing how our services handle 10x production traffic.</p><p>To try plug_logger_json for yourself, check out the README at <a href="https://github.com/bleacherreport/plug_logger_json/blob/master/README.md">https://github.com/bleacherreport/plug_logger_json</a> to view the latest setup information. Setting up plug_logger_json takes less than 5 minutes!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa50efe3105b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/bleacher-report-engineering/elixir-phoenix-centralized-http-logging-aa50efe3105b">Elixir/Phoenix Centralized HTTP Logging</a> was originally published in <a href="https://medium.com/bleacher-report-engineering">Bleacher Report Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>