<?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" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ cloudnative - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ cloudnative - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Fri, 29 May 2026 23:04:15 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/cloudnative/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Monitor Your Kubernetes Clusters with Prometheus and Grafana on AWS ]]>
                </title>
                <description>
                    <![CDATA[ Creating a solid application monitoring and observability strategy is a critical foundational step when deploying infrastructure or software in any environment. Monitoring ensures that your systems are running smoothly, while observability provides i... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/kubernetes-cluster-observability-with-prometheus-and-grafana-on-aws/</link>
                <guid isPermaLink="false">6790382dcb2eedbe449b6899</guid>
                
                    <category>
                        <![CDATA[ Kubernetes ]]>
                    </category>
                
                    <category>
                        <![CDATA[ AWS ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Grafana ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Devops ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Cloud ]]>
                    </category>
                
                    <category>
                        <![CDATA[ cloudnative ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Eti Ijeoma ]]>
                </dc:creator>
                <pubDate>Wed, 22 Jan 2025 00:13:33 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/res/hashnode/image/upload/v1737504669572/017570c6-7676-44e1-aa19-4257dd7d30e7.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Creating a solid application monitoring and observability strategy is a critical foundational step when deploying infrastructure or software in any environment. Monitoring ensures that your systems are running smoothly, while observability provides insights into the internal state of your application through the data generated. Together, they help you detect and address issues proactively rather than reacting after a failure occurs.</p>
<p>In Kubernetes environments, the complexity of managing distributed microservices can be challenging. For instance, an application usually spans multiple pods, nodes, and clusters. Because of Kubernetes’s dynamic nature, where pods are frequently created and terminated, proper monitoring and observability are ideal for capturing its fleeting behavior.</p>
<p>Imagine building a microservices application with several connected services handling critical components such as authentication, payments, and databases without proper monitoring. A sudden traffic spike could affect a single service, cascading to other services, causing the system to crash and resulting in downtime.</p>
<p>Without proper visibility, you may struggle to find the root cause of the issue. You may spend hours manually going through logs – and meanwhile, users are frustrated, and businesses are losing revenue and customer trust.</p>
<p>Before we begin the project, you’ll learn key monitoring and observability concepts, as well as why tools like Prometheus and Grafana are crucial for setting up a robust monitoring stack on your Kubernetes infrastructure.</p>
<h3 id="heading-heres-what-well-cover">Here’s what we’ll cover:</h3>
<ul>
<li><p><a class="post-section-overview" href="#heading-understanding-monitoring-and-observability">Understanding Monitoring and Observability</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-tools-for-monitoring-and-observability">Tools for Monitoring and Observability</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-how-to-deploy-prometheus-and-grafana-on-aws-eks-using-helm">How to Deploy Prometheus and Grafana on AWS EKS using Helm</a></p>
</li>
<li><p><a class="post-section-overview" href="#heading-conclusion">Conclusion</a></p>
</li>
</ul>
<h2 id="heading-understanding-monitoring-and-observability">Understanding Monitoring and Observability</h2>
<p>Implementing a proper monitoring and observability approach is important in fast-paced production Kubernetes environments. This helps in situations where downtime can lead to serious business loss and damage to customer trust. It’ll hopefully help you avoid the dreaded 2 am calls that are usually triggered by alert noise so you can focus on adding more innovative features to your software (rather than spending so much energy firefighting).</p>
<p>Monitoring and observability are often referred to as the same thing. But they serve two different purposes, especially for development and engineering teams.</p>
<h3 id="heading-monitoring">Monitoring</h3>
<p>In the software development lifecycle, monitoring is the practice of analyzing data in real time or reviewing data trends to ensure the health and performance of systems, infrastructure, and applications. Monitoring acts as the eyes and ears of your IT operations, collecting insightful data and presenting it in a way that is actionable.</p>
<p>If you have visited the IT department of a well-established organization, you have most likely seen large screens displaying colorful dashboards with charts and real-time statistics. This offers a centralized view of the key metrics, such as the server uptime, application response times, and resource usage.</p>
<h3 id="heading-observability">Observability</h3>
<p>Observability helps to address issues that haven’t been anticipated. These are usually called “unknown unknowns."  Unlike monitoring, which deals with predefined parameters and data, observability goes deeper into the application to give a broader view.</p>
<p>This not only helps to answer what is happening within your system and why it is happening. It also uses patterns within the system and application operations to detect and resolve issues efficiently. </p>
<p>Observability revolves around the three pillars of data: <strong>metrics</strong>, <strong>logs</strong>, and <strong>traces</strong>.</p>
<h4 id="heading-1-metrics">1. Metrics</h4>
<p>Metrics consist of time-series measurements such as CPU usage and memory consumption. These data points help teams to manage, optimize, and predict system performance and deviations from expected behavior.</p>
<h4 id="heading-2-logs">2. Logs</h4>
<p>Logs serve as a history of what happened within the system. It is a trail for engineers, especially during troubleshooting. Logs are important in diagnosing root causes and discovering malicious activities.</p>
<h4 id="heading-3-traces">3. Traces</h4>
<p>Traces provide insights into application workflows by tracking requests as they move through various components. They are good for highlighting latency issues and potential points of failure.</p>
<h2 id="heading-tools-for-monitoring-and-observability">Tools for Monitoring and Observability</h2>
<p>Now that you understand the theory behind monitoring and observability, you may be wondering what platforms and tools are available to developers to collect data and get insights about their services.</p>
<p>In the world of cloud-native infrastructure and Kubernetes, many users gravitate towards the popular stack of Prometheus and Grafana.</p>
<h3 id="heading-prometheus">Prometheus</h3>
<p>Prometheus is an open-source tool that specializes in collecting metrics as time-series data. The information is stored with the timestamp when it was recorded.<br>The Prometheus ecosystem includes the main Prometheus server, which scrapes and stores time-series data, an alert manager for managing alerts, a push gateway for handling metrics from short-lived jobs, and exporters for collecting metrics from various services connected to the cluster.</p>
<p>It fits both in machine-centric and application-centric monitoring, especially for microservices in a Kubernetes cluster. It’s designed to be the system you go to if there is a system outage and you need to quickly diagnose problems.</p>
<p>The Prometheus ecosystem includes the main Prometheus server, which scrapes and stores time-series data, an alert manager for managing alerts, a push gateway for handling metrics from short-lived jobs, and exporters for collecting metrics from various services connected to the cluster.</p>
<p>Prometheus fits both in machine-centric and application-centric monitoring, especially for microservices in a Kubernetes cluster. It’s designed to be the system you go to if there is a system outage and you need to quickly diagnose problems.</p>
<h3 id="heading-grafana">Grafana</h3>
<p>Grafana is a visualization tool that transforms, queries, visualizes, and sets alerts on raw metrics stored in Prometheus. With Grafana, you can explore metrics and logs wherever they are stored and display the data on live dashboards. This allows teams to monitor system performance, identify trends, and act quickly on anomalies.</p>
<p>Prometheus and Grafana are compatible with containerized applications, especially in Kubernetes environments. It can also manage workloads outside Kubernetes for flexibility. They are both open-source tools that give developers control over the implementation. There is no licensing cost, which helps teams that cannot afford expensive, powerful solutions.</p>
<p>By combining Prometheus and Grafana, your team gets helpful insights into the system to optimize performance, track errors, and aid troubleshooting processes.</p>
<h2 id="heading-how-to-deploy-prometheus-and-grafana-on-aws-eks-using-helm">How to Deploy Prometheus and Grafana on AWS EKS using Helm</h2>
<h3 id="heading-prerequisites">Prerequisites</h3>
<p>For this project, we will use an EC2 instance with the Ubuntu 22.04 operating system. If you are using Windows or a Mac, log into AWS to create your virtual machine.</p>
<p>Here’s what else you’ll need:</p>
<h4 id="heading-1-aws-account-setup-with-access-keys-and-secret-keys">1. AWS account setup with access keys and secret keys</h4>
<ul>
<li><p><a target="_blank" href="https://portal.aws.amazon.com/billing/signup">AWS Sign Up</a></p>
</li>
<li><p><a target="_blank" href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html">AWS Access ID and Secret Keys</a></p>
</li>
</ul>
<h4 id="heading-2-knowledge-of-kubernetes">2. Knowledge of Kubernetes</h4>
<ul>
<li><a target="_blank" href="https://kubernetes.io/docs/home/">Kubernetes Official Documentation</a></li>
</ul>
<h4 id="heading-3-aws-cli-installation-for-the-virtual-server">3. AWS CLI installation for the virtual server</h4>
<ul>
<li><a target="_blank" href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installation Guide</a></li>
</ul>
<h3 id="heading-getting-started">Getting Started</h3>
<p>Let’s start by setting up an EKS cluster on a virtual server and installing the required tools on the server. Then, we’ll deploy our monitoring tools, Prometheus and Grafana, using Helm charts. In the end, we’ll deploy an NGINX web application on Kubernetes and use Grafana to visualize the pod performance and cluster resource usage on the cluster.</p>
<h3 id="heading-step-1-install-aws-cli-eksctl-kubectl-and-helm">Step 1: Install AWS CLI, <code>eksctl</code>, <code>kubectl</code>, and Helm</h3>
<p>AWS CLI is a tool that allows users to interact with AWS services using the command-line interface. It makes the management of cloud resources simpler and enables admins to configure AWS services.</p>
<p>Here, we will install AWS CLI on our server to be able to create Kubernetes resources.</p>
<p>On your server, run the following commands:</p>
<pre><code class="lang-bash">curl <span class="hljs-string">"https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"</span> -o <span class="hljs-string">"awscliv2.zip"</span>

sudo apt install unzip

unzip awscliv2.zip

sudo ./aws/install
</code></pre>
<p>Verify the installation by running this:</p>
<pre><code class="lang-bash">aws --version
</code></pre>
<p>After installation, configure the AWS CLI with your credentials using the following command:</p>
<pre><code class="lang-bash">aws configure
</code></pre>
<p>You will be prompted to enter your AWS Access Key ID, Secret Access Key, Default region name, and default output format.</p>
<p>Next, we need to install eksctl. <code>eksctl</code> is a command-line tool that simplifies the creation and management of Kubernetes clusters on AWS. It helps you configure, set, and maintain clusters and allows you to manage clusters more effectively.</p>
<p>This tool removes the complexities of setting up a production-grade cluster, helping you and your admins focus only on application development and deployment.</p>
<p>To set up <code>eksctl</code> on your machine, download the latest release using the following command:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># for ARM systems, set ARCH to: arm64, armv6 or armv7</span>
ARCH=amd64

PLATFORM=$(uname -s)_<span class="hljs-variable">$ARCH</span>

curl -sLO <span class="hljs-string">"https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_<span class="hljs-variable">$PLATFORM</span>.tar.gz"</span>

<span class="hljs-comment"># (Optional) Verify checksum</span>

curl -sL <span class="hljs-string">"https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt"</span> | grep <span class="hljs-variable">$PLATFORM</span> | sha256sum --check

tar -xzf eksctl_<span class="hljs-variable">$PLATFORM</span>.tar.gz -C /tmp &amp;&amp; rm eksctl_<span class="hljs-variable">$PLATFORM</span>.tar.gz

sudo mv /tmp/eksctl /usr/<span class="hljs-built_in">local</span>/bin
</code></pre>
<p>Run <code>eksctl version</code> to confirm its successful installation and the version downloaded.</p>
<pre><code class="lang-bash">eksctl version <span class="hljs-comment"># 0.198.0</span>
</code></pre>
<p>Next, we’ll run Kubectl which is a command line interface for managing and interacting with Kubernetes clusters. It enables users to deploy and manage applications within a Kubernetes environment.</p>
<p>With Kubectl, you can perform various crucial operations such as scaling, deployments, inspecting cluster status, and managing networking.</p>
<p>To install <code>kubectl</code>, run the following commands:</p>
<pre><code class="lang-bash">curl -LO <span class="hljs-string">"https://storage.googleapis.com/kubernetes-release/release/<span class="hljs-subst">$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)</span>/bin/linux/amd64/kubectl"</span>
chmod +x ./kubectl
sudo mv ./kubectl /usr/<span class="hljs-built_in">local</span>/bin
</code></pre>
<p>Run <code>kubectl</code> on your command line to confirm it has been installed successfully:</p>
<pre><code class="lang-bash">kubectl version 
<span class="hljs-comment"># client version: 0.198.0</span>
<span class="hljs-comment"># Kustomize Versionv: 5.4.2</span>
<span class="hljs-comment"># Server Version: v1.30.7-eks-56e63d8</span>
</code></pre>
<p>Finally, we’ll install Helm which is a Kubernetes Package manager that simplifies the deployments and management of applications in Kubernetes. It uses <a target="_blank" href="https://helm.sh/docs/topics/charts/"><strong>charts</strong></a> to define Kubernetes resources into a collection of files, handles templating and versioning, and makes application deployment easier.</p>
<p>Here, we will install the Helm package manager on our virtual machine for our cluster deployments. This downloads the installation script and saves it in the <code>get_helm.sh</code> file.</p>
<p>Next, the file is set to executable, which allows only the user to run it. Finally, the script is executed using the <code>./get_helm.sh</code> command.</p>
<pre><code class="lang-bash">curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3

chmod 700 get_helm.sh

./get_helm.sh
</code></pre>
<h3 id="heading-step-2-create-a-kubernetes-cluster">Step 2: Create a Kubernetes Cluster</h3>
<p>Next, we need to create our Kubernetes cluster in AWS with the <code>eksctl</code> command line. We can do this with the following command:</p>
<pre><code class="lang-bash">eksctl create cluster --name my-prac-cluster-1 --version 1.30 --region us-east-1 --nodegroup-name worker-nodes --node-type t2.medium --nodes 2 --nodes-min 2 --nodes-max 3
</code></pre>
<p><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXf-np7NdxK-zwQLtYoVE51RUoHYMf5GBHT1tAEjV-eoxk2xCvH13s0tjzPdIb8QVt5amijSBjkpaAh4AuPQd4DJvtnKmMpPQ1_dFoRx1KRNRiCto0U7CpXU-rsd-KH8NhuQoHfRAg?key=U2Fi6zvcj43zRMwXR2oKCzLU" alt="Terminal window in Visual Studio Code displaying a series of commands and outputs related to setting up an EKS cluster. The log includes status updates, such as &quot;creating addon&quot; and &quot;EKS cluster resources have been created.&quot; The environment is Ubuntu, visible through the desktop interface and application icons on the left." width="1366" height="768" loading="lazy"></p>
<p>Let’s break down the command:</p>
<ul>
<li><p><code>–name my-prac-cluster-1</code>: This specifies the name of the EKS cluster that will be created. In this case, the cluster will be named <strong>my-prac-cluster-1</strong>.</p>
</li>
<li><p><code>–version 1.30</code>: This sets the Kubernetes version for the cluster. Here, the version will be version 1.30.</p>
</li>
<li><p><code>--region us-east-1</code>: This specifies the AWS region where the cluster will be provisioned on AWS. Here, it is set to us-east-1.</p>
</li>
<li><p><code>--nodegroup-name worker-nodes</code>: This defines the name of the node groups that will be created. In this case, it’s named <strong>worker-nodes</strong>.</p>
</li>
<li><p><code>--node-type t2.large</code>: This sets the instance type for the worker nodes in the <code>node-group</code>.</p>
</li>
<li><p><code>--nodes 2</code>: This sets the desired number of worker nodes in the node group.</p>
</li>
<li><p><code>--nodes-min 2</code>: This sets the minimum number of worker nodes that should be maintained in the node group to 2.</p>
</li>
<li><p><code>--nodes-max 3</code>: This defines the maximum number of worker nodes allowed in the node group and sets it to 3.</p>
</li>
</ul>
<p>Once the cluster comes up, run the command <code>kubectl get nodes</code> to ensure that the cluster is set up properly.</p>
<h3 id="heading-step-3-install-the-metrics-server">Step 3: Install the Metrics Server</h3>
<p>The metrics server is a component that collects resource data from the Kubelets on each node in the cluster. This includes metrics such as CPU, memory, and network usage, which Prometheus can access. The server provides a single source of truth for resource data and is easy to deploy and use.</p>
<p>Run the following script to install the metrics server:</p>
<pre><code class="lang-bash">kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml
</code></pre>
<p>To verify the installation, run the following command:</p>
<pre><code class="lang-bash">kubectl get deployment metrics-server -n kube-system
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734913540206/47361106-21b0-4076-91c2-ffb8a925b372.jpeg" alt="A terminal screenshot displaying the command output for `kubectl get deployment metrics-server -n kube-system`. It shows the deployment details of &quot;metrics-server&quot; with readiness, up-to-date and available statuses as 1, and an age of 51 minutes." class="image--center mx-auto" width="1122" height="234" loading="lazy"></p>
<h3 id="heading-step-4-install-the-iam-oidc-identity-provider-and-amazon-ebs-csi-driver">Step 4: Install the IAM OIDC Identity Provider and Amazon EBS CSI Driver</h3>
<p>The IAM OpenID connect provider allows Kubernetes access to AWS resources within the cluster. Here, we need EBS volumes to create persistent storage for Prometheus pods.</p>
<p>Run the following commands to create the IAM OIDC provider:</p>
<pre><code class="lang-bash">eksctl utils associate-iam-oidc-provider --cluster my-prac-cluster-1 --approve
</code></pre>
<p>Next, we will create the Amazon EBS CSI Driver that will provide permissions for the cluster to access the EBS volumes. Replace the placeholder “my-cluster” with your cluster name.</p>
<pre><code class="lang-bash">eksctl create iamserviceaccount \

--name ebs-csi-controller-sa \

--namespace kube-system \

--cluster my-prac-cluster-1 \

--role-name AmazonEKS_EBS_CSI_DriverRole \

--role-only \

--attach-policy-arn arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy \

--approve
</code></pre>
<p>Now, we need to add the AWS EBS Driver Addon to the cluster using the following commands:</p>
<pre><code class="lang-bash">eksctl create addon --name aws-ebs-csi-driver --cluster &lt;cluster_name&gt; --service-account-role-arn arn:aws:iam::&lt;AWS_ACCOUNT_ID&gt;:role/AmazonEKS_EBS_CSI_DriverRole --force
</code></pre>
<p>Adding the AWS EBS CSI Driver to your Kubernetes cluster enables the cluster to dynamically create and manage EBS volumes for persistent storage within the cluster. Since our Prometheus installation needs persistent volumes, this add-on will enable the cluster to create EBS volumes to persist data.</p>
<p>Now, our future Prometheus installation will create EBS volumes for persistent storage.</p>
<h3 id="heading-step-5-install-prometheus-and-grafana">Step 5: Install Prometheus and Grafana.</h3>
<p>To install Prometheus and Grafana, we need to add the Helm Stable Charts for the local client.</p>
<p>Run the command below:</p>
<pre><code class="lang-bash">helm repo add stable https://charts.helm.sh/stable
</code></pre>
<p>Next, we will add the Prometheus Helm repo:</p>
<pre><code class="lang-bash">helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
</code></pre>
<p>We’ll use the Prometheus community version because it is well-maintained by the Prometheus community. It offers faster updates and continuous improvements for different Kubernetes environments.</p>
<p>Next, create the Prometheus namespace:</p>
<pre><code class="lang-bash">kubectl create namespace prometheus
</code></pre>
<p>Install Prometheus and Grafana through the <code>kube-prometheus-stack</code> Helm Chart:</p>
<pre><code class="lang-bash">helm install stable prometheus-community/kube-prometheus-stack -n prometheus
</code></pre>
<p>When that’s done, verify that the Prometheus deployment and service are installed by using the command below:</p>
<pre><code class="lang-bash">kubectl get all -n prometheus
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734913921541/9b851fcc-c390-4d86-9108-adaaddd58d07.jpeg" alt="Terminal output showing Kubernetes resources in the &quot;prometheus&quot; namespace. It lists several pods and services, each with information on readiness, status, restarts, age, type, cluster IP, and ports. All pods are in the &quot;Running&quot; status, with no restarts." class="image--center mx-auto" width="1135" height="597" loading="lazy"></p>
<p>At this stage, you should change the service type from a ClusterIP to a LoadBalancer in the manifest file. We can update the file by running the command below:</p>
<pre><code class="lang-bash">kubectl edit svc stable-kube-prometheus-sta-prometheus -n prometheus
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734914216836/217e2e5e-1d75-4ca4-88eb-56276f25c12f.jpeg" alt=" Screenshot of a Kubernetes service YAML file edited with kubectl for Prometheus in the prometheus namespace." class="image--center mx-auto" width="1172" height="584" loading="lazy"></p>
<p>After the update, a LoadBalancer URL will be generated for you to access your Prometheus Dashboard.</p>
<p><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcWtK8G1cJTD8GI-vACe_KexsXIp5SEXYiGTuBXZNQJ93tpo-XrMVb6ekA1ZRDrAODyFn29p3JdQDOHCdMnq2eapX4drdLMJ_8u_B8z1Jl0LqJjIHJwwIbDhgRUU5tlkGhhnBdYKQ?key=U2Fi6zvcj43zRMwXR2oKCzLU" alt=" Prometheus dashboard showing the &quot;Targets&quot; page with active scrape pools, including details such as endpoints, state, labels, last scrape, scrape duration, and errors for Prometheus Alertmanager services." width="1366" height="768" loading="lazy"></p>
<p>Next, we’ll move over to Grafana. Change the SVC file of Grafana to create a LoadBalancer and expose it to the public using the command below:</p>
<pre><code class="lang-bash">kubectl edit svc stable-grafana -n prometheus
</code></pre>
<p>Next, we will update the Grafana SVC file by changing the service <code>type</code> from <code>ClusterIP</code> to <code>LoadBalancer</code> to expose it to the public using the command below:</p>
<pre><code class="lang-bash">kubectl edit svc stable-grafana -n prometheus
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734914435224/1ab76b93-2b35-4074-92cb-c7c3173edaee.jpeg" alt=" Screenshot of a Kubernetes service YAML configuration file edited using kubectl edit svc stable-grafana -n prometheus, displaying the details for the Grafana service in the prometheus namespace" class="image--center mx-auto" width="1144" height="601" loading="lazy"></p>
<p>Once the settings are saved, you can use the <code>LoadBalancer</code> link to access your Grafana Dashboard from the browser. The username is <strong>admin</strong>. To get the login password printed in the terminal, run the following command:</p>
<pre><code class="lang-bash">kubectl get secret --namespace prometheus stable-grafana -o jsonpath=<span class="hljs-string">"{.data.admin-password}"</span> | base64 --decode ; <span class="hljs-built_in">echo</span>
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734915573534/12b64c7f-b74b-4ebb-8a1b-ae6c5357f76a.jpeg" alt="Grafana login screen displaying input fields for email/username and password with a notification indicating a successful login." class="image--center mx-auto" width="1276" height="629" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734915606224/bc06a48b-75e8-4115-816b-462c69975d97.jpeg" alt="Grafana welcome dashboard after a successful authentication" class="image--center mx-auto" width="1243" height="636" loading="lazy"></p>
<p>After successfully logging into the Grafana dashboard, the first step is to create a <code>datasource</code> that will provide the metrics for the Grafana visualization.</p>
<p>Go to <strong>Add your first data source</strong> and choose Prometheus as the Data Source.</p>
<p>Insert the Prometheus URL, and click on “<strong>Save and Test</strong>”. It should show success if Grafana queries the Prometheus URL successfully.</p>
<p>The next step is to create a Dashboard that our Grafana visualization will use to view the metrics of our pods. To do so, click on “<strong>Dashboards</strong>” and then on “<strong>Add Visualization.</strong>”</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734915769650/10f7877b-7183-4709-b672-ff6d67ef529d.jpeg" alt="Screenshot of a configuration interface showing options for custom query parameters and HTTP method (set to POST) for Prometheus data source. Confirmation message states, &quot;Successfully queried the Prometheus API,&quot; with options to delete or save &amp; test." class="image--center mx-auto" width="1293" height="627" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734915836669/3fb27ce9-23d9-4c35-abf6-7ce44508720d.jpeg" alt="Grafana Dashboard interface with options to add a visualization, import a panel, or import a dashboard. There is a prominent button for adding a visualization." class="image--center mx-auto" width="1263" height="622" loading="lazy"></p>
<p>You’d be taken to an environment where you’d be required to import a dashboard. Select the data source as “<strong>Prometheus-1</strong>” and use the code “<strong>15760</strong>” to import the Node Exporter dashboard to view our pods.</p>
<p>Click on Load after importing the dashboard, and you will see your newly created dashboard.</p>
<p>Here, we can see the entire data of the cluster, the CPU and RAM use, and data regarding pods in a specified namespace.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734917376090/9e0097f4-07bb-495a-9572-060db373334c.jpeg" alt="Screenshot of a Grafana interface showing a &quot;Select data source&quot; window. Two data sources named &quot;Prometheus&quot; and &quot;prometheus-1&quot; are listed. Options for using mixed data sources, dashboards, and Grafana mock data are on the right." class="image--center mx-auto" width="1266" height="579" loading="lazy"></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734917392381/c7e01350-d90e-43a1-b172-82899f377d82.jpeg" alt="Screenshot of Grafana's &quot;Import dashboard&quot; page, showing options to upload a JSON file or enter a dashboard ID. The ID &quot;15760&quot; is entered in the input box, and there is a JSON model example displayed below." class="image--center mx-auto" width="1284" height="637" loading="lazy"></p>
<h3 id="heading-step-6-deploying-an-application-on-kubernetes-to-monitor-on-grafana">Step 6: Deploying an Application on Kubernetes to Monitor on Grafana.</h3>
<p>Finally, we will deploy an NGINX container in our EKS Cluster to monitor using Grafana. We need to create a Yaml deployment and service file.</p>
<pre><code class="lang-yaml"><span class="hljs-attr">apiVersion:</span> <span class="hljs-string">apps/v1</span>

<span class="hljs-attr">kind:</span> <span class="hljs-string">Deployment</span>

<span class="hljs-attr">metadata:</span>

<span class="hljs-attr">name:</span> <span class="hljs-string">nginx-app</span>

<span class="hljs-attr">spec:</span>

<span class="hljs-attr">replicas:</span> <span class="hljs-number">2</span>

<span class="hljs-attr">selector:</span>

<span class="hljs-attr">matchLabels:</span>

<span class="hljs-attr">app:</span> <span class="hljs-string">nginx-app</span>

<span class="hljs-attr">template:</span>

<span class="hljs-attr">metadata:</span>

<span class="hljs-attr">labels:</span>

<span class="hljs-attr">app:</span> <span class="hljs-string">nginx-app</span>

<span class="hljs-attr">spec:</span>

<span class="hljs-attr">containers:</span>

<span class="hljs-bullet">-</span> <span class="hljs-attr">name:</span> <span class="hljs-string">nginx-app</span>

<span class="hljs-attr">image:</span> <span class="hljs-string">nginx:latest</span>

<span class="hljs-attr">ports:</span>

<span class="hljs-bullet">-</span> <span class="hljs-attr">containerPort:</span> <span class="hljs-number">80</span>

<span class="hljs-meta">---</span>

<span class="hljs-attr">apiVersion:</span> <span class="hljs-string">v1</span>

<span class="hljs-attr">kind:</span> <span class="hljs-string">Service</span>

<span class="hljs-attr">metadata:</span>

<span class="hljs-attr">name:</span> <span class="hljs-string">nginx-app</span>

<span class="hljs-attr">spec:</span>

<span class="hljs-attr">type:</span> <span class="hljs-string">LoadBalancer</span>

<span class="hljs-attr">ports:</span>

<span class="hljs-bullet">-</span> <span class="hljs-attr">port:</span> <span class="hljs-number">80</span>

<span class="hljs-attr">targetPort:</span> <span class="hljs-number">80</span>

<span class="hljs-attr">selector:</span>

<span class="hljs-attr">app:</span> <span class="hljs-string">nginx-app</span>
</code></pre>
<p>To deploy the Node.js application on the Kubernetes cluster, use the following <code>kubectl</code> command. Verify the deployment by running the following <code>kubectl</code> command:</p>
<pre><code class="lang-bash">kubectl apply -f deployment.yml

kubectl get deployment

kubectl get pods
</code></pre>
<p>Click the load balancer URL to see your application on your browser:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734917018333/987b78c4-cae0-42dc-bd19-0a4f8a6a6b10.jpeg" alt="Browser window displaying the default welcome page for Nginx, indicating successful installation and suggesting further configuration." class="image--center mx-auto" width="1162" height="710" loading="lazy"></p>
<p>Let’s refresh our Grafana dashboard to see our NGINX web application in Grafana.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734917096760/72815d56-04a5-47cf-8b2b-89164ccb7e7a.jpeg" alt="A Kubernetes dashboard showing CPU and memory usage by container. The CPU usage graph is on the left, and the memory usage graph is on the right. Both graphs display data for containers named &quot;nginx-app&quot; over the last 5 minutes." class="image--center mx-auto" width="1278" height="626" loading="lazy"></p>
<h3 id="heading-step-7-deleting-the-cluster">Step 7: Deleting the Cluster</h3>
<p>Now that everything is set up, we can delete our Kubernetes Cluster to avoid extra costs. Run the following commands to do so:</p>
<pre><code class="lang-bash">eksctl delete cluster my-prac-cluster-1 –region us-east-1
</code></pre>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1734917455255/04b00a79-d963-4e28-bc99-4cb6ea8c65cf.jpeg" alt="A terminal window displaying a series of commands and system messages related to the deletion of an EKS cluster and associated resources. It shows timestamps for each action, status updates, and confirmation that all cluster resources were deleted successfully." class="image--center mx-auto" width="1192" height="657" loading="lazy"></p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>This article teaches the theory behind monitoring and observability and highlights the roles of Prometheus and Grafana in these processes.</p>
<p>We went through a hands-on deployment of Prometheus and Grafana on an EKS cluster and a web application to illustrate how they can be effectively monitored using Grafana.</p>
<p>By leveraging these tools, administrators can enjoy real-time visibility into their Kubernetes infrastructure, easily spot performance bottlenecks, and confidently make decisions that enhance application performance and reliability.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
