<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Md Asraful Haque (Sohel)</title>
    <description>The latest articles on DEV Community by Md Asraful Haque (Sohel) (@asraful_haque).</description>
    <link>https://dev.to/asraful_haque</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1947470%2Fce6f88cc-7594-4fd8-b29f-72e46da9f707.jpg</url>
      <title>DEV Community: Md Asraful Haque (Sohel)</title>
      <link>https://dev.to/asraful_haque</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/asraful_haque"/>
    <language>en</language>
    <item>
      <title>Prometric-Go Part 2 — Full Hands-On Demo with Grafana, Prometheus &amp; k6 📈</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Tue, 18 Nov 2025 04:19:43 +0000</pubDate>
      <link>https://dev.to/asraful_haque/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-216k</link>
      <guid>https://dev.to/asraful_haque/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-216k</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is &lt;strong&gt;Part 2&lt;/strong&gt; of my Prometric-Go series.&lt;br&gt;&lt;br&gt;
If you haven't read Part 1 yet — the introduction to the library — you can check it out here:&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://dev.to/asraful_haque/simplifying-prometheus-metrics-in-go-with-prometric-go-22ef"&gt;https://dev.to/asraful_haque/simplifying-prometheus-metrics-in-go-with-prometric-go-22ef&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  👋 What we’re building in Part 2
&lt;/h2&gt;

&lt;p&gt;In this article we will &lt;strong&gt;instrument a real Go API using &lt;code&gt;prometric-go&lt;/code&gt;&lt;/strong&gt;, collect metrics in &lt;strong&gt;Prometheus&lt;/strong&gt;, and visualize everything in &lt;strong&gt;Grafana&lt;/strong&gt; — including a load-test using &lt;strong&gt;k6&lt;/strong&gt; to generate traffic.&lt;/p&gt;

&lt;p&gt;To make this super easy, I created a ready-to-run sample project:&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;GitHub Repo:&lt;/strong&gt; &lt;a href="https://github.com/peek8/prometric-go-sample" rel="noopener noreferrer"&gt;https://github.com/peek8/prometric-go-sample&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This repository contains:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;th&gt;Tool&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Metric instrumentation&lt;/td&gt;
&lt;td&gt;&lt;a href="https://github.com/peek8/prometric-go" rel="noopener noreferrer"&gt;&lt;code&gt;prometric-go&lt;/code&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Metrics storage&lt;/td&gt;
&lt;td&gt;Prometheus&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Metrics visualization&lt;/td&gt;
&lt;td&gt;Grafana&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Web API&lt;/td&gt;
&lt;td&gt;Go + net/http&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Traffic Generation&lt;/td&gt;
&lt;td&gt;&lt;a href="https://k6.io/" rel="noopener noreferrer"&gt;Grafan k6&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;k6 hits the API → API exposes metrics via &lt;code&gt;/metrics&lt;/code&gt; → Prometheus scrapes → Grafana visualizes.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ Clone &amp;amp; Run the Sample
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone https://github.com/peek8/prometric-go-sample
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;prometric-go-sample
&lt;span class="nv"&gt;$ &lt;/span&gt;make run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will run the api server at port &lt;code&gt;7080&lt;/code&gt;. You can explore the prometheus metrics exposed by  &lt;a href="https://github.com/peek8/prometric-go" rel="noopener noreferrer"&gt;&lt;code&gt;prometric-go&lt;/code&gt;&lt;/a&gt; library at url:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://localhost:7080/metrics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See the full metrics list exposed at &lt;a href="https://github.com/peek8/prometric-go?tab=readme-ov-file#-features" rel="noopener noreferrer"&gt;prometric-go library readme&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The K6 Script
&lt;/h2&gt;

&lt;p&gt;I use &lt;a href="https://k6.io/" rel="noopener noreferrer"&gt;Grafan k6&lt;/a&gt; to generate traffic against the prometric API. This &lt;a href="https://github.com/peek8/prometric-go-sample/blob/main/scripts/k6-scripts.js" rel="noopener noreferrer"&gt;k6-scripts&lt;/a&gt; demonstrates a simple scenario that exercises the CRUD endpoints for Person objects.&lt;/p&gt;

&lt;h3&gt;
  
  
  What the script does
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Creates some 50K Objects (ie Person) in ~20 mins (50000 iterations shared among 50 VUs, maxDuration: 10m).&lt;/li&gt;
&lt;li&gt;Tries to get Person by Random Id for 10 mins (20.00 iterations/s for 10m0s, maxVUs: 10).&lt;/li&gt;
&lt;li&gt;Tries to get Person list  for 10 mins (10.00 iterations/s for 10m0s, maxVUs: 5).&lt;/li&gt;
&lt;li&gt;Updates the Person for 10 mins (5.00 iterations/s for 2m0s, maxVUs: 5).&lt;/li&gt;
&lt;li&gt;Deletes about 1500 Persons randomly within 10 mins (1500 iterations shared among 2 VUs,maxDuration: 10m0s).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These above iterations are enough to generate some adequate prometheus metrics which can be used to play with prometheus and grafana dashboard.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run k6
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Install &lt;a href="https://k6.io/" rel="noopener noreferrer"&gt;Grafan k6&lt;/a&gt; at your local machine and run the k6-scripts from the repo:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;k6 run ./scripts/k6-scripts.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now if you hit the metric endpoint, you will see different metric values keep changing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prometheus and Grafana
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Run Prometheus
&lt;/h3&gt;

&lt;p&gt;Run prometheus using the &lt;a href="//./resources/prometheus.yml"&gt;prometheus.yml file&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; 9090:9090 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-v&lt;/span&gt; ./resources/prometheus.yml:/etc/prometheus/prometheus.yml &lt;span class="se"&gt;\&lt;/span&gt;
    prom/prometheus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;N.B: If you are using podman use &lt;code&gt;host.containers.internal&lt;/code&gt; as targets at prometheus.yml file, ie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;targets: ["host.containers.internal:7080"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run Grafana
&lt;/h3&gt;

&lt;p&gt;Run Grafan using &lt;code&gt;docker&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -d -p 3000:3000 grafana/grafana
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then grafana will be available at &lt;code&gt;http://localhost:3000&lt;/code&gt;, use &lt;code&gt;admin:admin&lt;/code&gt; as to login for the first time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Import the included dashboard
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Create Grafana Data Source&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can create datasource if you don't have any running the shell script: &lt;a href="https://github.com/peek8/prometric-go-sample/blob/main/resources/grafana-datasource.sh" rel="noopener noreferrer"&gt;grafana-datasource.sh&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Import Grafana Dashboard&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Grafana → Dashboards&lt;/li&gt;
&lt;li&gt;Click Import&lt;/li&gt;
&lt;li&gt;Upload &lt;a href="https://github.com/peek8/prometric-go-sample/blob/main/resources/grafana-dashboard.json" rel="noopener noreferrer"&gt;grafana-dashboard.json&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Select Prometheus datasource → prometric-k6 (or the one you use)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Voila, You’ll now see real-time metrics at the dashboard from the sample app:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9oinwy4a1bnavajkbss2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9oinwy4a1bnavajkbss2.gif" alt="Image Grafana Dashboard" width="800" height="576"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 What You Learn From This Sample
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Category&lt;/th&gt;
&lt;th&gt;Benefit&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Go backend&lt;/td&gt;
&lt;td&gt;Clean way to expose metrics&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Prometheus&lt;/td&gt;
&lt;td&gt;Scraping &amp;amp; querying the app&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Grafana&lt;/td&gt;
&lt;td&gt;Dashboarding for API performance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;k6&lt;/td&gt;
&lt;td&gt;Generating programmable load&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Observability&lt;/td&gt;
&lt;td&gt;From raw counters → real visual insights&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h2&gt;
  
  
  🎁 Bonus: You Can Reuse This as a Template
&lt;/h2&gt;

&lt;p&gt;The repo is intentionally simple, so you can fork it and adapt it for your own services.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replace Person CRUD API with your own business logic&lt;/li&gt;
&lt;li&gt;Keep the prometric-go instrumentation + dashboard&lt;/li&gt;
&lt;li&gt;Add additional domain metrics as needed&lt;/li&gt;
&lt;li&gt;Extend k6 tests to simulate real traffic&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🌟 Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Prometheus + Grafana can feel complex when you start from scratch —&lt;br&gt;
but with prometric-go, you get:&lt;/p&gt;

&lt;p&gt;👌 Meaningful metrics by default&lt;br&gt;
📦 Domain-specific metrics with 2–3 lines of code&lt;br&gt;
🚀 Dashboards ready to plug into production&lt;/p&gt;

&lt;p&gt;If you try out the sample, I’d love to hear your feedback!&lt;/p&gt;

&lt;h2&gt;
  
  
  ⭐ If this helped you…
&lt;/h2&gt;

&lt;p&gt;Support the project by giving a ⭐ to both repos:&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://github.com/peek8/prometric-go" rel="noopener noreferrer"&gt;https://github.com/peek8/prometric-go&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🔗 &lt;a href="https://github.com/peek8/prometric-go-sample" rel="noopener noreferrer"&gt;https://github.com/peek8/prometric-go-sample&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And feel free to reach out if you want help adding alerting rules, histograms tuning, Grafana provisioning, or Kubernetes deployment.&lt;/p&gt;

</description>
      <category>go</category>
      <category>prometheus</category>
      <category>grafana</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Prometheus + K6 Fusion: Measure API Performance with Real-Time Metrics in Grafana</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Tue, 11 Nov 2025 06:53:04 +0000</pubDate>
      <link>https://dev.to/asraful_haque/prometheus-k6-fusion-measure-api-performance-with-real-time-metrics-in-grafana-4nl7</link>
      <guid>https://dev.to/asraful_haque/prometheus-k6-fusion-measure-api-performance-with-real-time-metrics-in-grafana-4nl7</guid>
      <description>&lt;h2&gt;
  
  
  🏁 Introduction
&lt;/h2&gt;

&lt;p&gt;When running load tests, we often get numbers like &lt;em&gt;requests per second&lt;/em&gt; or &lt;em&gt;average latency&lt;/em&gt; — but that doesn’t tell us how our system is &lt;em&gt;actually behaving&lt;/em&gt; inside.&lt;/p&gt;

&lt;p&gt;So I wanted to bring &lt;strong&gt;Prometheus observability&lt;/strong&gt; and &lt;strong&gt;K6 performance testing&lt;/strong&gt; together — to visualize live latency, error rate, CPU usage, and throughput in real-time while load tests are running.&lt;/p&gt;

&lt;p&gt;That’s how &lt;strong&gt;&lt;a href="https://github.com/peek8/prometheus-k6-fusion" rel="noopener noreferrer"&gt;Prometheus-K6-Fusion&lt;/a&gt;&lt;/strong&gt; was born — a simple yet powerful open-source stack combining &lt;strong&gt;Go&lt;/strong&gt;, &lt;strong&gt;Prometheus&lt;/strong&gt;, &lt;strong&gt;K6&lt;/strong&gt;, and &lt;strong&gt;Grafana&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚙️ What is Prometheus-K6-Fusion?
&lt;/h2&gt;

&lt;p&gt;prometheus-k6-fusion is a lightweight Go-based API server that provides CRUD operations for sample data objects and exposes Prometheus metrics.&lt;br&gt;
Its a lightweight and easy to start &lt;strong&gt;observability + performance testing lab&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
It includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🟢 &lt;strong&gt;A Go-based API&lt;/strong&gt; instrumented with Prometheus metrics
&lt;/li&gt;
&lt;li&gt;🔵 &lt;strong&gt;K6 load test scripts&lt;/strong&gt; that generate real traffic
&lt;/li&gt;
&lt;li&gt;🟠 &lt;strong&gt;Prometheus&lt;/strong&gt; to scrape the metrics
&lt;/li&gt;
&lt;li&gt;🔴 &lt;strong&gt;Grafana&lt;/strong&gt; dashboard to visualize everything in real-time
&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;In short — it’s a single repo that lets you see how load affects latency, error rate, and resource usage instantly.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h2&gt;
  
  
  Target Audience
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Developers learning Prometheus integration&lt;/strong&gt; in Go.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Teams exploring observability setups&lt;/strong&gt; with Prometheus and Grafana.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;People practicing performance&lt;/strong&gt; testing with k6.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Interview/demo projects&lt;/strong&gt; to showcase system design, metrics, and automation skills.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Why It’s Useful
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Provides a &lt;strong&gt;ready-to-run environment&lt;/strong&gt; for:

&lt;ul&gt;
&lt;li&gt;CRUD REST API (in Go)&lt;/li&gt;
&lt;li&gt;Prometheus metrics exposure&lt;/li&gt;
&lt;li&gt;k6 traffic generation&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Ideal for learning, teaching, or demonstrating:

&lt;ul&gt;
&lt;li&gt;Metrics instrumentation best practices&lt;/li&gt;
&lt;li&gt;Monitoring pipelines&lt;/li&gt;
&lt;li&gt;Performance &amp;amp; load testing workflows&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Components at a glance:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prometric (Go API)&lt;/strong&gt; → exposes Prometheus metrics like &lt;code&gt;http_requests_total&lt;/code&gt;, latency histograms, and memory usage
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;K6&lt;/strong&gt; → generates load (GET, POST, DELETE) to the API
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prometheus&lt;/strong&gt; → scrapes the &lt;code&gt;/metrics&lt;/code&gt; endpoint every few seconds
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Grafana&lt;/strong&gt; → displays dashboards that correlate load, latency, and system behavior&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Prometric
&lt;/h3&gt;

&lt;p&gt;Prometric = Prometheus + Metric&lt;br&gt;
This provides CRUD operations for Person objects. It uses an in-memory database and exposes Prometheus metrics for observability.&lt;/p&gt;
&lt;h4&gt;
  
  
  Features
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;RESTful API for managing Person objects (Create, Read, Update, Delete)&lt;/li&gt;
&lt;li&gt;In-memory storage (no external database required)&lt;/li&gt;
&lt;li&gt;Built-in Prometheus metrics for monitoring&lt;/li&gt;
&lt;li&gt;Runs on port :7080 by default&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  API Endpoints
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Endpoint&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/person/list&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;List all persons&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/persons/{id}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Get a specific person&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;POST&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/person&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Create a new person&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PUT&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/person/{id}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Update an existing person&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DELETE&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/person/{id}&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Delete a person&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;GET&lt;/td&gt;
&lt;td&gt;&lt;code&gt;/metrics&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Prometheus metrics endpoint&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;h3&gt;
  
  
  K6 Script
&lt;/h3&gt;

&lt;p&gt;I use &lt;a href="https://k6.io/" rel="noopener noreferrer"&gt;Grafan k6&lt;/a&gt; to generate traffic against the prometric API. This &lt;a href="https://github.com/peek8/prometheus-k6-fusion/blob/main/scripts/k6-scripts.js" rel="noopener noreferrer"&gt;k6-scripts&lt;/a&gt; demonstrates a simple scenario that exercises the CRUD endpoints for Person objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The script does the following:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates some 50K Objects (ie Person) in ~20 mins (50000 iterations shared among 50 VUs, maxDuration: 10m).&lt;/li&gt;
&lt;li&gt;Tries to get Person by Random Id for 10 mins (20.00 iterations/s for 10m0s, maxVUs: 10).&lt;/li&gt;
&lt;li&gt;Tries to get Person list  for 10 mins (10.00 iterations/s for 10m0s, maxVUs: 5).&lt;/li&gt;
&lt;li&gt;Updates the Person for 10 mins (5.00 iterations/s for 2m0s, maxVUs: 5).&lt;/li&gt;
&lt;li&gt;Deletes about 1500 Persons randomly within 10 mins (1500 iterations shared among 2 VUs,maxDuration: 10m0s).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These above iterations are enough to generate some adequate prometheus metrics which can be used to play with prometheus and grafana dashboard.&lt;/p&gt;


&lt;h2&gt;
  
  
  📈 Metrics Exposed
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Metric&lt;/th&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;http_requests_total&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Counter&lt;/td&gt;
&lt;td&gt;Total HTTP requests processed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;http_requests_in_progress&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gauge&lt;/td&gt;
&lt;td&gt;Active requests being handled&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;http_request_duration_seconds&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Histogram&lt;/td&gt;
&lt;td&gt;Request latency&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;person_store_count&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gauge&lt;/td&gt;
&lt;td&gt;Person records in memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;person_created_total&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Counter&lt;/td&gt;
&lt;td&gt;Successful creations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;person_deleted_total&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Counter&lt;/td&gt;
&lt;td&gt;Deletions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;person_not_found_total&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Counter&lt;/td&gt;
&lt;td&gt;Failed lookups&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;person_payload_size_bytes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Histogram&lt;/td&gt;
&lt;td&gt;POST payload size&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;app_cpu_usage_percent&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gauge&lt;/td&gt;
&lt;td&gt;CPU usage (%)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;app_memory_usage_megabytes&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Gauge&lt;/td&gt;
&lt;td&gt;Memory usage (MB)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These cover both &lt;strong&gt;application-level&lt;/strong&gt; and &lt;strong&gt;system-level&lt;/strong&gt; observability.&lt;/p&gt;


&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Run Locally
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Clone the repo and run the app
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;git clone https://github.com/peek8/prometheus-k6-fusion.git
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;prometheus-k6-fusion
&lt;span class="nv"&gt;$ &lt;/span&gt;go run main.go
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The API server will start on &lt;a href="http://localhost:7080" rel="noopener noreferrer"&gt;http://localhost:7080&lt;/a&gt;. You can use tools like curl or Postman to interact with the endpoints for testing. Access Prometheus metrics at: &lt;code&gt;http://localhost:7080/metrics&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install &lt;a href="https://k6.io/" rel="noopener noreferrer"&gt;Grafan k6&lt;/a&gt; at your local machine and run the k6-scripts from the repo:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;k6 run ./scripts/k6-scripts.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And now if you hit the metric endpoint, you will see different metric values keep changing.&lt;/p&gt;
&lt;h3&gt;
  
  
  Use Docker
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Run the api server first:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="se"&gt;\&lt;/span&gt;
&lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 7080:7080 &lt;span class="se"&gt;\&lt;/span&gt;
ghcr.io/peek8/prometric:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;With this, The API server will start on &lt;a href="http://localhost:7080" rel="noopener noreferrer"&gt;http://localhost:7080&lt;/a&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Run the k6 script with grafana/k6 image:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://host.docker.internal:7080 &lt;span class="se"&gt;\&lt;/span&gt;
  grafana/k6:latest  run  - &amp;lt; ./scripts/k6-scripts.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;if you are using podman, use &lt;code&gt;BASE_URL=http://host.containers.internal:7080&lt;/code&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Prometheus and Grafana
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Run Prometheus
&lt;/h3&gt;

&lt;p&gt;Run prometheus using the &lt;a href="https://github.com/peek8/prometheus-k6-fusion/blob/main/resources/prometheus.yml" rel="noopener noreferrer"&gt;prometheus.yml file&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-p&lt;/span&gt; 9090:9090 &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;-v&lt;/span&gt; ./prometheus.yml:/etc/prometheus/prometheus.yml &lt;span class="se"&gt;\&lt;/span&gt;
    prom/prometheus
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;N.B: If you are using podman use &lt;code&gt;host.containers.internal&lt;/code&gt; as targets at prometheus.yml file, ie:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;targets: ["host.docker.internal:7080"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run Grafana
&lt;/h3&gt;

&lt;p&gt;Run Grafan using &lt;code&gt;docker&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker run -d -p 3000:3000 grafana/grafana
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then grafana will be available at &lt;code&gt;http://localhost:3000&lt;/code&gt;, use &lt;code&gt;admin:admin&lt;/code&gt; as to login for the first time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Grafana Dashboard
&lt;/h3&gt;

&lt;p&gt;You can create a nice grafana dashboard using these metrics using the &lt;a href="https://github.com/peek8/prometheus-k6-fusion/blob/main/resources/grafana-dashboard.json" rel="noopener noreferrer"&gt;ready-to-import Grafana JSON dashboard&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;At this json the Datasource name is &lt;code&gt;prometric-k6&lt;/code&gt;, if you have already a datasource use that in the json file Or you can create it using running the &lt;a href="https://github.com/peek8/prometheus-k6-fusion/blob/main/resources/grafana-datasource.sh" rel="noopener noreferrer"&gt;grafana-datasource.sh&lt;/a&gt; where the credentials used is &lt;code&gt;admin/admin&lt;/code&gt;, Change it to your own user name/password. &lt;/p&gt;

</description>
      <category>devops</category>
      <category>grafana</category>
      <category>prometheus</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Simplifying Prometheus Metrics in Go with prometric-go (Part-1)</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Sun, 09 Nov 2025 04:32:44 +0000</pubDate>
      <link>https://dev.to/asraful_haque/simplifying-prometheus-metrics-in-go-with-prometric-go-22ef</link>
      <guid>https://dev.to/asraful_haque/simplifying-prometheus-metrics-in-go-with-prometric-go-22ef</guid>
      <description>&lt;p&gt;&lt;strong&gt;Effortless observability for your Go applications — without the boilerplate.&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This article is &lt;strong&gt;Part 1&lt;/strong&gt; of my Prometric-Go series.&lt;br&gt;&lt;br&gt;
Please have a look at Part 2 after reading this to see a full example of how this library can be used and create a Grafana Dashboard :&lt;br&gt;&lt;br&gt;
🔗 &lt;a href="https://dev.to/asraful_haque/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-216k"&gt;https://dev.to/asraful_haque/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-216k&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  🧠 The Problem
&lt;/h2&gt;

&lt;p&gt;As Go developers, we all want observability — to know how our APIs perform, how many requests we handle, and how our systems behave in production.&lt;/p&gt;

&lt;p&gt;Prometheus is fantastic for that — but setting up metrics in Go can quickly turn verbose:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;counter := prometheus.NewCounterVec(
    prometheus.CounterOpts{Name: "http_requests_total", Help: "Total HTTP requests"},
    []string{"path", "method", "status"},
)
prometheus.MustRegister(counter)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And soon your code fills with boilerplate.&lt;/p&gt;

&lt;p&gt;That’s why I built &lt;a href="https://github.com/peek8/prometric-go" rel="noopener noreferrer"&gt;prometric-go&lt;/a&gt; — a lightweight, idiomatic helper library that makes exposing Prometheus metrics in Go as simple as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  💡 What is prometric-go?
&lt;/h2&gt;

&lt;p&gt;prometric-go is a minimal Go library that wraps Prometheus client_golang and provides ready-to-use metrics for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌐 HTTP request tracking (latency, size, in-flight)&lt;/li&gt;
&lt;li&gt;⚙️ CRUD operation metrics (total, duration, object count)&lt;/li&gt;
&lt;li&gt;❤️ Application health metrics&lt;/li&gt;
&lt;li&gt;🧱 Helpers for creating and registering custom metrics easily&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s designed to be plug-and-play for HTTP servers and microservices.&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ Installation
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;go get github.com/peek8/prometric-go/prometrics
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then import it in your Go app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import "github.com/peek8/prometric-go/prometrics"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ⚙️ Getting Started
&lt;/h2&gt;

&lt;p&gt;Start by exposing a /metrics endpoint on your existing HTTP server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main
import (
    "net/http"
    "github.com/prometheus/client_golang/prometheus/promhttp"
)
func main() {
    mux := http.NewServeMux()
    mux.Handle("/metrics", promhttp.Handler())

    http.ListenAndServe(":7080", mux)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You now have a fully working Prometheus endpoint at &lt;a href="http://localhost:7080/metrics" rel="noopener noreferrer"&gt;http://localhost:7080/metrics&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 Track HTTP Request Metrics Automatically
&lt;/h2&gt;

&lt;p&gt;You can easily wrap your handlers with Prometheus middleware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;handler := prometrics.InstrumentHttpHandler("/person",http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    w.Write([]byte("Hello, Prometheus!"))
}))

http.Handle("/", handler)
http.ListenAndServe(":7080", nil)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The library automatically tracks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;http_requests_total:  Total HTTP requests processed&lt;/li&gt;
&lt;li&gt;http_request_duration_seconds:    Request duration histogram&lt;/li&gt;
&lt;li&gt;http_requests_in_flight:  Current requests being handled&lt;/li&gt;
&lt;li&gt;http_request_size_bytes:  Request payload size&lt;/li&gt;
&lt;li&gt;http_response_size_bytes: Response size&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http_requests_total{path="/",method="GET",code="200"} 42
http_request_duration_seconds_bucket{le="0.1",path="/",method="GET",code="200"} 12
http_requests_in_flight{path="/"} 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📦 Tracking CRUD Operations
&lt;/h2&gt;

&lt;p&gt;The library also provides metrics for tracking your CRUD operations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Example: create user in DB here
tracker := prometrics.TrackCRUD("user", "create")
defer tracker(time.Now())
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This automatically records:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;crud_operations_total:    Total CRUD operations by object &amp;amp; operation&lt;/li&gt;
&lt;li&gt;object_operation_duration_seconds:    Histogram of CRUD operation durations&lt;/li&gt;
&lt;li&gt;object_count: Current number of objects&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ⚡ Setting Object Counts
&lt;/h2&gt;

&lt;p&gt;You can manually control the current count of entities in your system:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prometrics.SetObjectCount("user", 100)
prometrics.IncObjectCount("user")
prometrics.DecObjectCount("user")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All labeled and tracked automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧠 System Metrics (Optional)
&lt;/h2&gt;

&lt;p&gt;You can also enable lightweight system metric collection in a background goroutine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// collect health metrics in 10s interval
ctx, cancel := context.WithCancel(context.Background(), 10)
go prometrics.CollectSystemMetricsLoop(ctx)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will report CPU and memory usage to Prometheus — useful for understanding resource trends.&lt;/p&gt;

&lt;p&gt;Its also possible to collect these health metrics using Middleware:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mux := http.NewServeMux()

// Use HealthMiddleware at /metrics endpoint
mux.Handle("/metrics", prometrics.HealthMiddleware(promhttp.Handler()))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using GIN Framework
&lt;/h2&gt;

&lt;p&gt;If you are using &lt;a href="https://github.com/gin-gonic/gin" rel="noopener noreferrer"&gt;Gin Web framework&lt;/a&gt; for your api, you can use the gin middlewares from prometrics.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;r := gin.Default()
// For http metrics
r.Use(prometrics.GinMiddleware())
// For health metrics
r.Use(prometrics.GinHealthMiddleware())

r.GET("/ping", func(c *gin.Context) {
  c.JSON(200, gin.H{"msg": "pong"})
})

r.GET("/person", func(c *gin.Context) {
  defer prometrics.TrackCRUD("person", "Get")(time.Now())

  c.JSON(200, gin.H{"name": "asraf"})
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  📊 Visualizing in Grafana
&lt;/h2&gt;

&lt;p&gt;Once your app exposes /metrics, you can scrape it using Prometheus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;scrape_configs:
  - job_name: 'prometric-go-demo'
    static_configs:
      - targets: ['localhost:7080']
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then build dashboards in Grafana with panels like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Request duration heatmaps&lt;/li&gt;
&lt;li&gt;Total requests per endpoint&lt;/li&gt;
&lt;li&gt;In-flight request gauge&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  ⚙️ Behind the Scenes
&lt;/h2&gt;

&lt;p&gt;When I started building small Go microservices, I kept rewriting the same few lines of Prometheus setup code — NewCounterVec, MustRegister, boilerplate handlers, and middleware wrappers.&lt;/p&gt;

&lt;p&gt;I wanted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;quick start&lt;/li&gt;
&lt;li&gt;clean, ready-to-use metrics,&lt;/li&gt;
&lt;li&gt;label conventions that were consistent,&lt;/li&gt;
&lt;li&gt;and no mental overhead every time I started a new project.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That’s where prometric-go was born.&lt;/p&gt;

&lt;p&gt;Some internal design goals that shaped it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Quick Start with Metrics&lt;/strong&gt;: Which metrics are useful to expose for a microservice/http-api and how to expose those. I wanted to start up with something without thinking too much. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Self-registration&lt;/strong&gt;: all metrics are registered automatically using promauto.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Safe concurrency&lt;/strong&gt;: metric operations are goroutine-safe by design.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;GoDoc first&lt;/strong&gt;: all exported symbols are documented so the package looks clean on pkg.go.dev.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composable structure&lt;/strong&gt;: submodules like http.go, crudmetrics.go, and apphealth.go keep responsibilities separate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The idea wasn’t to replace Prometheus — just to make it nicer and faster to use for everyday Go developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Roadmap
&lt;/h2&gt;

&lt;p&gt;Planned future enhancements include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add more metrics and customization to choose/filter metrics.&lt;/li&gt;
&lt;li&gt;Integration with OpenTelemetry&lt;/li&gt;
&lt;li&gt;Customizable metric namespace/prefix&lt;/li&gt;
&lt;li&gt;Built-in Chi(and probably others) middleware&lt;/li&gt;
&lt;li&gt;Out-of-the-box Grafana dashboards&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;prometric-go makes Prometheus metrics in Go simple, standardized, and developer-friendly.&lt;/p&gt;

&lt;p&gt;Whether you’re building an HTTP API, a CLI, or a microservice, it helps you focus on business logic — not boilerplate metrics wiring.&lt;/p&gt;

&lt;h2&gt;
  
  
  Give it a try 👇
&lt;/h2&gt;

&lt;p&gt;📦 &lt;a href="https://github.com/peek8/prometric-go" rel="noopener noreferrer"&gt;github.com/peek8/prometric-go&lt;/a&gt;&lt;br&gt;
If want to explore with some sample, please have a look at the part-2 blog: &lt;a href="https://dev.to/asraful_haque/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-216k"&gt;https://dev.to/asraful_haque/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-216k&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And checkout the corresponding github repo:&lt;br&gt;
&lt;a href="https://github.com/peek8/prometric-go-sample" rel="noopener noreferrer"&gt;https://github.com/peek8/prometric-go-sample&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📚 Documentation&lt;br&gt;
Full API reference available at:&lt;br&gt;
&lt;a href="https://pkg.go.dev/github.com/peek8/prometric-go/prometrics" rel="noopener noreferrer"&gt;pkg.go.dev/github.com/peek8/prometric-go/prometrics&lt;/a&gt;&lt;/p&gt;

</description>
      <category>go</category>
      <category>prometheus</category>
      <category>monitoring</category>
      <category>devops</category>
    </item>
    <item>
      <title>Make ArgoCD authenticated using AWS Cognito</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Sun, 01 Sep 2024 13:08:09 +0000</pubDate>
      <link>https://dev.to/asraful_haque/make-argocd-authenticated-using-aws-cognito-2328</link>
      <guid>https://dev.to/asraful_haque/make-argocd-authenticated-using-aws-cognito-2328</guid>
      <description>&lt;p&gt;&lt;a href="https://argo-cd.readthedocs.io/en/stable/" rel="noopener noreferrer"&gt;Argo CD&lt;/a&gt; is a declarative, GitOps continuous delivery tool for Kubernetes. If you install the argocd using &lt;a href="https://argo-cd.readthedocs.io/en/stable/getting_started/" rel="noopener noreferrer"&gt;the official guide&lt;/a&gt; and expose it using ALB and Route53, it will be open to anyone knowing the url.&lt;/p&gt;

&lt;p&gt;(If you want to know how to expose some EKS application using ALB and Route53 - see &lt;a href="https://dev.to/asraful_haque/expose-eks-tekton-pipeline-dashboard-with-ssl-enabled-3p4c"&gt;the blog post of exposing tekton-dashboard&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;The Goal of this blog is to show how we can make the argoCD protected  from public access using AWS Cognito and also control the access eg read/write access.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;EKS Cluster (or any other k8s cluster)&lt;/li&gt;
&lt;li&gt;Kubectl is configured at your local machine&lt;/li&gt;
&lt;li&gt;ArgoCD is installed at the cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step by Step
&lt;/h2&gt;

&lt;h2&gt;
  
  
  Setup AWS Cognito
&lt;/h2&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/asraful_haque/setup-aws-cognito-as-oidc-for-adding-access-control-for-application-40g7"&gt;the steps from this blog post on how to setup AWS Cognito&lt;/a&gt; for argoCD application.&lt;/p&gt;

&lt;p&gt;Get CLIENT_ID, CLIENT_SECRET and &lt;code&gt;oidc-issuer-url&lt;/code&gt; from aws cognito to be used in later steps.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create Users at AWS Cognito
&lt;/h2&gt;

&lt;p&gt;Go to the user pool and create two groups eg named &lt;code&gt;argocd-admin&lt;/code&gt; and &lt;code&gt;argocd-reader&lt;/code&gt;. Add the corresponding users to these groups ie add some admin users to &lt;code&gt;argocd-admin&lt;/code&gt; group and add some read-only user at &lt;code&gt;argocd-reader&lt;/code&gt;. The read-only users can't create application at argoCD console.&lt;/p&gt;

&lt;h2&gt;
  
  
  Update argoCD config
&lt;/h2&gt;

&lt;p&gt;Now we have to edit &lt;code&gt;argocd-cm&lt;/code&gt; and &lt;code&gt;argocd-rbac-cm&lt;/code&gt; configMap.&lt;br&gt;
You will get &lt;a href="https://github.com/asraf344/eks-argocd" rel="noopener noreferrer"&gt;the samples at this github repo&lt;/a&gt;. &lt;br&gt;
So steps would be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone the git repository&lt;/li&gt;
&lt;li&gt;go to &lt;code&gt;aws-cognito-config&lt;/code&gt; dir&lt;/li&gt;
&lt;li&gt;Get the &lt;code&gt;clientID&lt;/code&gt;, &lt;code&gt;clientSecret&lt;/code&gt; and &lt;code&gt;issuer&lt;/code&gt; url from previous cognito-setup step and fill the &lt;code&gt;oidc.config&lt;/code&gt; at argocm.yaml file&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The last field &lt;code&gt;url&lt;/code&gt; (at configMap) should be the domain url with which you will access the argocd console eg. &lt;code&gt;https://argocd.myekscluster.com&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now apply the configurations by :&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -n argocd -k .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;To take effect immediately, you can restart the &lt;code&gt;argocd server pod&lt;/code&gt;
ie. get the pods
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$kubectl get pods -n argocd | grep argocd-server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Then delete the pods eg if your argocd-server pod is &lt;code&gt;argocd-server-6d879b555c-srbv5&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl delete pod -n argocd argocd-server-6d879b555c-srbv5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's it, Now if you hit the argocd url eg. &lt;code&gt;https://argocd.myekscluster.com&lt;/code&gt;, you will see the button login with Cognito and if you enter the correct user and password you can login !!! 🎉.&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://medium.com/@devopsrockers/argocd-sso-config-with-aws-cognito-c51cade75cef" rel="noopener noreferrer"&gt;https://medium.com/@devopsrockers/argocd-sso-config-with-aws-cognito-c51cade75cef&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-user-pools.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-user-pools.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>argocd</category>
      <category>awscognito</category>
      <category>kubernetes</category>
      <category>cicd</category>
    </item>
    <item>
      <title>Setup AWS Cognito as OIDC for adding access control for Application</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Wed, 28 Aug 2024 03:31:53 +0000</pubDate>
      <link>https://dev.to/asraful_haque/setup-aws-cognito-as-oidc-for-adding-access-control-for-application-40g7</link>
      <guid>https://dev.to/asraful_haque/setup-aws-cognito-as-oidc-for-adding-access-control-for-application-40g7</guid>
      <description>&lt;h1&gt;
  
  
  Goal
&lt;/h1&gt;

&lt;p&gt;We will setup aws cognito by creating user pool and identity provider. This setup can be used for authenticating other app which support oidc endpoint.&lt;/p&gt;

&lt;h1&gt;
  
  
  Setup AWS Cognito
&lt;/h1&gt;

&lt;h2&gt;
  
  
  Create User Pool
&lt;/h2&gt;

&lt;p&gt;Go to &lt;code&gt;AWS Cognito Console&lt;/code&gt; and click on &lt;code&gt;create user pool&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure sign-in experience
&lt;/h3&gt;

&lt;p&gt;Select the &lt;code&gt;user name&lt;/code&gt; and &lt;code&gt;email&lt;/code&gt; sign-in options selected.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhosbx1bgpzzthcvcj3wu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhosbx1bgpzzthcvcj3wu.png" alt=" " width="800" height="720"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure security requirements
&lt;/h3&gt;

&lt;p&gt;Keep everything as default except set &lt;code&gt;No MFA&lt;/code&gt; option to keep things simple &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijs5njn1x76xjcwftvog.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fijs5njn1x76xjcwftvog.png" alt=" " width="800" height="853"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure sign-up experience
&lt;/h3&gt;

&lt;p&gt;For this section keep it to the default options&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure message delivery
&lt;/h3&gt;

&lt;p&gt;For message deliver select &lt;code&gt;select email with cognito&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fresp6zgbm5yvb6sxclz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fresp6zgbm5yvb6sxclz4.png" alt=" " width="800" height="674"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Integrate your app
&lt;/h3&gt;

&lt;p&gt;Give some user-pool name eg &lt;code&gt;myapp-users&lt;/code&gt; and app client name is &lt;code&gt;myapp&lt;/code&gt;. Make sure that the app client is public and check the option &lt;code&gt;Generate a client secret&lt;/code&gt;. Keep everything else as their default options.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fso3bgyfcuzvjg3qex8w2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fso3bgyfcuzvjg3qex8w2.png" alt=" " width="800" height="896"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Create User Pool
&lt;/h2&gt;

&lt;p&gt;Create Identity Pools by going to AWS cognito then identity-pool console&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure identity pool trust
&lt;/h3&gt;

&lt;p&gt;Check &lt;code&gt;Authenticated Access&lt;/code&gt; and &lt;code&gt;Amazon Cognito User Pool&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo0ysh7gzwfpy8hd0oih2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fo0ysh7gzwfpy8hd0oih2.png" alt=" " width="800" height="750"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure permissions
&lt;/h3&gt;

&lt;p&gt;Create a new role eg named &lt;code&gt;myapp-identity-role&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjxswag9oacjilz8y76o2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjxswag9oacjilz8y76o2.png" alt=" " width="800" height="632"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Connect identity providers
&lt;/h3&gt;

&lt;p&gt;Select your user pools eg &lt;code&gt;myapp-users&lt;/code&gt; and the client (eg &lt;code&gt;myapp&lt;/code&gt;) you created in earlier steps. Set everything else default&lt;/p&gt;

&lt;h3&gt;
  
  
  Configure properties
&lt;/h3&gt;

&lt;p&gt;Put some name eg. &lt;code&gt;myapp-idp&lt;/code&gt;, keep everthing else on their default values.&lt;/p&gt;

&lt;h3&gt;
  
  
  Review and create
&lt;/h3&gt;

&lt;p&gt;Review and Create your identity Pool&lt;/p&gt;

&lt;h3&gt;
  
  
  Create user at your user pools
&lt;/h3&gt;

&lt;p&gt;Go to your user pools eg &lt;code&gt;myapp-users&lt;/code&gt;, and then click on &lt;code&gt;users&lt;/code&gt; then &lt;code&gt;create user&lt;/code&gt;.&lt;br&gt;
Put your user name and email and set a password:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4rrldcu71ujxoz3haeda.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4rrldcu71ujxoz3haeda.png" alt=" " width="800" height="871"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Get Values for using AWS Cognito as OIDC
&lt;/h3&gt;

&lt;h4&gt;
  
  
  CLIENT_ID and CLIENT_SECRET
&lt;/h4&gt;

&lt;p&gt;You will get client-id and secret  from your &lt;code&gt;AWS User Pools&lt;/code&gt; ie &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to &lt;code&gt;Cognito User Pools&lt;/code&gt; and select your user pool(eg. &lt;code&gt;tekton-user&lt;/code&gt;) &lt;/li&gt;
&lt;li&gt;Click on &lt;code&gt;App Integration&lt;/code&gt; tab &lt;/li&gt;
&lt;li&gt;Go to the &lt;code&gt;App client list&lt;/code&gt; section &lt;/li&gt;
&lt;li&gt;Click on your client &lt;/li&gt;
&lt;li&gt;At App client information page you will find the &lt;code&gt;Client ID&lt;/code&gt; and &lt;code&gt;Client Secret&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  OIDC Issuer URL
&lt;/h4&gt;

&lt;p&gt;The oidc url for your AWS &lt;code&gt;Cognito User Pools&lt;/code&gt;, It would be like : &lt;code&gt;https://cognito-idp.AWS_REGION.amazonaws.com/USER_POOL_ID&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;For example if your region is eu-west-1 and your user-pool id is &lt;code&gt;eu-west-1-1234&lt;/code&gt;, then it will be: &lt;code&gt;https://cognito-idp.eu-west-1.amazonaws.com/eu-west-1-1234&lt;/code&gt;.  You will find the user-pool id at your &lt;code&gt;AWS Cognito user-pools overview page&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Read
&lt;/h2&gt;

&lt;p&gt;See &lt;a href="https://dev.to/asraful_haque/make-tekton-dashboard-user-authenticated-at-eks-using-aws-cognito-4jg3"&gt;my next blog post on authenticating tekton-dashboard&lt;/a&gt; as an example how we can use aws cognito as OIDC provider.&lt;/p&gt;

&lt;p&gt;Reference:&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-user-pools.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-user-pools.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>awscognito</category>
      <category>eks</category>
    </item>
    <item>
      <title>Make Tekton Dashboard user authenticated at EKS using AWS Cognito</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Thu, 22 Aug 2024 07:19:39 +0000</pubDate>
      <link>https://dev.to/asraful_haque/make-tekton-dashboard-user-authenticated-at-eks-using-aws-cognito-4jg3</link>
      <guid>https://dev.to/asraful_haque/make-tekton-dashboard-user-authenticated-at-eks-using-aws-cognito-4jg3</guid>
      <description>&lt;h2&gt;
  
  
  Goal
&lt;/h2&gt;

&lt;p&gt;The goal of this post is to add authentication to &lt;a href="https://tekton.dev/docs/dashboard" rel="noopener noreferrer"&gt;Tekton Dashboard &lt;/a&gt;installed at &lt;a href="https://aws.amazon.com/eks/" rel="noopener noreferrer"&gt;AWS EKS&lt;/a&gt;&lt;br&gt;
If you are only interested to install the Dashboard and keep it publicly accessible, have a look at my &lt;a href="https://dev.to/asraful_haque/expose-eks-tekton-pipeline-dashboard-with-ssl-enabled-3p4c"&gt;previous blog post&lt;/a&gt; on &lt;code&gt;Expose EKS tekton pipeline dashboard with ssl enabled&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feflxhwzeayvtz2s3tjej.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feflxhwzeayvtz2s3tjej.jpg" alt=" " width="400" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@iraj83?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Iraj Ishtiak&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/a-pond-with-trees-around-it-DNKhf4lPqLQ?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;
&lt;h1&gt;
  
  
  Pre-Requisite
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;EKS Cluster &lt;/li&gt;
&lt;li&gt;Kubectl is configured at your local machine&lt;/li&gt;
&lt;li&gt;Tekton pipeline is installed&lt;/li&gt;
&lt;/ul&gt;
&lt;h1&gt;
  
  
  Strategy
&lt;/h1&gt;

&lt;p&gt;As per the &lt;a href="https://tekton.dev/docs/dashboard/install/#access-control" rel="noopener noreferrer"&gt;Tekton Dashboard documentation&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Dashboard does not provide its own authentication or authorization, however it will pass on any authentication headers provided to it by a proxy deployed in front of the Dashboard.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For authentication, there are several options like oauth2-proxy, Keycloak, OpenUnison, Traefik, Istio’s EnvoyFilter. For this tutorial we will use &lt;a href="https://oauth2-proxy.github.io/oauth2-proxy/" rel="noopener noreferrer"&gt;oauth2-proxy&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Workflows
&lt;/h2&gt;

&lt;p&gt;-- There will be a oauth2-proxy service deployed&lt;br&gt;
-- This service will be exposed via the loadbalancer and the loadbalancer will be mapped against the your domain eg &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt;&lt;br&gt;
-- The upstream of the oauth-proxy service is the tekton-dashboard service.&lt;br&gt;
-- We will use &lt;a href="https://aws.amazon.com/cognito/" rel="noopener noreferrer"&gt;AWS Cognito&lt;/a&gt; as the OIDC provider for oauth2-proxy service ie user will be authenticated via &lt;a href="https://aws.amazon.com/cognito/" rel="noopener noreferrer"&gt;AWS Cognito&lt;/a&gt;.&lt;br&gt;
-- With the above setup, when the end user will request for the tekton-dashboard  (with eg &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt;) it will first hit the oauth2 proxy service.&lt;br&gt;
-- The &lt;code&gt;oauth2-proxy service&lt;/code&gt; will forward the request to &lt;a href="https://aws.amazon.com/cognito/" rel="noopener noreferrer"&gt;AWS Cognito&lt;/a&gt; to check if the user is authenticated.&lt;br&gt;
-- If authenticated, the user is logged in and can see the tekton-dashboard.&lt;/p&gt;
&lt;h1&gt;
  
  
  Step By Step
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Install Tekton Dashboard
&lt;/h2&gt;

&lt;p&gt;-- Install the &lt;strong&gt;Tekton Dashboard&lt;/strong&gt; using &lt;a href="https://tekton.dev/docs/dashboard/install/" rel="noopener noreferrer"&gt;the official documentation&lt;/a&gt;&lt;br&gt;
-- Add a Service to access the Tekton Dashboard eg. &lt;code&gt;tekton-dashboard.yaml&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  labels:
    app: tekton-dashboard
    app.kubernetes.io/component: dashboard
    app.kubernetes.io/instance: default
    app.kubernetes.io/name: dashboard
    app.kubernetes.io/part-of: tekton-dashboard
    app.kubernetes.io/version: v0.49.0
    dashboard.tekton.dev/release: v0.49.0
    version: v0.49.0
  name: tekton-dashboard
  namespace: tekton-pipelines
spec:
  ports:
    - name: http
      port: 9097
      protocol: TCP
      targetPort: 9097
  selector:
    app.kubernetes.io/component: dashboard
    app.kubernetes.io/instance: default
    app.kubernetes.io/name: dashboard
    app.kubernetes.io/part-of: tekton-dashboard
  sessionAffinity: None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that this service doesn't have a type so, its of type &lt;code&gt;ClusterIP&lt;/code&gt; that means only accessible internally inside the cluster ie this service can be accessed using &lt;code&gt;http://tekton-dashboard:9097&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup AWS Cognito
&lt;/h2&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/asraful_haque/setup-aws-cognito-as-oidc-for-adding-access-control-for-application-40g7"&gt;the steps from this blog post on how to setup AWS Cognito&lt;/a&gt; for this app&lt;/p&gt;

&lt;p&gt;Now We are done with setting up AWS Cognito. Lets move to &lt;code&gt;Oauth2 Proxy&lt;/code&gt;.&lt;br&gt;
Get CLIENT_ID, CLIENT_SECRET and &lt;code&gt;oidc-issuer-url&lt;/code&gt; from aws cognito to be used in later steps.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing and Configuring Oauth2-Proxy
&lt;/h2&gt;

&lt;p&gt;What we have to do now deploy the oauth2 proxy as &lt;code&gt;k8s Deployement&lt;/code&gt;, expose that proxy app to the world by creating a service and map the domain name for the service.&lt;/p&gt;
&lt;h3&gt;
  
  
  Create Tekton Dashboard secret
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl create secret generic tekton-dashboard-auth \
-n tekton-pipelines \
--from-literal=username=CLIENT_ID \
--from-literal=password=CLIENT_SECRET
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;You will get the CLIENT_ID and CLIENT_SECRET from your &lt;code&gt;AWS User Pools&lt;/code&gt; (see &lt;a href="https://dev.to/asraful_haque/setup-aws-cognito-as-oidc-for-adding-access-control-for-application-40g7"&gt;the steps at AWS Cognito post&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Add the oauth2-proxy Deployment
&lt;/h3&gt;

&lt;p&gt;Before creating the deployment for &lt;code&gt;oauth2-proxy&lt;/code&gt;, check the following values:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;upstream&lt;/code&gt;: This is the url of the tekton-dashboard service. In our case it will be &lt;code&gt;http://tekton-dashboard:9097&lt;/code&gt;.
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;redirect-url&lt;/code&gt;: The url where the oauth-proxy will be redirected. it will be you tekton-dashboard callback url eg. &lt;a href="https://tkn-dashboard.myeks/oauth2/callback" rel="noopener noreferrer"&gt;https://tkn-dashboard.myeks/oauth2/callback&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;oidc-issuer-url&lt;/code&gt;: The oidc url for your AWS &lt;code&gt;Cognito User Pools&lt;/code&gt;, It would be like : &lt;code&gt;https://cognito-idp.AWS_REGION.amazonaws.com/USER_POOL_ID&lt;/code&gt;. For example if your region is eu-west-1 and your user-pool id is &lt;code&gt;eu-west-1-1234&lt;/code&gt;, then it will be: &lt;code&gt;https://cognito-idp.eu-west-1.amazonaws.com/eu-west-1-1234&lt;/code&gt;.  You will find the user-pool id at your &lt;code&gt;AWS Cognito user-pools overview page&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cookie-secret&lt;/code&gt;: Generate some random string for cookie secret. you can use openssl for that:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ openssl rand -base64 32 | head -c 32 | base64
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;To make things easier, I have put the deployment and service file at &lt;a href="https://github.com/asraf344/eks-tekton/blob/main/tekton-dashboard-oidc" rel="noopener noreferrer"&gt;this eks-tekton github repository&lt;/a&gt;. Clone it and add the values of above params at the &lt;a href="https://github.com/asraf344/eks-tekton/blob/main/tekton-dashboard-oidc/tekton-dashboard-oidc.yaml#L31-L36" rel="noopener noreferrer"&gt;Deployment manifest&lt;/a&gt;.&lt;br&gt;
(Don't apply it yet, we have to change the service as well)&lt;/p&gt;
&lt;h3&gt;
  
  
  Exposing the oauth2-proxy service with LoadBalancer
&lt;/h3&gt;
&lt;h4&gt;
  
  
  Create Certificate
&lt;/h4&gt;

&lt;p&gt;Create Certificate using &lt;a href="https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html" rel="noopener noreferrer"&gt;AWS Certificate Manager&lt;/a&gt; for your domain &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt;. Make sure you also validate the certificate.&lt;/p&gt;
&lt;h4&gt;
  
  
  Add certificate arn at the service
&lt;/h4&gt;

&lt;p&gt;We need to add the following annotations at the service which needs the certificate arn, ie&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn of the certificate created above"
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the certificate arn, at your cloned github repository for the  &lt;a href="https://github.com/asraf344/eks-tekton/blob/main/tekton-dashboard-oidc/tekton-dashboard-oidc.yaml#L78" rel="noopener noreferrer"&gt;tekton-dashboard-auth service&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Create the deployment and service
&lt;/h4&gt;

&lt;p&gt;If you are at the root of the cloned github repo and modified as per above steps, now you can apply it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -n tekton-pipelines -k tekton-dashboard-oidc
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create the deployment and corresponding services, and there will be a loadbalancer created which points to the oauth2-proxy service.&lt;/p&gt;

&lt;h3&gt;
  
  
  Map the domain with Loadbalancer
&lt;/h3&gt;

&lt;p&gt;Now, Find your LoadBalancer from the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kc get svc tekton-dashboard-auth -n tekton-pipelines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the LoadBalancer URl at the &lt;code&gt;External-IP&lt;/code&gt; field.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;With the URL, Locate that LoadBalancer at AWS Console and check at the Listener there is &lt;code&gt;443&lt;/code&gt; port. For the SSL certificate check the certificate you defined at the &lt;code&gt;Service&lt;/code&gt; has been attached at the loadbalancer.&lt;/li&gt;
&lt;li&gt;From AWS Route53, Associate your domain name (eg. &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt;) with the LoadBalancer. If you are doing it for the first time, you can follow the &lt;a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-elb-load-balancer.html" rel="noopener noreferrer"&gt;AWS Routing traffic to an ELB load balancer documentation&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's it now you can browse the tekton dashboard using your domain eg. &lt;a href="https://tekton-dashboard.myeks.com" rel="noopener noreferrer"&gt;https://tekton-dashboard.myeks.com&lt;/a&gt; and it ask you &lt;code&gt;login with AWS Cognito&lt;/code&gt;.&lt;br&gt;
If you put the correct &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;password&lt;/code&gt;, you will be on the &lt;code&gt;Tekton Dashboard&lt;/code&gt; homepage 🎉.&lt;/p&gt;

&lt;p&gt;NB. The picture attached at this post not related to content, its just attached to &lt;code&gt;soothe your eyes&lt;/code&gt; :)&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://medium.com/octo-technology-morocco/secure-authentication-to-tekton-dashboard-using-oidc-36de9b3f8a7d" rel="noopener noreferrer"&gt;https://medium.com/octo-technology-morocco/secure-authentication-to-tekton-dashboard-using-oidc-36de9b3f8a7d&lt;/a&gt;&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/56534589/is-there-a-way-to-configure-an-eks-service-to-use-https" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/56534589/is-there-a-way-to-configure-an-eks-service-to-use-https&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-user-pools.html" rel="noopener noreferrer"&gt;https://docs.aws.amazon.com/cognito/latest/developerguide/getting-started-user-pools.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>tekton</category>
      <category>awseks</category>
      <category>awscognito</category>
    </item>
    <item>
      <title>Expose EKS tekton pipeline dashboard with ssl enabled</title>
      <dc:creator>Md Asraful Haque (Sohel)</dc:creator>
      <pubDate>Wed, 21 Aug 2024 06:36:30 +0000</pubDate>
      <link>https://dev.to/asraful_haque/expose-eks-tekton-pipeline-dashboard-with-ssl-enabled-3p4c</link>
      <guid>https://dev.to/asraful_haque/expose-eks-tekton-pipeline-dashboard-with-ssl-enabled-3p4c</guid>
      <description>&lt;p&gt;In this tutorial we will try to expose &lt;a href="https://tekton.dev/docs/dashboard/" rel="noopener noreferrer"&gt;tekton-pipeline dashboard&lt;/a&gt; using application load balancer with ssl enabled at AWS EKS cluster.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqmkc1pqohboz3zc790o.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcqmkc1pqohboz3zc790o.jpg" alt="Image River and boat of bangladesh, Shaplabill, Jointapur, Sylhet, Bangladesh" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@fahadzyl" rel="noopener noreferrer"&gt;ATM Arafath Ali&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/a-boat-floating-on-top-of-a-body-of-water-RtciDwB0v5A" rel="noopener noreferrer"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Pre-Requisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;EKS Cluster &lt;/li&gt;
&lt;li&gt;Kubectl is configured at your local machine&lt;/li&gt;
&lt;li&gt;Tekton pipeline is installed&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Context
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://tekton.dev/docs/dashboard/" rel="noopener noreferrer"&gt;Tekton Dashboard &lt;/a&gt; is a Web-based UI for Tekton Pipelines and Tekton Triggers resources. Its quite easy to install following the &lt;a href="https://tekton.dev/docs/dashboard/install/" rel="noopener noreferrer"&gt;official Install guidelines&lt;/a&gt; using kubectl. In your self-managed kubernetes cluster, you can easily expose it with ingress controller, But at EKS you have to install some ingress controller which is &lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/aws-load-balancer-controller.html" rel="noopener noreferrer"&gt;AWS Load Balancer Controller&lt;/a&gt; which seems to be a bit hassle to me if you want to achieve something quickly. Rather than I would use Service to achieve this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install Tekton Dashboard
&lt;/h2&gt;

&lt;p&gt;Install the &lt;strong&gt;Tekton Dashboard&lt;/strong&gt; using &lt;a href="https://tekton.dev/docs/dashboard/install/" rel="noopener noreferrer"&gt;the official documentation&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Expose Tekton Dashboard with Service (without https)
&lt;/h2&gt;

&lt;p&gt;Create a &lt;strong&gt;LoadBalancer Type Service&lt;/strong&gt; (ie tekton-dashboard-svc.yaml) with the following manifests:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  labels:
    app: tekton-dashboard    
  name: tekton-dashboard
  namespace: tekton-pipelines
spec:
  type: LoadBalancer
  ports:
    - name: http
      port: 9097
      protocol: TCP
      targetPort: 9097
  selector:
    app.kubernetes.io/component: dashboard
    app.kubernetes.io/instance: default
    app.kubernetes.io/name: dashboard
    app.kubernetes.io/part-of: tekton-dashboard
  sessionAffinity: None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create this service using kubectl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -n tekton-pipelines -f tekton-dashboard-svc.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will create a LoadBalancer at aws, with the load balancer url you can access the dashboard or you can also map this loadBalancer with your domain name eg &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt; using Route53 service.&lt;/p&gt;

&lt;h2&gt;
  
  
  Expose Tekton Dashboard with Service and https enabled
&lt;/h2&gt;

&lt;p&gt;Exposing the &lt;a href="https://tekton.dev/docs/dashboard/" rel="noopener noreferrer"&gt;Tekton Dashboard &lt;/a&gt; with &lt;strong&gt;LoadBalancer Service&lt;/strong&gt; was quite easy. Now we want to enable https. To do that we have to do the following steps:&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Create Certificate
&lt;/h3&gt;

&lt;p&gt;Create Certificate using &lt;a href="https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html" rel="noopener noreferrer"&gt;AWS Certificate Manager&lt;/a&gt; for your domain &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt;. Make sure you also validate the certificate.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 : Create Service with the certificate
&lt;/h3&gt;

&lt;p&gt;Add the following annotations with the certificate arn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn of the certificate created above"
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So the service will be like following (ie. tekton-dashboard-svc-ssl.yaml):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;apiVersion: v1
kind: Service
metadata:
  annotations:
    # Note that the backend talks over HTTP.
    service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
    # TODO: Fill in with the ARN of your certificate.
    service.beta.kubernetes.io/aws-load-balancer-ssl-cert: "arn of the certificate created above"
    # Only run SSL on the port named "https" below.
    service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "https"
  labels:
    app: tekton-dashboard
  name: tekton-dashboard-ssl
  namespace: tekton-pipelines
spec:
  type: LoadBalancer
  ports:
    - name: http
      port: 80
      protocol: TCP
      targetPort: 9097
    - name: https
      port: 443
      protocol: TCP
      targetPort: 9097
   selector:
    app.kubernetes.io/component: dashboard
    app.kubernetes.io/instance: default
    app.kubernetes.io/name: dashboard
    app.kubernetes.io/part-of: tekton-dashboard
  sessionAffinity: None
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create this service using kubectl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kubectl apply -n tekton-pipelines -f tekton-dashboard-svc-ssl.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you had created the service using tekton-dashboard-svc.yaml, you can delete that service.&lt;br&gt;
Wait for some time, the load balancer will be created and now you can use now https.&lt;/p&gt;
&lt;h3&gt;
  
  
  Step 3 : Use the domain name
&lt;/h3&gt;

&lt;p&gt;Now, Find your LoadBalancer from the service:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ kc get svc tekton-dashboard-ssl -n tekton-pipelines
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You will get the LoadBalancer URl at the &lt;code&gt;External-IP&lt;/code&gt; field.&lt;/p&gt;

&lt;p&gt;-- With the URL, Locate that LoadBalancer at AWS Console and check at the Listener there is &lt;code&gt;443&lt;/code&gt; port. For the SSL certificate check the certificate you defined at the &lt;code&gt;Service&lt;/code&gt; has been attached at the loadbalancer.&lt;br&gt;
-- From AWS Route53, Associate your domain name (eg. &lt;code&gt;tekton-dashboard.myeks.com&lt;/code&gt;) with the LoadBalancer. If you are doing it for the first time, you can follow the &lt;a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/routing-to-elb-load-balancer.html" rel="noopener noreferrer"&gt;AWS Routing traffic to an ELB load balancer documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it now you can browse the tekton dashboard using &lt;a href="https://tekton-dashboard.myeks.com" rel="noopener noreferrer"&gt;https://tekton-dashboard.myeks.com&lt;/a&gt; 🎉&lt;/p&gt;

&lt;p&gt;If you want to Make your Tekton Dashboard user authenticated, Look at my &lt;a href="https://dev.to/asraful_haque/make-tekton-dashboard-user-authenticated-at-eks-using-aws-cognito-4jg3"&gt;next post to authenticate Tekton Dashboard using AWS Cognito&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;NB. The picture attached at this post not related to content, its just attached to &lt;code&gt;soothe your eyes&lt;/code&gt; :)&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
&lt;a href="https://stackoverflow.com/questions/56534589/is-there-a-way-to-configure-an-eks-service-to-use-https" rel="noopener noreferrer"&gt;https://stackoverflow.com/questions/56534589/is-there-a-way-to-configure-an-eks-service-to-use-https&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>tekton</category>
      <category>kubernetes</category>
      <category>awseks</category>
    </item>
  </channel>
</rss>
