Monitoring with custom metrics¶
In this exercice, we will see how to generatge custom metircs using a Prometheus client and mock multiple access to API endpoints.
The sample application called WoLaM extracted from the tutorial here. This project includes the code to generate custom metrics.
For instance, review line 29 here to see how the custom metric
wolam_api_counter is defined.
Step 1: Setup the application¶
-
Setup manifests for the application
Ensure the valeu of
INGRESS_SUBDOMAINis set based on the sample application deploy steps from this lab.Replaceecho "Ingress subdomain: ${INGRESS_SUBDOMAIN}"<INGRESS_SUBDOMAIN>ink8s/ingress.yamlfile with the value that you retrieved in the previous step by running the following command:Users on Mac:sed -i "s/<INGRESS_SUBDOMAIN>/${INGRESS_SUBDOMAIN}/" k8s/monitor/app-log-analysis.yamlVerify the igress value was substituted correctly:sed -i "" "s/<INGRESS_SUBDOMAIN>/${INGRESS_SUBDOMAIN}/" k8s/monitor/app-log-analysis.yaml$ more k8s/app-log-analysis.yaml ... spec: rules: - host: observe.iks-cluster-user-0-c074815f6c3dc41618f978f8bffffa07-0000.us-south.containers.appdomain.cloud http: paths: - path: /(.*) ... -
Run the applicaiton
Run the
kubectlcommand to deploy the application. Two pods with nameapp-log-analysis-deploymentshould show inRunningstatus.kubectl create -f k8s/monitor/app-log-analysis.yaml deployment.apps/app-log-analysis-deployment created service/app-log-analysis-svc created ingress.networking.k8s.io/app-log-analysis-ingress created $ kubectl get pods NAME READY STATUS RESTARTS AGE api-gateway-575f59b7d8-vlm6x 1/1 Running 0 12h app-log-analysis-deployment-595df69c5-77l5h 1/1 Running 0 20s app-log-analysis-deployment-595df69c5-gxwvh 1/1 Running 0 20s customers-687749cfb-vzblv 1/1 Running 0 12h missing-image-6c677574d8-zqc57 0/1 ImagePullBackOff 0 78m vets-6bb6655b7f-dpf88 1/1 Running 0 12h visits-784749c647-t6tb9 1/1 Running 0 10hUse the application endpoint to get to the
WoLaMlanding page.echo "https://observe.${INGRESS_SUBDOMAIN}"echo "https://observe.${INGRESS_SUBDOMAIN}" https://observe.iks-cluster-user-0-c074815f6c3dc41618f978f8bffffa07-0000.us-south.containers.appdomain.cloudThe application is now ready to send custom metric data.
Step 2: Monitor Metrics¶
-
Generate metrics
Go to the
WoLaMapplication, select theMonitoringtab and generate few metrics. for eg:Development,London&25. -
View metrics
To monitor the calls to a given api endpoint of the application, From the Explore tab, select Deployments. Select
Metrics > Prometheus > wolam_api_counter_totalin the Metrics and Dashboards dropdown. SelectTime: Average, Group: Sum, Segment: endpoint.Go back to the
WoLaMapplication, generate a few metrics after changing the region. To monitor the calls to a given api endpoint of the application by region, SelectTime: Average, Group: Sum, Segment: region.