Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

OpenShift Monitoring and Webhook Alert Notifications

March 3, 2025
Alessandro Arrichiello
Related topics:
KubernetesObservability
Related products:
Red Hat OpenShift Container Platform

Share:

    OpenShift Container Platform comes equipped with a powerful, pre-configured monitoring stack, built on the robust foundation of Prometheus and AlertManager. This allows cluster administrators to keep a close eye on the health and performance of core platform components, and even extend monitoring to user-defined projects. Let's break down the essentials.

    OpenShift Monitoring: A Quick Overview

    OpenShift's monitoring stack provides out-of-the-box visibility into your cluster's vital signs. It leverages key components like:

    • Prometheus: The heart of the system, storing time-series data and evaluating rules.
    • Alertmanager: Handles alerts from Prometheus, routing them to various notification systems.
    • Metrics Server: Collects resource metrics, making them available through the metrics.k8s.io API.
    • kube-state-metrics: Converts Kubernetes objects into metrics for Prometheus.
    • and others!

    This stack monitors crucial targets, including:

    • CoreDNS
    • etcd
    • HAProxy
    • Kubernetes API server
    • And many more...

    This comprehensive monitoring enables administrators to quickly identify and address potential issues, ensuring the stability and reliability of the OpenShift cluster.

    OpenShift Monitoring Architecture

    As you can see from the next diagram, OpenShift's monitoring architecture is structured into two primary components: default platform monitoring and user-defined project monitoring. 

    OpenShift Monitoring Architecture

    During installation, core cluster components, including Kubernetes services, are automatically monitored through a set of platform components deployed within the openshift-monitoring project, which also enables remote health monitoring. 

    For user-defined projects, once enabled, additional monitoring components are installed in the openshift-user-workload-monitoring project, extending monitoring capabilities to applications and services deployed by users.

    Alerting and Notifications: Keeping You Informed

    OpenShift's alerting capabilities are designed to keep you informed about critical events. Alertmanager plays a central role in this, allowing you to configure how alerts are routed and delivered. You can configure various alert receivers for different types of alerts.

    One of the most powerful features is the ability to configure webhooks for alert notifications. This allows you to integrate OpenShift alerts with external systems and services, automating responses and workflows.

    What types of alerts can we expect, and what format do the notifications follow?

    We will leverage a small application for receiving and storing the OpenShift Monitoring's Alerts.

    Building a Webhook Notification Receiver: A Simple Webhook Logger

    When configuring webhooks for alert notifications, it's crucial to understand the structure of the incoming webhook payload. This is where our small project comes in.

    To facilitate the development and testing of our real webhook notification receiver, I created a simple application that captures incoming webhooks and saves them as JSON files. This allows us to:

    • Inspect the structure and content of the webhook payload.
    • Develop and test any existing notification receiver we may have in our company.

    The application is a lightweight HTTP server that listens for incoming POST requests. When a webhook is received, it extracts the JSON payload and saves it to a file with a unique timestamp.

    The Application's core is less than 40 lines of Python code using the Flask, a lightweight web framework that enables developers to build web applications quickly and easily, you can see a small extract in the next code block:

    @app.route('/webhook', methods=['POST'])
    def webhook():
        try:
            data = request.get_json()  # Get the JSON data from the request
            now = datetime.now()
            date_str = now.strftime("%Y%m%d-%H%M%S")  # Format: YYYYMMDD-HHMMSS
            unique_id = uuid.uuid4()
            filename = f"{date_str}-{unique_id}.json"
            filepath = os.path.join(WEBHOOK_DIR, filename)
            # Write the JSON data to a file, formatted for readability
            with open(filepath, 'w') as f:
                json.dump(data, f, indent=4)  # indent=4 for human-readable formatting
            return jsonify({"message": "Webhook received and saved successfully"}), 200
        except Exception as e:
            return jsonify({"error": str(e)}), 500

    You can find the full Application code in the Github repository I created here: https://github.com/alezzandro/webhook-store.

    This approach provides a convenient way to analyze the webhook data and ensure that our receiver is prepared to handle it correctly.

    We are now ready to deploy it on our OpenShift cluster! Let's see how in the next section.

    Install the Python WebHook Receiver in our OpenShift cluster

    The Github repository of the application project is ready to be deployed on OpenShift, leveraging the Application Template's mechanism offered by the platform as a service layer.

    Let's first create an OpenShift project for this application:

    $ oc new-project webhook-store

    Then we can launch the application build and the Kubernetes resources' configuration by creating an OpenShift Application:

    $ oc new-app --name=webhook-store --labels="application=webhook-store-app"  python:3.9-ubi9~https://github.com/alezzandro/webhook-store 

    You can monitor the application deployment process by looking at the BuildConfig / Builds elements and at the Pods running in the Project.

    Finally let's expose the Service through the OpenShift's Ingress Controller (we are creating a Route object):

    $ oc expose service webhook-store -l application=webhook-store-app --name=webhook-store

    If the application's deployment completed successfully you should see something similar in your OpenShift Topology View:

    OCP Topology View - WebHook Store App

    That's all, you can test if the service is working properly by contacting the Route URL we just created also with a simple curl command. 

    Don't forget to copy the URL: We are going to configure the AlertManager forwarder/receiver in the next section!

    Please note: these steps don't require administrative privileges.

    OpenShift Monitoring's AlertManager Configuration

    Now that our application is started on the OpenShift cluster we can configure the AlertManager notification configuration to actually forward to our WebHook Store application any new Alert.

    We can navigate through the OpenShift Web Console to configure the webhook receivers in the respective section.

    First of all let's connect with administrative privileges, then let's navigate through the left bar in Administration -> Cluster Settings, then let's click on the Configuration tab as shown in the screenshot below:

    WebHook Store - Cluster Settings

    After that we need to click on the AlertManager element that we can find in the list.

    In the AlertManager's details page, we should see the list of the default receivers, as shown in the next screenshot:

    WebHook Store App - AlertManager Details Page

    We can now edit the Default receiver (or even both) for forwarding any new Alert to our WebHook Store application.

    As you can imagine and as you can see for the Routing Labels column, the Default receiver is actually getting all the Alerts, while the Critical one is just receiving the critical Alerts.

    Clicking the edit button in the right menu, you should see something similar to the next screenshot:

    WebHook Store - Edit Receiver

    As you can see from the previous screenshot we have a URL field in which we should paste our WebHook receiver endpoint. Don't forget to include the /webhook subpath in your URL!

    You can also take a look to the OpenShift Documentation page available here.

    Are you ready to test the webhook notification then?

    Testing the WebHook Store application with new incoming Alerts

    There are several way to actually test the Notification Alerts we just configured.

    If you are in a development / test cluster, for getting some real data you could try to shutdown one of the master and one of the worker nodes (in case you have enough machines to let the cluster survive the fault!).

    Consider also that the application does not request or mount any PersistentVolume, it just writes in a unique JSON file the webhook received in the /tmp/webhooks folder. For checking the current Alerts notification save you may want to jump directly in the WebHook Store running container through the OpenShift Web Console section.

    Alternatively you can leverage the command line tool "oc":

    $ oc project webhook-store
    $ oc rsh webhook-store-YOUR-ID

    For copying the saved JSON files out from your running container, again you could leverage the "oc" command line tool as shown in the next code block:

    $ oc rsync webhook-store-YOUR-ID:/tmp/webhooks/ .

    That's all you are now ready to start working with Alert Notifications in your OpenShift cluster. But in case you want a preview of what kind of of alerts we can expect, and what format the notifications follow you can take a look in the webhook-examples directory in the WebHook Store Application Gihub repository!

    This is an example of the Notification Alert you should get:

    {
        "receiver": "Default",
        "status": "firing",
        "alerts": [
            {
                "status": "firing",
                "labels": {
                    "alertname": "TargetDown",
                    "job": "etcd",
                    "namespace": "openshift-etcd",
                    "openshift_io_alert_source": "platform",
                    "prometheus": "openshift-monitoring/k8s",
                    "service": "etcd",
                    "severity": "warning"
                },
                "annotations": {
                    "description": "33.33% of the etcd/etcd targets in openshift-etcd namespace have been unreachable for more than 15 minutes. This may be a symptom of network connectivity issues, down nodes, or failures within these components. Assess the health of the infrastructure and nodes running these targets and then contact support.",
                    "runbook_url": "https://github.com/openshift/runbooks/blob/master/alerts/cluster-monitoring-operator/TargetDown.md",
                    "summary": "Some targets were not reachable from the monitoring server for an extended period of time."
                },
                "startsAt": "2025-02-28T12:12:19.03Z",
                "endsAt": "0001-01-01T00:00:00Z",
                "generatorURL": "https://console-openshift-console.apps.ocp.example.com/monitoring/graph?g0.expr=100+%2A+%28%281+-+sum+by+%28job%2C+namespace%2C+service%29+%28up+and+on+%28namespace%2C+pod%29+kube_pod_info%29+%2F+count+by+%28job%2C+namespace%2C+service%29+%28up+and+on+%28namespace%2C+pod%29+kube_pod_info%29%29+or+%28count+by+%28job%2C+namespace%2C+service%29+%28up+%3D%3D+0%29+%2F+count+by+%28job%2C+namespace%2C+service%29+%28up%29%29%29+%3E+10&g0.tab=1",
                "fingerprint": "22578b8bd796282b"
            }
        ],
        "groupLabels": {
            "namespace": "openshift-etcd"
        },
        "commonLabels": {
            "namespace": "openshift-etcd",
            "openshift_io_alert_source": "platform",
            "prometheus": "openshift-monitoring/k8s",
            "severity": "warning"
        },
        "commonAnnotations": {},
        "externalURL": "https://console-openshift-console.apps.ocp.example.com/monitoring",
        "version": "4",
        "groupKey": "{}:{namespace=\"openshift-etcd\"}",
        "truncatedAlerts": 0
    }

    As you can see it a well formatted JSON containing one or multiple Alerts. For further information you can also take a look to the AlertManager's docs available here.

    Conclusion

    OpenShift's monitoring and alerting capabilities provide a powerful toolkit for ensuring the health and stability of your cluster. By leveraging webhooks, you can integrate OpenShift alerts with external systems and automate responses. The simple application described in this post provides a practical approach to developing and testing your webhook notification receiver, ensuring that your existing tools will be ready to handle real-world alerts coming from OpenShift Container Platform.

    Last updated: March 4, 2025
    Disclaimer: Please note the content in this blog post has not been thoroughly reviewed by the Red Hat Developer editorial team. Any opinions expressed in this post are the author's own and do not necessarily reflect the policies or positions of Red Hat.

    Recent Posts

    • Create and enrich ServiceNow ITSM tickets with Ansible Automation Platform

    • Expand Model-as-a-Service for secure enterprise AI

    • OpenShift LACP bonding performance expectations

    • Build container images in CI/CD with Tekton and Buildpacks

    • How to deploy OpenShift AI & Service Mesh 3 on one cluster

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue