Creating Application Alerts#
Overview#
There are 2 types of monitoring:
- Infrastructure monitoring (comes default with OpenShift installation)
- User Workload monitoring (it can be enabled)
Enabling monitoring for user-defined projects#
Cluster administrators can enable monitoring for user-defined projects by setting the enableUserWorkload: true
field in the cluster monitoring ConfigMap object.
apiVersion: v1
kind: ConfigMap
metadata:
name: cluster-monitoring-config
namespace: openshift-monitoring
data:
config.yaml: |
enableUserWorkload: true
Excluding a user-defined project from monitoring#
Individual user-defined projects can be excluded from user workload monitoring. To do so, simply add the openshift.io/user-monitoring
label to the project's namespace with a value of false.
Add the label to the project namespace:
Infrastructure Monitoring#
- Prometheus
- Grafana
- Alertmanager
User Workload Monitoring#
- Prometheus
- Grafana
- Alertmanager
Creating Application Alerts to Monitor Application workloads#
In order to define Prometheus rules to monitor applications on the basis of exposed metrics. You need 3 things:
- Metrics Exposed by Application endpoints
- Metrics endpoints are scraped via ServiceMonitor by Prometheus
- Defining PrometheusRule CustomResource
Metrics Exposed by the Application#
Prometheus metrics can be exposed on any endpoint from the application (usually /metrics
)
Metrics endpoints are scraped via ServiceMonitor by Prometheus#
The Prometheus Operator includes a Custom Resource Definition that allows the definition of the ServiceMonitor. The ServiceMonitor is used to define an application you wish to scrape metrics from, the controller will action the ServiceMonitors we define and automatically build the required Prometheus configuration.
Example ServiceMonitor:
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: example-svc-monitor
namespace: example-namespace
spec:
endpoints:
- interval: 30s
path: /metrics
port: metrics
selector:
matchLabels:
app: example-svc-label
Creating alerting rules for user-defined projects#
Creating alerting rules for user-defined projects You can create alerting rules for user-defined projects. Those alerting rules will fire alerts based on the values of chosen metrics.