Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Installing Red Hat OpenShift Cluster Observability Operator
Installing and configuring the Cluster Observability Operator.
Abstract
Chapter 1. Installing the Cluster Observability Operator Link kopierenLink in die Zwischenablage kopiert!
As a cluster administrator, you can install or remove the Cluster Observability Operator (COO) from OperatorHub by using the OpenShift Container Platform web console. OperatorHub is a user interface that works in conjunction with Operator Lifecycle Manager (OLM), which installs and manages Operators on a cluster.
1.1. Installing the Cluster Observability Operator in the web console Link kopierenLink in die Zwischenablage kopiert!
Install the Cluster Observability Operator (COO) from OperatorHub by using the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role. - You have logged in to the OpenShift Container Platform web console.
Procedure
- In the OpenShift Container Platform web console, click Operators → OperatorHub.
-
Type
cluster observability operator
in the Filter by keyword box. - Click Cluster Observability Operator in the list of results.
Read the information about the Operator, and configure the following installation settings:
- Update channel → stable
- Version → 1.0.0 or later
- Installation mode → All namespaces on the cluster (default)
- Installed Namespace → Operator recommended Namespace: openshift-cluster-observability-operator
- Select Enable Operator recommended cluster monitoring on this Namespace
- Update approval → Automatic
- Optional: You can change the installation settings to suit your requirements. For example, you can select to subscribe to a different update channel, to install an older released version of the Operator, or to require manual approval for updates to new versions of the Operator.
- Click Install.
Verification
- Go to Operators → Installed Operators, and verify that the Cluster Observability Operator entry appears in the list.
Additional resources
1.2. Uninstalling the Cluster Observability Operator using the web console Link kopierenLink in die Zwischenablage kopiert!
If you have installed the Cluster Observability Operator (COO) by using OperatorHub, you can uninstall it in the OpenShift Container Platform web console.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role. - You have logged in to the OpenShift Container Platform web console.
Procedure
- Go to Operators → Installed Operators.
- Locate the Cluster Observability Operator entry in the list.
-
Click
for this entry and select Uninstall Operator.
Verification
- Go to Operators → Installed Operators, and verify that the Cluster Observability Operator entry no longer appears in the list.
Chapter 2. Configuring the Cluster Observability Operator to monitor a service Link kopierenLink in die Zwischenablage kopiert!
You can monitor metrics for a service by configuring monitoring stacks managed by the Cluster Observability Operator (COO).
To test monitoring a service, follow these steps:
- Deploy a sample service that defines a service endpoint.
-
Create a
ServiceMonitor
object that specifies how the service is to be monitored by the COO. -
Create a
MonitoringStack
object to discover theServiceMonitor
object.
2.1. Deploying a sample service for Cluster Observability Operator Link kopierenLink in die Zwischenablage kopiert!
This configuration deploys a sample service named prometheus-coo-example-app
in the user-defined ns1-coo
project. The service exposes the custom version
metric.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role or as a user with administrative permissions for the namespace.
Procedure
Create a YAML file named
prometheus-coo-example-app.yaml
that contains the following configuration details for a namespace, deployment, and service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the file.
Apply the configuration to the cluster by running the following command:
oc apply -f prometheus-coo-example-app.yaml
$ oc apply -f prometheus-coo-example-app.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the pod is running by running the following command and observing the output:
oc -n ns1-coo get pod
$ oc -n ns1-coo get pod
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME READY STATUS RESTARTS AGE prometheus-coo-example-app-0927545cb7-anskj 1/1 Running 0 81m
NAME READY STATUS RESTARTS AGE prometheus-coo-example-app-0927545cb7-anskj 1/1 Running 0 81m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2. Specifying how a service is monitored by Cluster Observability Operator Link kopierenLink in die Zwischenablage kopiert!
To use the metrics exposed by the sample service you created in the "Deploying a sample service for Cluster Observability Operator" section, you must configure monitoring components to scrape metrics from the /metrics
endpoint.
You can create this configuration by using a ServiceMonitor
object that specifies how the service is to be monitored, or a PodMonitor
object that specifies how a pod is to be monitored. The ServiceMonitor
object requires a Service
object. The PodMonitor
object does not, which enables the MonitoringStack
object to scrape metrics directly from the metrics endpoint exposed by a pod.
This procedure shows how to create a ServiceMonitor
object for a sample service named prometheus-coo-example-app
in the ns1-coo
namespace.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role or as a user with administrative permissions for the namespace. - You have installed the Cluster Observability Operator.
You have deployed the
prometheus-coo-example-app
sample service in thens1-coo
namespace.NoteThe
prometheus-coo-example-app
sample service does not support TLS authentication.
Procedure
Create a YAML file named
example-coo-app-service-monitor.yaml
that contains the followingServiceMonitor
object configuration details:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This configuration defines a
ServiceMonitor
object that theMonitoringStack
object will reference to scrape the metrics data exposed by theprometheus-coo-example-app
sample service.Apply the configuration to the cluster by running the following command:
oc apply -f example-coo-app-service-monitor.yaml
$ oc apply -f example-coo-app-service-monitor.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the
ServiceMonitor
resource is created by running the following command and observing the output:oc -n ns1-coo get servicemonitors.monitoring.rhobs
$ oc -n ns1-coo get servicemonitors.monitoring.rhobs
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE prometheus-coo-example-monitor 81m
NAME AGE prometheus-coo-example-monitor 81m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Creating a MonitoringStack object for the Cluster Observability Operator Link kopierenLink in die Zwischenablage kopiert!
To scrape the metrics data exposed by the target prometheus-coo-example-app
service, create a MonitoringStack
object that references the ServiceMonitor
object you created in the "Specifying how a service is monitored for Cluster Observability Operator" section. This MonitoringStack
object can then discover the service and scrape the exposed metrics data from it.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role or as a user with administrative permissions for the namespace. - You have installed the Cluster Observability Operator.
-
You have deployed the
prometheus-coo-example-app
sample service in thens1-coo
namespace. -
You have created a
ServiceMonitor
object namedprometheus-coo-example-monitor
in thens1-coo
namespace.
Procedure
-
Create a YAML file for the
MonitoringStack
object configuration. For this example, name the fileexample-coo-monitoring-stack.yaml
. Add the following
MonitoringStack
object configuration details:Example
MonitoringStack
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
MonitoringStack
object by running the following command:oc apply -f example-coo-monitoring-stack.yaml
$ oc apply -f example-coo-monitoring-stack.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the
MonitoringStack
object is available by running the following command and inspecting the output:oc -n ns1-coo get monitoringstack
$ oc -n ns1-coo get monitoringstack
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
NAME AGE example-coo-monitoring-stack 81m
NAME AGE example-coo-monitoring-stack 81m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Run the following comand to retrieve information about the active targets from Prometheus and filter the output to list only targets labeled with
app=prometheus-coo-example-app
. This verifies which targets are discovered and actively monitored by Prometheus with this specific label.oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/targets' | jq '.data.activeTargets[].discoveredLabels | select(.__meta_kubernetes_endpoints_label_app=="prometheus-coo-example-app")'
$ oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/targets' | jq '.data.activeTargets[].discoveredLabels | select(.__meta_kubernetes_endpoints_label_app=="prometheus-coo-example-app")'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThe above example uses
jq
command-line JSON processor to format the output for convenience.
2.4. Validating the monitoring stack Link kopierenLink in die Zwischenablage kopiert!
To validate that the monitoring stack is working correctly, access the example service and then view the gathered metrics.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role or as a user with administrative permissions for the namespace. - You have installed the Cluster Observability Operator.
-
You have deployed the
prometheus-coo-example-app
sample service in thens1-coo
namespace. -
You have created a
ServiceMonitor
object namedprometheus-coo-example-monitor
in thens1-coo
namespace. -
You have created a
MonitoringStack
object namedexample-coo-monitoring-stack
in thens1-coo
namespace.
Procedure
Create a route to expose the example
prometheus-coo-example-app
service. From your terminal, run the command:oc expose svc prometheus-coo-example-app -n ns1-coo
$ oc expose svc prometheus-coo-example-app -n ns1-coo
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Access the route from your browser, or command line, to generate metrics.
Execute a query on the Prometheus pod to return the total HTTP requests metric:
oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/query?query=http_requests_total'
$ oc -n ns1-coo exec -c prometheus prometheus-example-coo-monitoring-stack-0 -- curl -s 'http://localhost:9090/api/v1/query?query=http_requests_total'
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output (formatted using
jq
for convenience)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.5. Scrape targets in multiple namespaces Link kopierenLink in die Zwischenablage kopiert!
To scrape targets in multiple namespaces, set the namespace and resource selector in the MonitoringStack
object.
Prerequisites
-
You have access to the cluster as a user with the
cluster-admin
cluster role or as a user with administrative permissions for the namespace. - You have installed the Cluster Observability Operator.
Procedure
Deploy the following namespace object and
MonitoringStack
YAML file:Example
MonitoringStack
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy a sample application in the namespace
ns1-coo
, with an alert that is always firing:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the same example application in another namespace labeled with
monitoring.rhobs/stack: multi-ns
:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the Prometheus instance adds new targets and that the alert are firing. Use a port-forward command to expose the Prometheus or the Alertmanager user interface that has been deployed by the
Monitoringstack
instance.Prometheus
oc port-forward -n ns1-coo pod/prometheus-example-coo-monitoring-stack-0 9090
$ oc port-forward -n ns1-coo pod/prometheus-example-coo-monitoring-stack-0 9090
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Alertmanager
oc port-forward -n ns1-coo pod/alertmanager-example-coo-monitoring-stack-0 9093
$ oc port-forward -n ns1-coo pod/alertmanager-example-coo-monitoring-stack-0 9093
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Verify that the targets are being scraped and that the alerts are firing by browsing to
http://localhost:9090/targets
orhttp://localhost:9093/#/alerts
.