Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ

This article is Part 2 of my Prometric-Go series.
If you haven’t read Part 1 yet β€” the introduction to the library β€” you can check it out here:
πŸ”— https://dev.to/asraful_haque/simplifying-prometheus-metrics-in-go-with-prometric-go-22ef

πŸ‘‹ …


This content originally appeared on DEV Community and was authored by Md Asraful Haque (Sohel)

This article is Part 2 of my Prometric-Go series.

If you haven't read Part 1 yet β€” the introduction to the library β€” you can check it out here:

πŸ”— https://dev.to/asraful_haque/simplifying-prometheus-metrics-in-go-with-prometric-go-22ef

πŸ‘‹ What we’re building in Part 2

In this article we will instrument a real Go API using prometric-go, collect metrics in Prometheus, and visualize everything in Grafana β€” including a load-test using k6 to generate traffic.

To make this super easy, I created a ready-to-run sample project:

πŸ”— GitHub Repo: https://github.com/peek8/prometric-go-sample

This repository contains:

Purpose Tool
Metric instrumentation prometric-go
Metrics storage Prometheus
Metrics visualization Grafana
Web API Go + net/http
Traffic Generation Grafan k6

k6 hits the API β†’ API exposes metrics via /metrics β†’ Prometheus scrapes β†’ Grafana visualizes.

βš™οΈ Clone & Run the Sample

$ git clone https://github.com/peek8/prometric-go-sample
$ cd prometric-go-sample
$ make run

This will run the api server at port 7080. You can explore the prometheus metrics exposed by prometric-go library at url:

http://localhost:7080/metrics

See the full metrics list exposed at prometric-go library readme

The K6 Script

I use Grafan k6 to generate traffic against the prometric API. This k6-scripts demonstrates a simple scenario that exercises the CRUD endpoints for Person objects.

What the script does

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

These above iterations are enough to generate some adequate prometheus metrics which can be used to play with prometheus and grafana dashboard.

Run k6

  • Install Grafan k6 at your local machine and run the k6-scripts from the repo:
$ k6 run ./scripts/k6-scripts.js

And now if you hit the metric endpoint, you will see different metric values keep changing.

Prometheus and Grafana

Run Prometheus

Run prometheus using the prometheus.yml file:

$ docker run \
    -p 9090:9090 \
    -v ./resources/prometheus.yml:/etc/prometheus/prometheus.yml \
    prom/prometheus

N.B: If you are using podman use host.containers.internal as targets at prometheus.yml file, ie:

targets: ["host.containers.internal:7080"]

Run Grafana

Run Grafan using docker:

$ docker run -d -p 3000:3000 grafana/grafana

Then grafana will be available at http://localhost:3000, use admin:admin as to login for the first time.

Import the included dashboard

Create Grafana Data Source

Import Grafana Dashboard

  • Open Grafana β†’ Dashboards
  • Click Import
  • Upload grafana-dashboard.json
  • Select Prometheus datasource β†’ prometric-k6 (or the one you use)

Voila, You’ll now see real-time metrics at the dashboard from the sample app:

Image Grafana Dashboard

πŸ’‘ What You Learn From This Sample

Category Benefit
Go backend Clean way to expose metrics
Prometheus Scraping & querying the app
Grafana Dashboarding for API performance
k6 Generating programmable load
Observability From raw counters β†’ real visual insights

🎁 Bonus: You Can Reuse This as a Template

The repo is intentionally simple, so you can fork it and adapt it for your own services.

  • Replace Person CRUD API with your own business logic
  • Keep the prometric-go instrumentation + dashboard
  • Add additional domain metrics as needed
  • Extend k6 tests to simulate real traffic

🌟 Final Thoughts

Prometheus + Grafana can feel complex when you start from scratch β€”
but with prometric-go, you get:

πŸ‘Œ Meaningful metrics by default
πŸ“¦ Domain-specific metrics with 2–3 lines of code
πŸš€ Dashboards ready to plug into production

If you try out the sample, I’d love to hear your feedback!

⭐ If this helped you…

Support the project by giving a ⭐ to both repos:

πŸ”— https://github.com/peek8/prometric-go

πŸ”— https://github.com/peek8/prometric-go-sample

And feel free to reach out if you want help adding alerting rules, histograms tuning, Grafana provisioning, or Kubernetes deployment.


This content originally appeared on DEV Community and was authored by Md Asraful Haque (Sohel)


Print Share Comment Cite Upload Translate Updates
APA

Md Asraful Haque (Sohel) | Sciencx (2025-11-18T04:19:43+00:00) Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ. Retrieved from https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/

MLA
" » Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ." Md Asraful Haque (Sohel) | Sciencx - Tuesday November 18, 2025, https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/
HARVARD
Md Asraful Haque (Sohel) | Sciencx Tuesday November 18, 2025 » Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ., viewed ,<https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/>
VANCOUVER
Md Asraful Haque (Sohel) | Sciencx - » Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/
CHICAGO
" » Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ." Md Asraful Haque (Sohel) | Sciencx - Accessed . https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/
IEEE
" » Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ." Md Asraful Haque (Sohel) | Sciencx [Online]. Available: https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/. [Accessed: ]
rf:citation
» Prometric-Go Part 2 β€” Full Hands-On Demo with Grafana, Prometheus & k6 πŸ“ˆ | Md Asraful Haque (Sohel) | Sciencx | https://www.scien.cx/2025/11/18/prometric-go-part-2-full-hands-on-demo-with-grafana-prometheus-k6-%f0%9f%93%88/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.