Rancher 2.5.x monitoring and alerting with MS Teams
Posted on September 9, 2021 by Adrian Wyssmann ‐ 5 min read
Installing monitoring and configuration with Rancher is quite easy, but in combination wit alerting for MS Teams some guidance might be helpful. I guide you trough the process of the complete installation and configuration
Introduction
The rancher-monitoring
operator, introduced in Rancher v2.5, is powered by Prometheus, Grafana, Alertmanager, the Prometheus Operator, and the Prometheus adapter.
Rancher’s solution allows users to:
- Monitor the state and processes of your cluster nodes, Kubernetes components, and software deployments via Prometheus, a leading open-source monitoring solution.
- Define alerts based on metrics collected via Prometheus
- Create custom dashboards to make it easy to visualize collected metrics via Grafana
- Configure alert-based notifications via Email, Slack, PagerDuty, etc. using Prometheus Alertmanager
- Defines precomputed, frequently needed or computationally expensive expressions as new time series based on metrics collected via Prometheus (only available in 2.5)
- Expose collected metrics from Prometheus to the Kubernetes Custom Metrics API via Prometheus Adapter for use in HPA (only available in 2.5)
Installation of Monitoring
Install Operator
Go to “Apps & Marketplace” in “Cluster Explorer” and select “Monitoring”
Configure the monitoring as follows
Click on “Edit as YAML” and add the following to
prometheus.prometheusSpec.additionalScrapeConfigs
(see Rancher Docs: Selectors and Scrape Configs) to scrape traffic from istio-enabled namespaces.Optionally you may add Ingress configurations to the yaml, so developers can access it without going over the Rancher UI
Ingress for Grafana:
Ingress for Alertmanager
Ingress for Prometheus:
Click “Install”
Now we have all monitoring components installed and are ready to configure the alerting.
Configure Alerting for MS Teams
Incoming Webhooks in MS Teams
First you need to create a Incoming Webhook in your MS Teams “Team”. We name the connector as follows in order to see where it is used:
Container Platform Cluster "CONTEXT"
-CONTEXT
is the cluster name e.gDEV
:Copy the URL
Click Done
Install Alerting Drivers
As we are using MS teams the steps required are slightly different as if you would use Slack. This is due to the need of the need of rancher-alerting-drivers. Thus we have to do the following steps
Install “Alerting Drivers” via Apps & Marketplace, with the following options
- Chart Options:
[x] Enable Microsoft Teams
- Namespace:
cattle-monitoring-system
- Chart Options:
Configure
prom2teams
. You can do this either via the Rancher UI or as I prefer, to use a separate manifest file, as follows:Remarks
- The section
[Microsoft Teams]
in theconfig.ini
contains configurations for the Incoming Webhooks, using the url from the configuration in MS Teams - The
teams.j2
is slightly adjusted to the original one.
- The section
As we are sitting behind a proxy, we have to manually add the proxy configuration to the
rancher-alerting-drivers-prom2teams
deployment:You can check now if the setup works, using the following command:
If there is an issue, you would see it in the logs.
Add Receivers
Once the pods are running, one has to configure the Receivers - unfortunately this has to be done manually in the Rancher UI:
Yes, you can add routes and receivers via kubectl and base64 but it’s not recommended. They are stored in the alertmanager secrets under the cattle-monitoring namespace for Monitoring v2.
So we create for each incoming webhook a route, example:
Take attention on the url as this points to the rancher-alerting-drivers-prom2teams
-pod using the connection defined in the prom2teams
-configuration as explained above. Inthis case we use msteams-alert-1
.
Add Routes
At last we need a Route which tells which alerts shall appear in the channel. We want all default alerts in it, so we match the namespace: cattle-monitoring-system
:
And voilà, here you have your alerts: