Monitoring your application¶
OpenShift supports monitoring via their User Workload Monitoring feature. You can expose metrics to Prometheus and configure alerts for them.
Creating a simple alerting rule¶
The simplest possible rule would be one where you monitor if a Deployment has enough healthy pods. The YAML looks like this:
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
name: myapp
spec:
groups:
- name: backend-monitoring-rules
rules:
- alert: Backend instances
annotations:
description: |
Checks if enough backend instances are available.
event: Backend instances
html: <h1>Backend instances</h1>
summary: Backend instances
expr: >
kube_deployment_status_replicas{namespace="YOURNAMESPACE",deployment="YOURDEPLOYMENT"} < 2
for: 5m
labels:
severity: minor
Note that during node maintenance individual pods may briefly restart. This is normal and your monitoring setup should account for that.
Alerting¶
You can, of course, use the instant messenger of your choice for monitoring, but we support alerting via Matrix out of the box. First, configure the TU Wien Hookshot service for your Matrix room, then apply the following alert rule:
apiVersion: monitoring.coreos.com/v1beta1
kind: AlertmanagerConfig
metadata:
name: myapp
spec:
receivers:
- name: matrix-webhook
webhookConfigs:
- sendResolved: true
url: >-
https://matrixproxy.arisnet.ac.at/hookshot/webhook/HOOKSHOTID_HERE
route:
groupBy:
- alertname
receiver: matrix-webhook
If you want to customize the Matrix message, you can deploy the proxy service in your own namespace.