a-service is a simple golang service which exposes 2 http endpoints:
/health
/metrics
It also exposes a bunch of metrics to prometheus:
regular golang metrics
a_hits_total: The total number of hits
avec_duration_seconds: 99th percentile latency in seconds
You can run a docker build and post it to your own docker registry. However for the sake of simplicity a docker images is already available with this a-service at quay.io/bjoydeep/a-service:latest
Goal
Goal is to get the metrics this service emits into the platform Prometheus inside OpenShift - in other words, the Promtheus deployed by the default OpenShift. Check with OpenShift RedHat Team if this will be supported even though you can technically do it.
Steps
Connect to your OpenShift cluster as cluster admin.
Adjust image location in deploy/deploy.yaml if needed.
Run kubectl apply -k deploy/
You will find that a namespace a-service created and a pod and a service is created under it. It will also create ServiceMonitor CR in the openshift-monitoring namespace and allow prometheus-k8s service account in openshift-monitoring namespace to scrape endpoints of service exposed by a-service (it creates the required ClusterRole and ClusterRoleBinding)
Create a route in OpenShift for the service created by a-service