<?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"><channel><title><![CDATA[DevOps7]]></title><description><![CDATA[DevOps7]]></description><link>https://devops7.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 24 Oct 2026 01:47:59 GMT</lastBuildDate><atom:link href="https://devops7.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[List of commonly used Git commands along with their names, uses, and syntax:]]></title><description><![CDATA[1. Initialization and Cloning: git init: Initializes a new Git repository in the current directory. git clone <repository>: Clones an existing Git…]]></description><link>https://devops7.hashnode.dev/list-of-commonly-used-git-commands-along-with-their-names-uses-and-syntax</link><guid isPermaLink="true">https://devops7.hashnode.dev/list-of-commonly-used-git-commands-along-with-their-names-uses-and-syntax</guid><category><![CDATA[List of commonly used Git commands along with their names, uses, and syntax:]]></category><dc:creator><![CDATA[Anil Kushwaha]]></dc:creator><pubDate>Tue, 16 May 2023 12:55:34 GMT</pubDate><content:encoded><![CDATA[<h2 id="heading-git-commands">Git commands:</h2>
<p><strong>1. Initialization and Cloning:</strong></p>
<ul>
<li><p><code>git init</code>: Initializes a new Git repository in the current directory.</p>
</li>
<li><p><code>git clone &lt;repository&gt;</code>: Clones an existing Git repository to your local machine.</p>
</li>
</ul>
<p><strong>2. Basic Workflow:</strong></p>
<ul>
<li><p><code>git add &lt;file&gt;</code>: Adds a file or changes to the staging area.</p>
</li>
<li><p><code>git commit -m "&lt;message&gt;"</code>: Commits the staged changes with a descriptive message.</p>
</li>
<li><p><code>git status</code>: Shows the current status of the repository.</p>
</li>
<li><p><code>git log</code>: Displays the commit history.</p>
</li>
</ul>
<p><strong>3. Branching and Merging:</strong></p>
<ul>
<li><p><code>git branch</code>: Lists all branches in the repository.</p>
</li>
<li><p><code>git branch &lt;branch-name&gt;</code>: Creates a new branch.</p>
</li>
<li><p><code>git checkout &lt;branch-name&gt;</code>: Switches to the specified branch.</p>
</li>
<li><p><code>git merge &lt;branch-name&gt;</code>: Merges changes from one branch into the current branch.</p>
</li>
<li><p><code>git rebase &lt;branch-name&gt;</code>: Incorporates changes from one branch onto another.</p>
</li>
</ul>
<p><strong>4. Remote Repository:</strong></p>
<ul>
<li><p><code>git remote add &lt;name&gt; &lt;url&gt;</code>: Adds a remote repository.</p>
</li>
<li><p><code>git remote -v</code>: Lists all remote repositories.</p>
</li>
<li><p><code>git pull &lt;remote&gt; &lt;branch&gt;</code>: Fetches changes from a remote repository and merges them into the current branch.</p>
</li>
<li><p><code>git push &lt;remote&gt; &lt;branch&gt;</code>: Pushes local commits to a remote repository.</p>
</li>
</ul>
<p><strong>5. Undoing Changes:</strong></p>
<ul>
<li><p><code>git revert &lt;commit&gt;</code>: Reverts a commit by creating a new commit that undoes the changes.</p>
</li>
<li><p><code>git reset &lt;commit&gt;</code>: Resets the repository to a specific commit, discarding subsequent commits.</p>
</li>
<li><p><code>git checkout -- &lt;file&gt;</code>: Discards changes made to a file and restores the last committed version.</p>
</li>
<li><p><code>git stash</code>: Temporarily saves changes that are not ready to be committed.</p>
</li>
</ul>
<p><strong>6. Tagging:</strong></p>
<ul>
<li><p><code>git tag</code>: Lists all tags in the repository.</p>
</li>
<li><p><code>git tag &lt;tag-name&gt;</code>: Creates a lightweight tag at the current commit.</p>
</li>
<li><p><code>git tag -a &lt;tag-name&gt; -m "&lt;message&gt;"</code>: Creates an annotated tag with a message.</p>
</li>
<li><p><code>git push --tags</code>: Pushes all local tags to the remote repository.</p>
</li>
</ul>
<p><strong>7. Collaboration:</strong></p>
<ul>
<li><p><code>git fetch</code>: Downloads changes from a remote repository but does not merge them.</p>
</li>
<li><p><code>git branch -r</code>: Lists remote branches.</p>
</li>
<li><p><code>git diff &lt;commit1&gt; &lt;commit2&gt;</code>: Shows differences between two commits.</p>
</li>
<li><p><code>git blame &lt;file&gt;</code>: Shows who last modified each line of a file.</p>
</li>
</ul>
<p>These are some of the commonly used Git commands at both basic and advanced levels. Git provides a wide range of commands to handle various scenarios and workflows. For more detailed information about each command and their options, you can refer to the Git documentation or use <code>git --help</code> or <code>git &lt;command&gt; --help</code> for specific command usage.</p>
<p>Thanks,</p>
<p>Anil Kushwaha</p>
]]></content:encoded></item><item><title><![CDATA[How to create Jenkins pipeline using build pipeline.]]></title><description><![CDATA[We are going to set up two interrelated jobs. The first job, named 'project1-build', will be a freestyle job that generates a build and 2nd job is for…]]></description><link>https://devops7.hashnode.dev/how-to-create-jenkins-pipeline-using-build-pipeline</link><guid isPermaLink="true">https://devops7.hashnode.dev/how-to-create-jenkins-pipeline-using-build-pipeline</guid><category><![CDATA[How to create Jenkins pipeline using build pipeline.]]></category><dc:creator><![CDATA[Anil Kushwaha]]></dc:creator><pubDate>Tue, 09 May 2023 10:04:39 GMT</pubDate><content:encoded><![CDATA[<p>We are going to set up two interrelated jobs. The first job, named 'project1-build', will be a freestyle job that generates a build and 2nd job is for deployment.</p>
<p><strong>Create the first freestyle build-type job in the name of "Project1-build"</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683622544055/4480e079-60c2-4562-a202-b76a20642487.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683622673680/098aefa2-9caa-4fa0-aaba-efac1068e977.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683622802852/0f1f5e49-dcab-44f0-8739-b0f97222ba55.png" alt class="image--center mx-auto" /></p>
<p><strong>Create a second freestyle deploy job.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683622885571/a9f9a713-3954-47fd-bd56-0fe9f54eb8fa.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683622999697/e5493ddf-62f6-403c-bc78-46f4e7ed4e6b.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623022243/b064f7d8-3052-4784-9634-33626a370e1a.png" alt class="image--center mx-auto" /></p>
<p><strong>Next, we install the plugin "build pipeline" to create a simple pipeline.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623216965/add2b751-beb1-45dc-a9ea-5bb05112d322.png" alt class="image--center mx-auto" /></p>
<p><strong>Now after installing the plugins just restart and re-login Jenkins.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623337311/e2aa037d-39f0-4e22-a2c6-9a2167fa6c6e.png" alt class="image--center mx-auto" /></p>
<p><strong>Next, we have to configure the "Project1 build"</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623445222/d949df9e-2fcc-43b9-b334-d25ecc0a616d.png" alt class="image--center mx-auto" /></p>
<p><strong>When our first project i.e. "Project1 build" is once done then will execute the second project so we have to choose the "Build another project" option from "Add post-build action" now.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623642063/c30cea63-7b70-4783-99a6-583ecaba5df5.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623750204/ed055950-dc2f-40a9-8139-acb481950145.png" alt class="image--center mx-auto" /></p>
<p><strong>Now our pipeline is created and next to visualize the pipeline to perform the below steps.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623931645/22fc7efb-ebfb-423f-ba9c-fb68ed577968.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683623981123/bdd832b9-4c49-4215-8b09-2b5e9a6a2781.png" alt class="image--center mx-auto" /></p>
<p><strong>Our pipeline is created under the parent &amp; child concept so here have given the job name i.e. "project1-build.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683624170984/a9124924-2bf2-4457-aeb0-a43d51b85e14.png" alt class="image--center mx-auto" /></p>
<p><strong>Click on the "Run" button to visualize the jobs below.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683624498730/7235ceb9-19d6-4188-a7c5-f8eb9d2edd8d.png" alt class="image--center mx-auto" /></p>
<p><strong>The "Project1-build" job pulls the code from SCM and creates or generates a build and once the bill is generated then it will be triggered to the 2nd build job i.e. "Project1-test-deploy".</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683624551323/a8a843c2-1d23-4a40-8506-1a4f3eef5067.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683624557278/457233b5-f5e1-4df3-a429-80fd7a1e35d9.png" alt class="image--center mx-auto" /></p>
<p><strong>Now here you can see the first job is done and then 2nd job will be triggered automatically.</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683625095719/f8ffc1b4-489a-4f5b-a872-671b621a571b.png" alt class="image--center mx-auto" /></p>
<p>The Build Pipeline plugin allows you to create a graphical representation of your pipeline and easily track the progress of each stage. You can also add manual approval steps and integrate with other Jenkins plugins to enhance the functionality of your pipeline.</p>
<p><strong>That's it, we created a simple CICD pipeline.</strong></p>
<p>Thanks,</p>
<p>Anil Kushwaha</p>
]]></content:encoded></item><item><title><![CDATA["How to install and configure Prometheus, Node Exporter and Grafana for server metric monitoring".]]></title><description><![CDATA[Prometheus is an open-source monitoring and alerting toolkit, originally built at SoundCloud. It is designed for collecting, storing, and querying…]]></description><link>https://devops7.hashnode.dev/how-to-install-and-configure-prometheus-node-exporter-and-grafana-for-server-metric-monitoring</link><guid isPermaLink="true">https://devops7.hashnode.dev/how-to-install-and-configure-prometheus-node-exporter-and-grafana-for-server-metric-monitoring</guid><category><![CDATA["Learn how to effectively monitor server metrics with Prometheus, Node Exporter, and Grafana by following our step-by-step guide on installation and configuration. #servermetrics #monitoring #Prometheus #Grafana"]]></category><category><![CDATA["How to install and configure Prometheus, Node Exporter and Grafana for server metric monitoring".]]></category><dc:creator><![CDATA[Anil Kushwaha]]></dc:creator><pubDate>Thu, 20 Apr 2023 12:03:25 GMT</pubDate><content:encoded><![CDATA[<h3 id="heading-definitions"><strong>Definitions:</strong></h3>
<ul>
<li><p>Prometheus is an open-source monitoring and alerting toolkit, originally built at SoundCloud. It is designed for collecting, storing, and querying time-series data.</p>
</li>
<li><p>Grafana is an open-source data visualization and monitoring platform. It allows you to create dashboards and panels to display your Prometheus metrics and other data sources.</p>
</li>
</ul>
<h3 id="heading-use-cases"><strong>Use Cases:</strong></h3>
<ul>
<li><p>Prometheus can be used to monitor various types of systems, including servers, databases, and applications. It can help you detect and diagnose issues before they become critical.</p>
</li>
<li><p>Grafana can be used to visualize and explore your Prometheus metrics. You can create dashboards and panels to display data in real-time, track trends over time, and set up alerts based on specific thresholds or conditions.</p>
</li>
</ul>
<h3 id="heading-workflow"><strong>Workflow:</strong></h3>
<ol>
<li><p>Prometheus scrapes data from targets (servers, applications, databases, etc.) using various collectors.</p>
</li>
<li><p>The scraped data is stored in a time-series database.</p>
</li>
<li><p>Grafana connects to the Prometheus data source and allows you to create dashboards and panels to display your metrics.</p>
</li>
<li><p>You can use Grafana to set up alerts based on specific thresholds or conditions.</p>
</li>
<li><p>When an alert is triggered, you can use Grafana to investigate the issue further and take corrective actions as needed.</p>
</li>
</ol>
<p>Overall, Prometheus and Grafana are powerful tools for monitoring and visualizing your systems' performance. They can help you identify and troubleshoot issues quickly, leading to improved reliability and performance.</p>
<h3 id="heading-for-beginner-guide"><strong>For beginner guide.</strong></h3>
<ol>
<li><p>Installation of Prometheus.</p>
<p> -Prometheus public IP: 13.213.57.83</p>
</li>
<li><p>How to create and Install Node exporter.</p>
<p> -Node exporter public: 13.213.57.83</p>
<p> -Node exporter public: 13.213.37.30 (Remote machine)</p>
</li>
<li><p>Installing the Grafana.</p>
<p> -Grafana dashboard public IP: 13.213.57.83</p>
</li>
<li><p>Setting up the Grafana Dashboard.</p>
</li>
<li><p>Setting up Prometheus and Grafana for Kubernetes on AWS (Advance Use-Case)</p>
</li>
<li><p>Advantages of Prometheus</p>
</li>
<li><p>Advantages of Grafana</p>
</li>
<li><p>Conclusion</p>
</li>
</ol>
<h3 id="heading-1-installation-of-prometheus"><strong>1. Installation of Prometheus.</strong></h3>
<ul>
<li><p>Goto <a target="_blank" href="https://prometheus.io/download/">https://prometheus.io/download/</a> and select the <code>prometheus-x.xx.x.linux-amd64.tar.gz</code> file for download. <strong><em>(Note- Here x.xx.x is version number)</em></strong></p>
</li>
<li><p>Extract the download binary file. <strong><em>(Note- Replace x.xx.x with the downloaded version of Prometheus)</em></strong></p>
</li>
<li><p><code>root@prometheus:~# mkdir prometheus</code></p>
</li>
<li><p><code>root@prometheus:~# cd prometheus</code></p>
</li>
<li><p><code>root@prometheus:~/prometheus# wget</code> <a target="_blank" href="https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz"><code>https://github.com/prometheus/prometheus/releases/download/v2.43.0/prometheus-2.43.0.linux-amd64.tar.gz</code></a></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681973475432/f71f44b7-673b-4e8e-8b58-4d3d79278796.png" alt class="image--center mx-auto" /></p>
<p><code>root@prometheus:~/prometheus# tar -xvf prometheus-2.43.0.linux-amd64.tar.gz</code></p>
<p><code>root@prometheus:~/prometheus# cd prometheus-2.43.0.linux-amd64/</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681973620237/2a1535b0-3da7-4c74-988d-c7511574efff.png" alt class="image--center mx-auto" /></p>
<p>Start the prometheus server with the command and by default prometheus port is 9090.</p>
<p><code>#./prometheus</code></p>
<p>The above command has our Prometheus server up and running.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681974622773/e61c7982-fa69-49c0-ae36-0de36db821c5.png" alt class="image--center mx-auto" /></p>
<ul>
<li><p>The Prometheus server should start on port <code>9090.</code></p>
</li>
<li><p>You can access the Prometheus graph UI by visint <a target="_blank" href="http://localhost:9090/graph"><code>http://PublicIP.com:9090/graph</code></a></p>
</li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681973963180/beeacf2f-6bd3-4b68-8b32-b31b269f1212.png" alt class="image--center mx-auto" /></p>
<ul>
<li>You can access the Prometheus metrics UI by visint <a target="_blank" href="http://localhost:9090/metrics"><code>http://PublicIP.com:9090/metrics</code></a></li>
</ul>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681974054540/99a5a0d7-bed2-4f9e-b858-0f93b4b8e0e6.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-2-how-to-create-and-install-node-exporter"><strong>2. How to create and Install Node exporter.</strong></h3>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681974369435/07fe3be7-7035-400f-b039-e6d4d1cd7c3d.png" alt class="image--center mx-auto" /></p>
<p>Node exporter is responsible for fetching the statistics from various hardware and virtual resources in the format which Prometheus can understand and with the help of the prometheus server those statistics can be exposed on port <strong>9100</strong>.</p>
<h3 id="heading-21-how-to-install-node-exporter"><strong>2.1</strong> How to Install Node exporter.</h3>
<p>After installing the Prometheus in the previous step the next package we are going to install is <a target="_blank" href="https://github.com/prometheus/node_exporter"><strong>Node Exporter</strong></a> in remote machine. Node exported is used for collecting various hardware and kernel-level metrics of your machine.</p>
<p><strong>Here are the download and installation steps to remote machine -</strong></p>
<ol>
<li>Download the binary of <a target="_blank" href="https://prometheus.io/download/#node_exporter">Node exporter</a> based on the operating system.<strong><em>(In my case I am using Ubuntu linux machine of prometheus server.)</em></strong></li>
</ol>
<p><code>#mkdir nodeexporter</code></p>
<p><code>#cd nodeexporter</code></p>
<p><code>#wget</code> <a target="_blank" href="https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz"><code>https://github.com/prometheus/node_exporter/releases/download/v1.5.0/node_exporter-1.5.0.linux-amd64.tar.gz</code></a></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681975380039/3da1af9d-cdc2-46f9-9da1-fd0b73cf00a2.png" alt class="image--center mx-auto" /></p>
<p><code>#tar -xvf node_exporter-1.5.0.linux-amd64.tar.gz</code></p>
<p><code>#cd node_exporter-1.5.0.linux-amd64</code></p>
<p><code>#./node_exporter</code></p>
<p><code>#cp -r node_exporter /usr/local/bin/</code></p>
<p><strong>Create a node_exporter service file in the /etc/systemd/system directory.</strong></p>
<p><code>#vim /etc/systemd/system/node_exporter.service</code></p>
<p>Paste the below content in your service file.</p>
<p><code>[Unit]</code></p>
<p><code>Description=Node Exporter</code></p>
<p><code>[Service]</code></p>
<p><code>User=root</code></p>
<p><code>Group=root</code></p>
<p><code>Type=simple</code></p>
<p><code>ExecStart=/usr/local/bin/node_exporter --web.listen-address=:9090</code></p>
<p><code>[Install]</code></p>
<p><code>WantedBy=multi-user.target</code></p>
<p>Set User permission and ownership for the node_exporter service file.</p>
<p><code>#chown -R root:root /etc/systemd/system/node_exporter.service 15</code></p>
<p><code>#chmod -R 644 /etc/systemd/system/node_exporter.service</code></p>
<p>Now let's start and enable the node_exporter service using the below commands </p>
<p><code># sudo systemctl daemon-reload</code></p>
<p><code># sudo systemctl start node_exporter</code></p>
<p><code># sudo systemctl enable node_exporter</code></p>
<p><code>#sudo systemctl status node_exporter</code></p>
<p>Let's Check the Status of Node Exporter:</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682578560670/c92c6ebb-a79a-482c-9157-3105780d18db.png" alt class="image--center mx-auto" /></p>
<p>Node exporter is started and running by executing the above command and now it will collect metrics from the installation machine and push to the Prometheus server.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681975478753/27e9d0ee-b3a7-4113-b92c-d6533f2dc44d.png" alt class="image--center mx-auto" /></p>
<ol>
<li>URL - <a target="_blank" href="http://publicIP:9100"><code>http://publicIP:9100</code></a> and accesses node exporter metrics on a browser using port 9100 by default.</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681976066644/753595ad-ed4d-47b2-b890-d1d9154efe0b.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681976520729/ed561240-1e2e-45eb-a49e-89b85efa8a49.png" alt class="image--center mx-auto" /></p>
<h3 id="heading-22-adding-node-exporter-scrapconfigs-to-prometheus-as-a-yaml-configuration"><strong>2.2</strong> Adding node exporter scrap_configs to prometheus as a YAML Configuration.</h3>
<p>In the previous node export installation, we had Prometheus and node exporter running on the same server. But if you want to add <strong><em>node exporter</em></strong> for any remote server then you need to define <code>scrap_configs</code> with <code>target</code> hosts inside the YAML configuration.</p>
<p><strong>Here is an example of</strong> <code>scrap_configs</code> -</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681976635604/4524e4fe-7119-4dfe-92ea-e3b2a9b49553.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681976691196/4372af9d-c538-4e29-b39d-3aeac2eaa6bb.png" alt class="image--center mx-auto" /></p>
<p><strong><em>(\</em>Note - In the below configuration you have replaced IP address 13.213.57.83 with your host IP or Hostname)*</strong></p>
<p><code>global:</code></p>
<p><code>scrape_interval: 15s</code></p>
<p><code>scrape_configs:</code></p>
<p><code>- job_name: node</code></p>
<p><code>static_configs:</code></p>
<p><code>- targets: ['</code><a target="_blank" href="http://localhost:9100"><code>localhost:9100</code></a><code>','IP:9100']</code></p>
<p>For the above, we go to Prometheus server and press ctrl+c and clear the screen.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681976915518/bac73e6e-6e10-4b82-beb1-61a561cc9189.png" alt class="image--center mx-auto" /></p>
<ol>
<li><p>As you can see I have added two hosts <a target="_blank" href="http://localhost"><code>localhost</code></a><code>, 13.213.57.83</code> inside the <strong><em>scrap_config</em></strong>.</p>
</li>
<li><p>Save the above configuration as <code>YAML</code><strong><em>(ex. exporter-config.yaml)</em></strong></p>
</li>
<li><p>Start the Prometheus server bypassing <code>scrap_config</code> with the help of <code>--config.file</code> flag.</p>
</li>
</ol>
<p><strong>Example -</strong></p>
<p>#./prometheus --config.file=exporter-config.yml</p>
<p><code>#touch exporter-config.yml</code></p>
<p><code>#ls -larth</code></p>
<p>Here, it's needed to add remote machine IP with port 9100.</p>
<p><code>#vi exporter-config.yml</code></p>
<p><code>root@prometheus:~/prometheus/prometheus-2.43.0.linux-amd64# cat exporter-config.yml</code></p>
<p><code>global:</code></p>
<p><code>scrape_interval: 15s</code></p>
<p><code>scrape_configs:</code></p>
<p><code>- job_name: node</code></p>
<p><code>static_configs:</code></p>
<p><code>- targets: ['</code><a target="_blank" href="http://localhost:9100"><code>localhost:9100</code></a><code>','13.213.57.83:9100']</code></p>
<p>root@prometheus:~/prometheus/prometheus-2.43.0.linux-amd64#</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681977809035/d1d7d905-4e41-46f9-a0cc-7576b1104e44.png" alt class="image--center mx-auto" /></p>
<p><code>#./prometheus --config.file=exporter-config.yml</code></p>
<p>It will execute the below syntax to create an exporter config file in Prometheus server.</p>
<p><strong>Verify the Host status-</strong></p>
<p>After adding the remote host into the node exporter configuration verify it by accessing the Prometheus target URL <a target="_blank" href="http://localhost:9090/targets"><code>13.213.57.83:9090/targets</code></a></p>
<p><code>http://13.213.57.83:9090/</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681978172670/e2e36851-5b05-48a3-bf60-52b337e6258b.png" alt class="image--center mx-auto" /></p>
<p>Next, we need to log in Prometheus server and add remote machine IP in the target field.</p>
<p><code>#pwd</code></p>
<p><code>/prometheus/prometheus-2.43.0.linux-amd64</code></p>
<p><code># ls</code></p>
<p><code>LICENSE NOTICE console_libraries consoles data exporter-config.yml prometheus prometheus.yml prometheus.yml-backup promtool</code></p>
<h2 id="heading-configure-the-node-exporter-as-a-prometheus-target"><strong>Configure the Node Exporter as a Prometheus target.</strong></h2>
<p>Go to the end of the prometheus.yml file and add this entry at the bottom of the line and then restart the Prometheus server.</p>
<p><code>#vim prometheus.yml</code></p>
<p><code>static_configs:</code></p>
<p><code>- targets: ["Remote_machine_IP:9090"]</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682580725102/77ae3dec-ee22-437d-aba7-a2f8cdd48908.png" alt class="image--center mx-auto" /></p>
<p>After changing in the config file you need to restart to Prometheus</p>
<p>Now restart the Prometheus Service</p>
<p><code>#sudo systemctl restart prometheus</code></p>
<p>or</p>
<p><code>#./prometheus --config.file=exporter-config.yml</code></p>
<h2 id="heading-logged-in-to-remote-machine-to-install-node-exporter">Logged in to Remote machine to install node exporter:-</h2>
<p>To install the node exporter on the remote machine will use the number of the above-mentioned steps <strong>"2.1 How to Install Node exporter".</strong></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681979254423/d4c56708-bbca-406e-90da-2270547c8c70.png" alt class="image--center mx-auto" /></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681979289950/cfeb6cf9-dfdc-4d14-b949-617def52de1e.png" alt class="image--center mx-auto" /></p>
<p><code>http://13.213.37.30:9100/metrics</code></p>
<p>Node exporter is installed &amp; configured on the remote machine now and able to see its metrics.</p>
<p>Next, we'll go to the Prometheus server (13.213.57.83) and press ctrl+C to stop the Prometheus server and to collect remote machine metrics add our remote machine public IP (13.213.37.30) in <strong>exporter-config.yml</strong> file.</p>
<p>Logged in to Prometheus server:-</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681982849705/6c55689c-7c57-4606-b6ca-412f30980aca.png" alt class="image--center mx-auto" /></p>
<p>Prometheus using the syntax, restart the server and on Prometheus login and check that all instances are collecting metrics from the UP server.</p>
<p><code>#./prometheus --config.file=exporter-config.yml</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681980227292/5c6b4153-6746-4e90-bf35-4dfaba8558a4.png" alt class="image--center mx-auto" /></p>
<p><code>http://13.213.57.83:9090/targets?search=&amp;scrapePool=node</code></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681983062306/b4d0a5da-2834-4b13-a3dd-8e037d3b49a9.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-23-enable-and-disable-the-collector">2.3 Enable and disable the collector</h2>
<p>If you have more than one collector configured then <strong><em>node_exporter</em></strong> allows you to enable and disable some of the collectors with run time arguments -</p>
<div class="hn-table">
<table>
<thead>
<tr>
<td><strong>Flag</strong></td><td><strong>Description</strong></td></tr>
</thead>
<tbody>
<tr>
<td><strong>- - collector.ENTER-THE-NAME-OF-COLLECTOR</strong></td><td>Enable collector</td></tr>
<tr>
<td><strong>- - no-collector.ENTER-THE-NAME-OF-COLLECTOR</strong></td><td>Disable collector</td></tr>
</tbody>
</table>
</div><p>Here is an example command for starting the node_exporter with disable flag -</p>
<p><code>#node_exporter --no-collector.ENTER-THE-NAME-OF-COLLECTOR</code></p>
<p>For enabling the collector use the following command -</p>
<p><code>#node_exporter --collector.ENTER-THE-NAME-OF-COLLECTOR</code></p>
<p>Now we will install and configure the same steps for node exporter in our another new remote machine to collect data from remote machine (13.213.37.30) and push data to prometheus server.</p>
<h3 id="heading-3-installing-the-grafana"><strong>3.</strong> Installing the Grafana</h3>
<p>After installing the Prometheus server and node exporter let's install the <strong>Grafana</strong> for setting up visualization using Grafana dashboard. Here is the <a target="_blank" href="https://grafana.com/docs/grafana/latest/installation/">official download link of Grafana</a> <a target="_blank" href="https://grafana.com/docs/grafana/latest/setup-grafana/installation/">https://grafana.com/docs/grafana/latest/setup-grafana/installation/</a>, choose the correct Grafana binary based on your operating system. For this blog post, I am going to use ubuntu Linux binary.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681987273999/28038537-7faf-4929-aadc-6d9960256b2a.png" alt class="image--center mx-auto" /></p>
<p><strong>Steps for Installing Grafana-</strong></p>
<p>In this installation, we are going to install the latest enterprise edition Grafana on the same prometheus server.</p>
<ol>
<li><p>Update the package info -</p>
<p> <code>#sudo apt-get install -y apt-transport-https</code></p>
<p> <code>#sudo apt-get install -y software-properties-common wget</code></p>
<p> <code>#wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -</code></p>
</li>
</ol>
<p>Add stable repository of Grafana -</p>
<ol>
<li><p><code>#echo "deb</code> <a target="_blank" href="https://packages.grafana.com/enterprise/deb"><code>https://packages.grafana.com/enterprise/deb</code></a> <code>stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list</code></p>
</li>
<li><p>Update repository and Install Grafana</p>
<p> <code>#sudo apt-get update</code></p>
<p> <code>#sudo apt-get install grafana-enterprise</code></p>
</li>
<li><p>Start the <code>Grafana Server</code> -</p>
<p> <code>#sudo systemctl daemon-reload</code></p>
<p> <code>#sudo systemctl start grafana-server</code></p>
<p> <code>#sudo systemctl status grafana-server</code></p>
</li>
<li><p>Configure Grafana to run at boot time-</p>
<p> <code>#sudo systemctl enable grafana-server.service</code></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681987558558/972ed0e1-35d9-486f-9932-88e70a1050ad.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Access the Grafana Dashboard using <code>http://13.213.57.83:3000/login</code></p>
</li>
<li><p>The default login <strong>Username: Password</strong> for accessing the Grafana dashboard is <strong>admin: admin</strong></p>
</li>
<li><p>Change the default admin password after the login.</p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1681987653720/24cecc15-4514-4812-be86-cc749bf6f7d0.png" alt class="image--center mx-auto" /></p>
</li>
</ol>
<h3 id="heading-4-setting-up-the-grafana-dashboard"><strong>4.</strong> Setting up the Grafana Dashboard</h3>
<p>The next step after installing the <strong><em>Grafana Server</em></strong> would be to set up the <strong>Grafana Dashboard</strong>. Till now, we have installed the <strong><em>Prometheus Server, Node Exporter</em></strong> as well as <strong><em>Grafana Server</em></strong> but there is a connection between Prometheus and Grafana.</p>
<h3 id="heading-41-lets-create-a-prometheus-datasource-inside-grafana-dashboard">4.1 Let's create a Prometheus Datasource inside Grafana Dashboard</h3>
<ol>
<li>Goto your Grafana Dashboard and click on <strong><em>Gear(Settings Icon)-&gt;Data Sources</em></strong></li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/grafana-create-datasource.webp" alt /></p>
<p><em>Grafana Dashboard create data source</em></p>
<ol>
<li>Click on <strong><em>Add Data Source</em></strong></li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/create-data-source.webp" alt /></p>
<p><em>Grafana Add Data source</em></p>
<ol>
<li>Select the <strong><em>Prometheus</em></strong> as preferred data source -</li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/prometheus-data-source.webp" alt /></p>
<p><em>Prometheus as preferred data source</em></p>
<ol>
<li>Enter the <code>hostname or IP address</code> of the prometheus server</li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/grafana-prometheus-host-url.webp" alt /></p>
<p><em>Enter the hostname or ip address of prometheus server e.g.</em> <a target="_blank" href="http://localhost:9090"><em>http://localhost:9090</em></a></p>
<ol>
<li>Save and test data source</li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/grafana-save-test-datasource.webp" alt /></p>
<p><em>Save and test prometheus datasource</em></p>
<h4 id="heading-42-import-grafana-dashboard-from-grafana-labs">4.2 Import Grafana Dashboard from Grafana Labs</h4>
<p>Now after settings the data source we can import pre-existing opensource dashboard from <a target="_blank" href="https://grafana.com/grafana/dashboards/">Grafana Labs</a> using the Dashboard ID.</p>
<ol>
<li>Goto <a target="_blank" href="https://grafana.com/grafana/dashboards/">Grafana Dashboard</a>(<a target="_blank" href="https://grafana.com/grafana/dashboards/">https://grafana.com/grafana/dashboards/</a>)and search for Node Exporter Full</li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682069803226/d0c30225-3daa-43e8-b610-5abce744bf0a.png" alt class="image--center mx-auto" /></p>
<p><em>Grafana lab dashboard 1860</em> Node Exporter Full</p>
<ol>
<li>Click on the result and then copy the board ID .e.g <strong>1860 or 9894.</strong></li>
</ol>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682069876144/932169a2-4b29-4c26-ade4-8842cb542264.png" alt class="image--center mx-auto" /></p>
<p>Or.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682581615624/c20f3741-748b-4343-bb6f-a143269503da.png" alt class="image--center mx-auto" /></p>
<p><em>Grafana lab dashboard 1860</em> Node Exporter Full</p>
<ol>
<li>Goto <strong>Import</strong> and enter the board ID .e.g. <strong>1860</strong></li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/grafana-dashboard-import.webp" alt /></p>
<p><em>Grafana dashboard import</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682069999482/99be0c4e-9912-4aa2-8660-fb6ddfeff8b5.png" alt class="image--center mx-auto" /></p>
<p><em>Import Grafana dashboard with dashboard id 1860.</em></p>
<ol>
<li>Click load and then select the data source as <strong><em>Prometheus</em></strong></li>
</ol>
<p><img src="https://jhooq.com/wp-content/uploads/aws/prometheus-grafan-installation/select-prometheus-datasource.webp" alt /></p>
<p><em>Select prometheus as preferred datasource</em></p>
<ol>
<li><p>Finally Click on Import</p>
</li>
<li><p>You should be able to see the memory dashboard</p>
<p> <code>http://13.213.57.83:3000</code></p>
</li>
</ol>
<p><em>Grafana dashboard</em></p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1682070054905/e4b895df-ddc5-4f49-83da-225ad74098cc.png" alt class="image--center mx-auto" /></p>
<h2 id="heading-5-advantages-of-prometheus">5. Advantages of Prometheus</h2>
<p>Now I have talked about how to install and use Prometheus along with Grafana, let's see what are the advantages of using Prometheus in the landscape of DevOps and SREs -</p>
<ol>
<li><p>Prometheus is a very independent framework that does not impact your existing cloud or in-premise infrastructure.</p>
</li>
<li><p>It can be customized to suit your infrastructure needs</p>
</li>
<li><p>To use Prometheus and Node exporter a developer does not have to install all the node exporters available in the market. A Developer can only install the required node exporter and to avoid extra overhead on the hardware resources</p>
</li>
<li><p>Prometheus node exporter can be customized to suit your infrastructure need, if you do not find a suitable node exporter in the library then Prometheus allows you to build a custom node exporter.</p>
</li>
<li><p>Prometheus comes along with <strong>PromQL</strong> and <strong>TSDB</strong> which make it a more powerful tool for debugging troubleshooting.</p>
</li>
<li><p>Prometheus has a built in database and you do not have to install the database separately.</p>
</li>
<li><p>The pull mechanism of Prometheus is very flexible, and it allows you to schedule variable scrappers at different intervals.</p>
</li>
<li><p>Also, Prometheus is being open-source, it has a wide variety of community support available for developers.</p>
</li>
</ol>
<h2 id="heading-6-advantages-of-grafana">6. Advantages of Grafana</h2>
<ol>
<li><p>If you compare <strong>Grafana</strong> with traditional tools <strong>Zabbix and LibreNMS</strong> then Grafana allows you to create multiple datasource whereas Zabbix and LibreNMS allow you only to create a single Datasource.</p>
</li>
<li><p>In the Grafana dashboard you can customize various panels based on your requirement, also you can have integration with multiple data sources in the same Dashboard which is by far the biggest merit of using Grafana.</p>
</li>
<li><p>In Grafana open-source community you can share your dashboard settings with others, and similarly, you can use other's dashboards by searching it on <a target="_blank" href="https://grafana.com/grafana/dashboards/">Grafana Community</a>, so you do not have to re-invent the wheel again.</p>
</li>
<li><p>Grafana dashboard's user experience is very pleasing and also it allows a developer to put PNG images on the dashboard to make it more appealing.</p>
</li>
<li><p>Grafana developer community is building a lot of features and various datasource support which makes Grafana more adaptable for various infrastructure monitoring needs.</p>
</li>
</ol>
<h2 id="heading-7-conclusion">7. Conclusion</h2>
<p>No doubt Grafana and Prometheus are a really popular frameworks for monitoring, alerting, and data visualization although there is a bit of learning because Prometheus has custom query language <strong>PromQL</strong> which requires little of practice before you call yourself an expert in the <strong>PromQL</strong>.</p>
<p>But when you look from DevOps and SREs end you would always like to have Prometheus and Grafana in your arsenal because of various third-party Node exporters, setting up various data sources, customizable dashboards, and panels. I hope this beginners guide will help you to get you started with Prometheus, Grafana, and Node exporter setup, and if you are interested in some advance setup of Prometheus and Grafana then I would recommend this guide on - <a target="_blank" href="https://jhooq.com/prometheous-k8s-aws-setup">How to setup Prometheus, Grafana dashboard for Kubernetes monitoring on AWS</a></p>
<p>All done.</p>
<p>Thanks,</p>
<p>Anil Kushwaha</p>
]]></content:encoded></item><item><title><![CDATA[How to install Jenkins on Ubuntu 22.04 LTS in AWS ec2 instance.]]></title><description><![CDATA[Here are the steps to install Jenkins on Ubuntu machine: Install Java: Jenkins is a Java-based application, so you need to install Java on your Ubuntu…]]></description><link>https://devops7.hashnode.dev/how-to-install-jenkins-on-ubuntu-2204-lts-in-aws-ec2-instance</link><guid isPermaLink="true">https://devops7.hashnode.dev/how-to-install-jenkins-on-ubuntu-2204-lts-in-aws-ec2-instance</guid><category><![CDATA[ Jenkins, DevOps]]></category><dc:creator><![CDATA[Anil Kushwaha]]></dc:creator><pubDate>Mon, 27 Feb 2023 15:28:08 GMT</pubDate><content:encoded><![CDATA[<p>Here are the steps to install Jenkins on Ubuntu machine:</p>
<ol>
<li><p>Install Java: Jenkins is a Java-based application, so you need to install Java on your Ubuntu system. You can install Java using the following command:</p>
<p> <code>#sudo apt update</code></p>
<p> <code>#sudo apt install openjdk-11-jre</code></p>
<p> <code>#sudo java -version</code></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683048441741/0f1abfbe-7f40-47f2-b0f5-82c90d32b9e0.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Install Jenkins: You can install Jenkins using the following commands:</p>
<p> This is the Debian package repository of Jenkins to automate installation and upgrade. To use this repository, first add the key to your system:</p>
<p> <code>#curl -fsSL</code> <a target="_blank" href="https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key"><code>https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key</code></a> <code>| sudo tee \   /usr/share/keyrings/jenkins-keyring.asc &gt; /dev/null</code></p>
<p> <code>#echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \</code></p>
<p> <a target="_blank" href="https://pkg.jenkins.io/debian-stable"><code>https://pkg.jenkins.io/debian-stable</code></a> <code>binary/ | sudo tee \</code></p>
<p> <code>/etc/apt/sources.list.d/jenkins.list &gt; /dev/null</code></p>
<p> <code>#sudo apt-get update</code></p>
<p> <code>#sudo apt-get install jenkins</code></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1683048804845/a84d8705-6b8f-4e72-afdb-107936a04e67.png" alt class="image--center mx-auto" /></p>
<p> <code>#sudo systemctl enable jenkins --now</code></p>
<p> <code>#sudo systemctl status jenkins</code></p>
</li>
<li><p>Access Jenkins: Jenkins runs on port 8080 by default, so you can access it using your server's IP address and port 8080, before accessing, 8080 port needs to allow in AWS Inbound rule of a security group. (e.g. <a target="_blank" href="http://your-server-ip-address:8080/">http://your-server-ip-address:8080/</a>). You will be prompted to enter an initial admin password which can be found in the file /var/lib/jenkins/secrets/initialAdminPassword.</p>
<p> <a target="_blank" href="http://52.77.221.18:8080/"><code>http://13.235.81.85:8080</code></a></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677508547020/8021c6ba-f01e-4523-aeb7-6be263770978.png" alt class="image--center mx-auto" /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677508667351/140f5a77-add7-4278-aab1-768b966dfbff.png" alt class="image--center mx-auto" /></p>
</li>
<li><p>Install Plugins: After logging in to Jenkins, you need to install the required plugins. You can install plugins by clicking on "Manage Jenkins" &gt; "Manage Plugins" &gt; "Available" and then searching for and selecting the desired plugins.</p>
<p> <strong>Follow the screenshots on the setup page to complete the installation and set up your Jenkins instance.</strong></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677509623183/0c28f6fb-288a-4785-aa97-7b3c890a2723.png" alt class="image--center mx-auto" /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677509692553/09efc5cf-c443-4725-a031-7c5676b403e1.png" alt class="image--center mx-auto" /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677509723443/21563dfd-88b5-48f8-875c-e716d26c1555.png" alt class="image--center mx-auto" /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677509740545/026fc0c1-903f-4510-8673-638b6c1069c3.png" alt class="image--center mx-auto" /></p>
<p> <img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1677509758170/d4994eef-398a-41f7-bf71-4e7d7569911c.png" alt class="image--center mx-auto" /></p>
<h1 id="heading-or">Or</h1>
<p> You can download the latest version of Jenkins from the official website (<a target="_blank" href="https://www.jenkins.io/download/">https://www.jenkins.io/download/</a>) and follow the installation instructions.</p>
<p> That's it! You have successfully installed Jenkins on your AWS Ubuntu instance.</p>
</li>
</ol>
]]></content:encoded></item></channel></rss>