eGov Monitoring & Alerting Setup
This doc will cover how you can set up the monitoring and alerting on existing k8s cluster either with help of go lang script or Jenkins deployment Jobs.
Prometheus is an open-source system monitoring and alerting toolkit originally built at SoundCloud
Pre-reads
https://prometheus.io/docs/introduction/overview OAuth2-Proxy Setup
Pre-requisites
All DIGIT services are packaged using helm charts
Installing Helm
kubectl is a CLI to connect to the kubernetes cluster from your machine
Install Visualstudio IDE Code for better code/configuration editing capabilities
Git
![](https://core.digit.org/~gitbook/image?url=https%3A%2F%2F4016629814-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FX13sH0e4xi7bV1juDmGX%252Fuploads%252FHGVP5LUgHpOYCkXE3BWe%252Fimage.png%3Falt%3Dmedia%26token%3De97745b4-f1c7-468f-b60c-d5149f470d79&width=768&dpr=4&quality=100&sign=a0f7e3c2&sv=1)
prometheus-operator chart includes multiple components and is suitable for a variety of use-cases.
The default installation is intended to suit monitoring a kubernetes cluster the chart is deployed onto. It closely matches the kube-prometheus project.
service monitors to scrape internal kubernetes components
kube-apiserver
kube-scheduler
kube-controller-manager
etcd
kube-dns/coredns
kube-proxy
With the installation, the chart also includes dashboards and alerts.
Deployment steps:
Add the below grafana init container parameters to your env config file
Chose your env config file, if you are deploying monitoring and alerting into the qa environment chose qa.yaml similarly for uat, dev, and other environments.
Depending upon your environment config file update the configs repo branch (like for qa.yaml add qa branch and uat.yaml it would be UAT the branch)
2. Add monitoring-dashboards folder to the configs repo's branch which you selected in 1st step.
3. Enable the serviceMonitor in the nginx-ingress configs which are available in the same <env>.yaml and redeploy the nginx-ingress.
go run main.go deploy -e <environment_name> -c 'nginx-ingress'
4. To enable alerting, Add alertmanager secret in <env>-secrets.yaml
If you want you can change the slack channel and other details like group_wait, group_interval, and repeat_interval according to your values.
![](https://core.digit.org/~gitbook/image?url=https%3A%2F%2F4016629814-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FX13sH0e4xi7bV1juDmGX%252Fuploads%252FVCRiKUv6eowPrhc62u4j%252Fimage.png%3Falt%3Dmedia%26token%3D8ad9e108-a828-4298-b8c6-3d1840ecc08e&width=768&dpr=4&quality=100&sign=fb87fb99&sv=1)
5. You can deploy the prometheus-operator using one of the below methods.
1. Deploy using go lang deployer
go run main.go deploy -e <environment_name> -c 'prometheus-operator,grafana,prometheus-kafka-exporter'
2. Deploy using Jenkin’s deployment job. (here we are using deploy-to-dev, you can choose your environment specific deployment job )
![](https://core.digit.org/~gitbook/image?url=https%3A%2F%2F4016629814-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FX13sH0e4xi7bV1juDmGX%252Fuploads%252FzeEDfZqccpKNfzTmkHGK%252Fimage.png%3Falt%3Dmedia%26token%3D23980983-a47e-488c-81ff-1e5e9908289b&width=768&dpr=4&quality=100&sign=ef8aa73d&sv=1)
You can connect to the monitoring console at https://<your_domin_name>/monitoring/
To create a new panel in the existing dashboard:-
Login to the dashboard and click on add panel
![](https://core.digit.org/~gitbook/image?url=https%3A%2F%2F4016629814-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FX13sH0e4xi7bV1juDmGX%252Fuploads%252FbQrNDpGnRLQxdVEGXu2g%252Fimage.png%3Falt%3Dmedia%26token%3D98fc7d75-a31c-4684-983b-414ff03b56a2&width=768&dpr=4&quality=100&sign=25c449fb&sv=1)
Set all required queries and apply the changes. Export the JSON file by clicking on the save dashboard
![](https://core.digit.org/~gitbook/image?url=https%3A%2F%2F4016629814-files.gitbook.io%2F%7E%2Ffiles%2Fv0%2Fb%2Fgitbook-x-prod.appspot.com%2Fo%2Fspaces%252FX13sH0e4xi7bV1juDmGX%252Fuploads%252FzWL5LzMozVf4pE736o46%252Fimage.png%3Falt%3Dmedia%26token%3Dd4ef8402-be09-477d-9dc3-0622932e256c&width=768&dpr=4&quality=100&sign=e6177ed2&sv=1)
3. Go to the configs repo and select your branch. In the branch look for the monitoring-dashboards folder and update the existing *-dashboard.json with a newly exported JSON file.
Last updated