Skip to content

mithunsl/prometheus-metrics-sample-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prometheus-metrics-sample-app

A sample prometheus metrics python application

Pre-requisites

  1. Docker
  2. Kind
  3. Kubectl
  4. Helm
  5. Kustomize

Note: If you are using Docker Desktop on Mac or Windows, please make sure the Docker VM is configured to use a minimum of 4 CPUs and 6GB Memory. (This can be modified under the setting/preferences of Docker Desktop)

Steps

  1. Create a kubernetes cluster.
kind create cluster -f kind/config.yaml
  1. Install the prometheus-operator using the kube-prometheus-stack helm chart.
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm update

helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack --version 31.0.0 -n monitoring

This will install the prometheus-operator which inturn will create prometheus statefulset, grafana deployment and alertmanager statefulset and a few out of the box exporters in the monitoring namespace

prometheus-metrics-sample-app % kubectl get pods -n monitoring                                  
NAME                                                        READY   STATUS    RESTARTS   AGE
alertmanager-kube-prometheus-stack-alertmanager-0           2/2     Running   0          75s
kube-prometheus-stack-grafana-67f7cb9468-srjbs              3/3     Running   0          79s
kube-prometheus-stack-kube-state-metrics-7f56994f6c-9lp95   1/1     Running   0          79s
kube-prometheus-stack-operator-868bb97b5c-bntw5             1/1     Running   0          79s
kube-prometheus-stack-prometheus-node-exporter-7sgfd        1/1     Running   0          79s
kube-prometheus-stack-prometheus-node-exporter-bg8rg        1/1     Running   0          79s
kube-prometheus-stack-prometheus-node-exporter-h67xq        1/1     Running   0          79s
kube-prometheus-stack-prometheus-node-exporter-nd6jt        1/1     Running   0          79s
prometheus-kube-prometheus-stack-prometheus-0               2/2     Running   0          75s
  1. Build the sample python metrics app
cd pythonapp

docker build -t metrics:v0.1 -f dockerfile-distroless .
  1. Load the image into the Kubernetes nodes.
kind load docker-image metrics:v0.1 --name monitoring
  1. Deploy the python application.
cd ../manifests

kubectl build . | kubectl create -f -
  1. Monitor the metrics using prometheus.
kubectl port-forward svc/prometheus-operated -n monitoring 9090

Access localhost:9090 using a browser.

Find the service monitor as a prometheus target.

alt text

About

A sample prometheus metrics python application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages