<?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 Agraj Mangal on Medium]]></title>
        <description><![CDATA[Stories by Agraj Mangal on Medium]]></description>
        <link>https://medium.com/@agraj?source=rss-f914d72684c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*DoGjuRWxW5u8hDrw3NH8lQ.png</url>
            <title>Stories by Agraj Mangal on Medium</title>
            <link>https://medium.com/@agraj?source=rss-f914d72684c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 00:59:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@agraj/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[So You Want To Be A Senior Engineer!]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/so-you-want-to-be-a-senior-engineer-13ab12105316?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/630/1*XaEYPdnIWXQakPEFJ6x9Yg.jpeg" width="630"></a></p><p class="medium-feed-snippet">There are a lot of buzzwords in our industry floating around to address a Senior Engineer ranging from &#x201C;Senior Software Engineer&#x201D; to&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/so-you-want-to-be-a-senior-engineer-13ab12105316?source=rss-f914d72684c------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/so-you-want-to-be-a-senior-engineer-13ab12105316?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/13ab12105316</guid>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[engineer]]></category>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[technical-leadership]]></category>
            <category><![CDATA[growth]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Thu, 03 Nov 2022 12:30:03 GMT</pubDate>
            <atom:updated>2022-11-03T12:30:03.726Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Secure your Microservices on AKS — Part 3 — The Network !]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://agraj.medium.com/secure-your-microservices-on-aks-part-3-the-network-dfde7d26af8c?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/1071/1*5U4AyZm2MQlXYAjOHAUXxA.png" width="1071"></a></p><p class="medium-feed-link"><a href="https://agraj.medium.com/secure-your-microservices-on-aks-part-3-the-network-dfde7d26af8c?source=rss-f914d72684c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://agraj.medium.com/secure-your-microservices-on-aks-part-3-the-network-dfde7d26af8c?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfde7d26af8c</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[firewall]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Tue, 04 May 2021 04:26:25 GMT</pubDate>
            <atom:updated>2021-05-05T11:00:50.451Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Secure your Microservices on AKS — Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://agraj.medium.com/secure-your-microservices-on-aks-part-2-5496bf2ba00c?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/715/1*sL9MIVvzK95KUThT_5_gsA.png" width="715"></a></p><p class="medium-feed-snippet">In the first article, we created a very simple Spring Boot App, dockerized it and deployed that to an Azure AD managed AKS cluster using&#x2026;</p><p class="medium-feed-link"><a href="https://agraj.medium.com/secure-your-microservices-on-aks-part-2-5496bf2ba00c?source=rss-f914d72684c------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://agraj.medium.com/secure-your-microservices-on-aks-part-2-5496bf2ba00c?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5496bf2ba00c</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[azure-policies]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[managed-identity]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Mon, 19 Apr 2021 15:15:33 GMT</pubDate>
            <atom:updated>2021-04-19T16:41:56.575Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Running Your Microservices Securely on AKS]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://itnext.io/running-your-microservices-securely-on-aks-417a110b2e76?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/727/1*VlqVhKB3SNzH0TyEgayMVw.jpeg" width="727"></a></p><p class="medium-feed-snippet">Azure offers different ways to build &amp; run your microservices ranging from Service Fabric to Azure Kubernetes Service to App Services to&#x2026;</p><p class="medium-feed-link"><a href="https://itnext.io/running-your-microservices-securely-on-aks-417a110b2e76?source=rss-f914d72684c------2">Continue reading on ITNEXT »</a></p></div>]]></description>
            <link>https://itnext.io/running-your-microservices-securely-on-aks-417a110b2e76?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/417a110b2e76</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Wed, 31 Mar 2021 13:47:32 GMT</pubDate>
            <atom:updated>2021-04-01T11:36:52.927Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Kafka on Azure Kubernetes Service, Part 2]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/kafka-on-azure-kubernetes-service-part-2-a837889ecadc?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/1036/1*Yeuufg2c8DXtBWZY8FNP9w.jpeg" width="1036"></a></p><p class="medium-feed-snippet">Learn how to run Kafka on Kubernetes, exposing brokers outside the cluster securely &amp; scraping Prometheus metrics using Azure Monitor</p><p class="medium-feed-link"><a href="https://medium.com/swlh/kafka-on-azure-kubernetes-service-part-2-a837889ecadc?source=rss-f914d72684c------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/kafka-on-azure-kubernetes-service-part-2-a837889ecadc?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a837889ecadc</guid>
            <category><![CDATA[azure-kubernetes-service]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Tue, 15 Sep 2020 03:20:42 GMT</pubDate>
            <atom:updated>2020-09-16T06:59:01.187Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Apache Kafka in Azure]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://itnext.io/apache-kafka-in-azure-6985ccdce89f?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/1215/1*inWBfpNfCkPaWudezVqqGw.png" width="1215"></a></p><p class="medium-feed-snippet">Compare &amp; choose the right way to run Kafka in Azure. Right for your use case&#xA0;!</p><p class="medium-feed-link"><a href="https://itnext.io/apache-kafka-in-azure-6985ccdce89f?source=rss-f914d72684c------2">Continue reading on ITNEXT »</a></p></div>]]></description>
            <link>https://itnext.io/apache-kafka-in-azure-6985ccdce89f?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6985ccdce89f</guid>
            <category><![CDATA[azure-event-hub]]></category>
            <category><![CDATA[apache-kafka]]></category>
            <category><![CDATA[confluent-cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Tue, 09 Jun 2020 12:02:14 GMT</pubDate>
            <atom:updated>2020-07-26T08:14:44.753Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Azure Functions + Docker + Java]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/azure-functions-docker-java-135c827593e9?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/1019/1*CQpu-VhBb02DItK_p5zRPw.png" width="1019"></a></p><p class="medium-feed-snippet">I don&#x2019;t really want to re-iterate and focus on the fact that Microsoft loves Linux (whether it is about shipping a full linux kernel in&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/azure-functions-docker-java-135c827593e9?source=rss-f914d72684c------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/azure-functions-docker-java-135c827593e9?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/135c827593e9</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[azure]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Fri, 03 Apr 2020 03:23:21 GMT</pubDate>
            <atom:updated>2020-04-18T11:34:36.721Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[YACR: Yet Another CKAD Resource]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/yacr-yet-another-ckad-resource-46c654de871?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/1540/1*2zfm2voS-Hw9WSEgNtE2dA.png" width="1540"></a></p><p class="medium-feed-snippet">There is an abundance of tips &amp; tricks for clearing the coveted CKAD exam by CNCF&#x200A;&#x2014;&#x200A;so why I&#x2019;m going to the trouble of writing one more&#xA0;&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/yacr-yet-another-ckad-resource-46c654de871?source=rss-f914d72684c------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/yacr-yet-another-ckad-resource-46c654de871?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/46c654de871</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[training]]></category>
            <category><![CDATA[certification]]></category>
            <category><![CDATA[ckad]]></category>
            <category><![CDATA[cncf]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Wed, 15 Jan 2020 22:41:40 GMT</pubDate>
            <atom:updated>2020-01-16T20:38:24.686Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Monitoring Kafka on Kubernetes with Prometheus]]></title>
            <link>https://medium.com/swlh/monitoring-kafka-on-kubernetes-with-prometheus-5b1d1518102?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b1d1518102</guid>
            <category><![CDATA[prometheus]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[grafana]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[monitoring]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Mon, 09 Dec 2019 05:50:35 GMT</pubDate>
            <atom:updated>2019-12-09T12:48:27.340Z</atom:updated>
            <content:encoded><![CDATA[<p>This is the second blog is our series of “<a href="https://medium.com/@agrajm/running-kafka-on-azure-kubernetes-service-d8d6882ade8">Running Kafka on Kubernetes</a>” — for context and initial setup, readers are encouraged the read the <a href="https://medium.com/@agrajm/running-kafka-on-azure-kubernetes-service-d8d6882ade8">first entry</a> to be able to setup Apache Kafka on <a href="https://azure.microsoft.com/en-gb/services/kubernetes-service/">Azure Kubernetes Service</a> with enabled end-to-end encryption.</p><blockquote>“Everything fails, all the time !” — Werner Vogels, Amazon CTO</blockquote><p>While the probability of failure has decreased, but what Werner said in 2008 still holds true to a great extent, no matter whether you run your application in a on-prem environment or use any public cloud, the virtual machine running your software will eventually fail. And this is why having proper monitoring and alerting mechanisms in place is of quintessential importance. And this is why we see industries adopting concepts like <a href="https://docs.microsoft.com/en-us/azure/devops/learn/what-is-infrastructure-as-code">Infrastructure as Code (IAC)</a> &amp; <a href="https://www.digitalocean.com/community/tutorials/what-is-immutable-infrastructure">Immutable Infrastructure</a> and are increasingly investing in building SRE and/or DevOps culture in their teams.</p><h3>Let’s get Started !</h3><p>In this blog post, we explore how we can use Prometheus &amp; Grafana for monitoring and alerting requirements and configure the Kafka Cluster to expose not only pod level metrics ( Memory, CPU, Available Disk Space, JVM GC Time and Memory Used, Network metrics etc) but also more Kafka contextual metrics like Consumer Lag, Messages produced and consumed per second, Number of Replicas per Topic/Partition, Number of In-Sync Replicas per Topic/Partition etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*xZamkeyaqCOcgMUTt528yA.png" /></figure><h4>Prometheus</h4><p>Prometheus joined <a href="https://www.cncf.io/">CNCF</a> in 2016 and become the second hosted project (second only to Kuberenetes) — this should be enough to convince you on the active community behind the project and the fact that it could be considered as a standard for monitoring &amp; alerting. It offers a multi-dimensional data model with time series data identified by metric name and key/value pairs and a flexible query language (<a href="https://prometheus.io/docs/prometheus/latest/querying/basics/">PromQL</a>) to select and aggregate tune series data in real time. Some important notes about Prometheus before we proceed with the setup:</p><ol><li>Prometheus does not require you to install any agents onto your services/jobs which you want to be monitored, rather it works on a pull-based model — where you expose metrics from your service and it will pull those metrics at a configurable interval.</li><li>You can configure Alerting rules/expressions in Prometheus which when evaluate to true, will result in an alert being pushed to another component known as <a href="https://prometheus.io/docs/alerting/alertmanager/">Alert Manager</a>. Alert Manager can then be configured with various notification channels like Pager Duty, Email, Slack channels etc. to send out these alert notifications to the concerned DevOps/SRE teams.</li><li>Prometheus does provides a basic Web UI for visualizing these metrics but again the community has mostly converged to use <a href="https://grafana.com/">Grafana </a>for visualization requirements.</li><li>Kubernetes provides an add-on agent: <a href="https://github.com/kubernetes/kube-state-metrics">kube-state-metrics</a> which listens to Kuberenetes API Server and generates and exposes cluster-level metrics about the health of various objects like Deployments, Pods, Nodes etc. kube-state-metrics also exposes a Prometheus compatible endpoint which can easily be configured for consumption.</li><li>Prometheus also provides another exporter for hardware and OS level metrics, exposed by *NIX kernels: <a href="https://github.com/prometheus/node_exporter">Node Exporter</a> — you can deploy this as a DaemonSet on your cluster (one node exporter per node) and then expose the metrics using a Service to expose the metrics which will be automatically scrapped by Prometheus if you use the annotation prometheus.io/scrape:&#39;true&#39; — An example for the same can be downloaded from <a href="https://coreos.com/assets/blog/promk8s/node-exporter.yaml">here </a>and applied to your cluster using kubectl Another way to install the same is using a <a href="https://github.com/helm/charts/tree/master/stable/prometheus-node-exporter">Helm chart</a></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/892/1*ztl7ii-FrK0GOL8mxwVFFQ.png" /><figcaption>Basic Monitoring Setup</figcaption></figure><h3>Set it up !</h3><p>Now that we have a basic understanding of what we want to achieve, let’s start with installing Prometheus &amp; Grafana on our Kubernetes cluster. As always there are multiple options but we will stick with our friendly-neighborhood-operators to help us out with it. Let’s first create the namespace for our monitoring setup</p><pre>kubectl create namespace monitoring</pre><h4>Step 1: Install the Prometheus Operator</h4><p>kube-prometheus provides a quick way to deploy Prometheus operator, Prometheus server, Grafana, Highly available Alert Manager, Node Exporter, kube-state-metrics and other helpful tools. I personally feel like losing control when deploying everything under manifests for <a href="https://github.com/coreos/kube-prometheus">kube-prometheus</a> so we will take a different way to deploy these components, but your mileage may vary so feel free to deploy everything using kube-prometheus. However if you want to deploy using kube-prometheus on AKS, you must label your nodes correctly. The deployment configuration of some of these manifests include the <a href="https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector">nodeSelector</a> as</p><pre>nodeSelector:<br>    kubernetes.io/os: linux</pre><p>This will not work by default with your AKS Cluster, so you must label your nodes accordingly using kubectl</p><pre>kubectl label nodes &lt;node-name&gt; kubernetes.io/os=linux</pre><p>What we’ll do instead for our example is to take things slowly and deploy things one-at-a-time, starting with <a href="https://github.com/coreos/prometheus-operator">Prometheus Operator</a>: The Prometheus Operator requires certain Kubernetes RBAC related resources like ServiceAccount , ClusterRole and ClusterRoleBinding in order to be able to authenticate against the API server and watch the custom resources for Prometheus — all the code for this blog post can be found on <a href="https://github.com/agrajm/strimzi-kafka-aks/tree/master/monitoring">Github </a>so please clone the repository and follow along</p><blockquote>Clone the repo from <a href="https://github.com/agrajm/strimzi-kafka-aks/tree/master/monitoring">Github</a> to follow along.</blockquote><p>So let’s start by creating ServiceAccount, ClusterRole &amp; ClusterRoleBinding for our Operator in the monitoring namespace</p><pre>kubectl apply -f monitoring/prometheus-setup/prometheus-operator-service-account.yaml -n monitoring<br>kubectl apply -f monitoring/prometheus-setup/prometheus-operator-cluster-role.yaml -n monitoring<br>kubectl apply -f monitoring/prometheus-setup/prometheus-operator-cluster-role-binding.yaml -n monitoring<br>kubectl apply -f monitoring/prometheus-setup/prometheus-operator-deployment.yaml -n monitoring</pre><h4>Step 2: Create a Service Monitor</h4><p>Before we go further with deploying Prometheus server, we need to configure Recording &amp; Alerting rules; let’s must take a step back and understand a bit more about how the operator works, what are the custom resources it exposes, how they interact with each other etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkDR1MHjJ9RK1-8IjOTklg.png" /><figcaption>Source: <a href="https://sysdig.com/blog/kubernetes-monitoring-prometheus-operator-part3/">Sysdig</a></figcaption></figure><p><strong>Service Monitors</strong> are one of the Custom Resources offered by the Prometheus Operator and basically provides a way to tell the operator to target new Kubernetes Services for scraping by Prometheus. A ServiceMonitor should be deployed in the same namespace where Prometheus is deployed, although it could target services deployed in other namespaces also using namespaceSelector property. Here is the truncated version of the Service Monitor yaml used to scrape Kafka related metrics from the earlier deployed Kafka Cluster</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1ea826f0c15882177573ceb77330c103/href">https://medium.com/media/1ea826f0c15882177573ceb77330c103/href</a></iframe><p>Couple of things to note here:</p><ol><li>spec.selector.matchLabels is used to target the service by matching labels.</li><li>spec.selector.namespaceSelector.matchNames is used to select the namespace in which the service is running.</li></ol><pre>kubectl apply -f monitoring/strimzi-service-monitor.yaml -n monitoring</pre><h4>Step 3: Setup some Prometheus Rules</h4><p>Another Custom Resource PrometheusRule can be used to configure alert rules in Prometheus. Here is how one looks</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/918651b0119f4f1dd2660c3c01787b71/href">https://medium.com/media/918651b0119f4f1dd2660c3c01787b71/href</a></iframe><pre>kubectl apply -f prometheus-rules.yaml -n monitoring</pre><h4>Step 4: Edit the Kafka Cluster</h4><p>Now is the time to edit the existing Kafka cluster ( we created in the<a href="https://medium.com/@agrajm/running-kafka-on-azure-kubernetes-service-d8d6882ade8"> earlier blog post</a> ) and add the following items:</p><h4>Step 4 a) Add Metrics for Kafka Brokers &amp; Zookeepers</h4><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b593d5d85e0c0ce0baab4d5c1d65e1b/href">https://medium.com/media/0b593d5d85e0c0ce0baab4d5c1d65e1b/href</a></iframe><p>Above is a snippet of how metrics are added to Kafka Brokers and Zookeeper. Prometheus offers <a href="https://prometheus.io/docs/concepts/metric_types/">four core metric types </a>— Counter, Gauge, Histogram and Summary</p><h4>Step 4 b) Kafka Exporter</h4><p>While Prometheus has a <a href="https://github.com/prometheus/jmx_exporter">JMX exporter</a> that is configured to scrape and expose mBeans of a JMX target, Kafka Exporter is an <a href="https://github.com/danielqsj/kafka_exporter">open source project</a> used to enhance monitoring of Apache Kafka brokers and clients by extracting additional metrics data from Kafka brokers related to offsets, consumer groups, consumer lag, and topics. Some useful examples of alerts that can be created based on these metrics are:</p><ul><li>Under Replicated Partitions of a Topic</li><li>ConsumerGroup Lag is too large = Very Slow Consumers, falling behind producers</li><li>An alert can be created if there is no message on a topic for a configurable amount of time</li></ul><p>Add the following snippet after spec.zookeeper to tls-kafka.yaml</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58df7f3e30bf113cdd7e272e2cbb7382/href">https://medium.com/media/58df7f3e30bf113cdd7e272e2cbb7382/href</a></iframe><p>Time to update our existing Kafka Cluster:</p><pre>kubectl apply -f monitoring/tls-kafka.yaml</pre><blockquote><a href="https://github.com/danielqsj/kafka_exporter">Kafka Exporter</a> enhances monitoring of Apache Kafka brokers and clients by extracting additional metrics data from Kafka brokers related to offsets, consumer groups, consumer lag, and topics.</blockquote><h4>Step 5: Create the Prometheus Server</h4><p>Now that we have the Operator running, we will create the custom resource for Prometheus specifying some config and the Operator will spin up a Deployment to manage the Prometheus server instance.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4c076bf77d2aad770394baa052616359/href">https://medium.com/media/4c076bf77d2aad770394baa052616359/href</a></iframe><p>The above gist only shows the important piece of the puzzle — the Prometheus Custom Resource. The complete code is present <a href="https://github.com/agrajm/strimzi-kafka-aks/blob/master/monitoring/prometheus.yaml">here</a>.</p><p>Before we deploy this, it is recommended to add some additional scraping targets for cAdvisor, kubelet, pods &amp; services. They can be added to the Prometheus resource using spec.additionalScrapeConfigs property. To do so, we need to create the following Kubernetes Secret</p><pre>kubectl create secret generic additional-scrape-configs --from-file=prometheus-additional.yaml -n monitoring</pre><p>Now let’s deploy the Prometheus Server</p><pre>kubectl apply -f monitoring/prometheus.yaml -n monitoring</pre><p>And that’s it. The operator does the rest — creates the Prometheus server instance and a couple of services and we can now simply do a port-forward and open up the basic Web UI offered by Prometheus</p><pre>kubectl port-forward prometheus-prometheus-0 9090:9090 -n monitoring</pre><p>Now point your browser to http://localhost:9090 and you would see something similar to the below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ksytj1TWg_em8r-LTqcLSQ.png" /><figcaption>Local Prometheus Server</figcaption></figure><p>This UI can also be used to see configured Alerts, how many of them are active and and details about when they were fired.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JKI_N53m7mka5I7WRXHm0Q.png" /><figcaption>Alerts UI</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w0vDT6QXwBb3p7YPIecPuA.png" /><figcaption>Details of Alert being Fired</figcaption></figure><p>We will see in subsequent sections on how to configure the Alert Manager to send out these alerts/notifications and how a much better visualization tool can be used to see these metrics in action !</p><h3>Alert Manager</h3><p>Alert Manager is responsible for passing on the generated alerts to the configured notification receivers. Examples of receivers could be chat clients like Microsoft Teams, Slack or on-call notification systems like OpsGenie or PagerDuty. It provides a way to integrate with your own notification/alerting systems via <a href="https://prometheus.io/docs/alerting/configuration/#webhook_config">Webhooks</a> as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/955/1*PgnerB6pXqsVY6UcfzF1wA.png" /><figcaption>Alert Manager Overview</figcaption></figure><p>So AlertManager is responsible for grouping related alerts, silencing and inhibiting alerts if related alerts already occurred, de-duplicating alerts and finally distributing to configured receivers. Following Prometheus Operator guidelines, to create and configure AlertManager, we need</p><ol><li>AlertManager Custom Resource specifying a name and the number of replicas needed for the StatefulSet it deploys</li><li>A Kuberenetes Secret holding the configuration for AlertManager — the secret must be named as alertmanager-{name} where name is the name of the Custom Resource created in the first step. This secret is created from a YAML file specifying the <a href="https://prometheus.io/docs/alerting/configuration/#example">configuration</a> of the Alert Manager — which may include the routes , receivers , inhibit_rules , templates for the alerts.</li><li>A Kubernetes Service which exposes the AlertManager so that it can interact with Prometheus and receive alerts.</li></ol><p>Since the AlertManager pod will not start up until the secret alertmanager-{name} is deployed so we start by creating the secret from our config file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16b04d5c19161a4cb7821ca812411f18/href">https://medium.com/media/16b04d5c19161a4cb7821ca812411f18/href</a></iframe><pre>kubectl create secret generic alertmanager-alertmanager --from-file=monitoring/alertmanager-setup/alertmanager.yaml -n monitoring</pre><blockquote>Important to note that the config file for alertmanager must be named alertmanager.yaml — nothing else would work. The secret alertmanager-{name} must be created from a config file named alertmanager.yaml</blockquote><p>Next, we create the Custom Resource for AlertManager</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/70a99726575ee48d9c2b1a993f06c056/href">https://medium.com/media/70a99726575ee48d9c2b1a993f06c056/href</a></iframe><pre>kubectl apply -f monitoring/alertmanager-setup/alert-manager.yaml</pre><p>That’s it — no need to connect Prometheus with AlertManager. The Operator will take care of doing that for you. See following as an example of a very <em>raw</em> alert being posted to the configured slack channel. Of course, you have the option to specify a template and custom image to format the message body.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*zmdpeoFgcQCkqRfIZyqLBA.png" /><figcaption>Raw Alert messages being posted to slack !</figcaption></figure><h3>Grafana</h3><p>Grafana is an open-source visualization framework that could be used to work with disparate data sources including Prometheus. Since Grafana is not really a part of Prometheus stack, so the prometheus operator does not offer a CRD to install or manage Grafana and its connections to Prometheus, rather you can simply install Grafana on AKS using a Deployment and a Service</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/72ef46fbac18dc09a467eb4b8adc991c/href">https://medium.com/media/72ef46fbac18dc09a467eb4b8adc991c/href</a></iframe><p>Install this in your AKS cluster using</p><pre>kubectl apply -f monitoring/grafana.yaml -n monitoring</pre><p>This deploys the Grafana server and exposes it via a Service — you can access the GUI using port-forwarding</p><pre>kubectl port-forward grafana-85d856cf58-s5m4g 3000:3000 -n monitoring</pre><p>Go ahead and access the Grafana UI at http://localhost:3000 and login with default admin/admin credentials — change the admin password on first login and then configure Prometheus DataSource using the prometheus-operated Kubernetes Service we created along with Prometheus Custom Resource. See the list of services using kubectl</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jeB4B8XYzNxCcGl14ZgrZg.png" /></figure><p>Select Add Data Source → Prometheus → enter the details as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aEescKQBEoI2amrsoiHcuQ.png" /></figure><h4>Import Dashboards</h4><p>The awesome community at Strimzi provides us with certain quickstart/example dashboards for Grafana which can be used as a starting point to explore the metrics</p><ol><li><a href="https://github.com/agrajm/strimzi-kafka-aks/blob/master/monitoring/grafana-dashboards/strimzi-kafka.json">Strimzi-Kafka</a> — Shows basic metrics for Kafka Brokers</li><li><a href="https://github.com/agrajm/strimzi-kafka-aks/blob/master/monitoring/grafana-dashboards/strimzi-zookeeper.json">Strimzi-Zookeeper</a> — Shows metrics related to Zookeeper pods</li><li><a href="https://github.com/agrajm/strimzi-kafka-aks/blob/master/monitoring/grafana-dashboards/strimzi-kafka-exporter.json">Kafka-Exporter</a> — Metrics exported using <a href="https://github.com/danielqsj/kafka_exporter">Kafka Exporter</a>.</li></ol><p>Import these dashboards in Grafana and start playing around.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ldIm-YeYSn2f_NEpV_6aA.jpeg" /><figcaption>Strimzi Kafka Dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8m9lJHQzPOvlBFG5Fh5IVA.jpeg" /><figcaption>Kafka Exporter Dashboard</figcaption></figure><h3>Performance Testing</h3><p>You can also run the Kafka Performance Test Tools kafka-producer-perf-test.sh and kafka-consumer-perf-test.sh —as an example to do so, exec into the configured kafka clients and execute</p><pre>bin/kafka-producer-perf-test.sh --topic test-one-rep --num-records 50000000 --record-size 100 --throughput 1 --producer-props acks=1 bootstrap.servers=my-tls-cluster-kafka-bootstrap.tls-kafka:9093 buffer.memory=67108864 batch.size=8196 --producer.config /opt/kafka/config/ssl-config.properties</pre><p>Here are <a href="https://gist.github.com/ueokande/b96eadd798fff852551b80962862bfb3#file-benchmark-commands-md">some benchmark commands</a> that you might find helpful.</p><h3>Conclusion</h3><p>I hope this article helps you with setting up your monitoring environment using Prometheus and enable you to be more proactive in dealing with the infrastructure you work with.</p><h4>References</h4><ul><li><a href="https://github.com/danielqsj/kafka_exporter">Kafka Exporter</a></li><li><a href="https://sysdig.com/blog/kubernetes-monitoring-prometheus-operator-part3/">Kubernetes Monitoring with Prometheus Operator</a></li><li><a href="https://github.com/coreos/kube-prometheus">kube-prometheus</a>: Deploy Prometheus Operator to Kubernetes with quickstart manifests for Prometheus, Grafana, Alert Manager, node-exporter, kube-state-metrics etc.</li><li><a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-digitalocean-kubernetes-cluster-monitoring-with-helm-and-prometheus-operator">DigitalOcean: Kuberenetes Cluster Monitoring with Helm &amp; Prometheus Operator</a></li><li><a href="https://blog.pilosus.org/posts/2019/06/01/prometheus-operator-no-active-targets/">Add new scraping targets via ServiceMonitor</a></li><li><a href="https://lapee79.github.io/en/article/prometheus-alertmanager-with-msteams/">Integrating Prometheus AlertManager with Microsoft Teams</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b1d1518102" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/monitoring-kafka-on-kubernetes-with-prometheus-5b1d1518102">Monitoring Kafka on Kubernetes with Prometheus</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Kafka on Azure Kubernetes Service]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://medium.com/swlh/running-kafka-on-azure-kubernetes-service-d8d6882ade8?source=rss-f914d72684c------2"><img src="https://cdn-images-1.medium.com/max/899/1*7m5L5OulpEGFRHgy0jy6OQ.png" width="899"></a></p><p class="medium-feed-snippet">Yes, Kubernetes was not designed for Stateful workloads. Yes StatefulSets and PersistentVolumes can be hard to reason about. Also when&#x2026;</p><p class="medium-feed-link"><a href="https://medium.com/swlh/running-kafka-on-azure-kubernetes-service-d8d6882ade8?source=rss-f914d72684c------2">Continue reading on The Startup »</a></p></div>]]></description>
            <link>https://medium.com/swlh/running-kafka-on-azure-kubernetes-service-d8d6882ade8?source=rss-f914d72684c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8d6882ade8</guid>
            <category><![CDATA[microsoft-azure]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[hands-on]]></category>
            <dc:creator><![CDATA[Agraj Mangal]]></dc:creator>
            <pubDate>Wed, 04 Dec 2019 23:34:54 GMT</pubDate>
            <atom:updated>2020-09-15T03:31:20.586Z</atom:updated>
        </item>
    </channel>
</rss>