Skip to content

Commit ba4ca05

Browse files
authored
Merge pull request #67608 from bburt-rh/OBSDOCS-552-config-content-for-coo-tech-preview
OBSDOCS-552: sample service config for Cluster Observability Operator tech preview
2 parents 4b2aa93 + bb1a882 commit ba4ca05

5 files changed

+249
-0
lines changed

_topic_maps/_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,6 +2620,8 @@ Topics:
26202620
File: cluster-observability-operator-overview
26212621
- Name: Installing the Cluster Observability Operator
26222622
File: installing-the-cluster-observability-operator
2623+
- Name: Configuring the Cluster Observability Operator to monitor a service
2624+
File: configuring-the-cluster-observability-operator-to-monitor-a-service
26232625
---
26242626
Name: Network Observability
26252627
Dir: network_observability
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// Module included in the following assemblies:
2+
//
3+
// monitoring/cluster-observability-operator/configuring-the-cluster-observability-operator-to-monitor-a-service.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="creating-a-monitoringstack-object-for-cluster-observability-operator_{context}"]
7+
= Creating a MonitoringStack object for the Cluster Observability Operator
8+
9+
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.
10+
This `MonitoringStack` object can then discover the service and scrape the exposed metrics data from it.
11+
12+
.Prerequisites
13+
14+
* 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.
15+
* You have installed the Cluster Observability Operator.
16+
* You have deployed the `prometheus-coo-example-app` sample service in the `ns1-coo` namespace.
17+
* You have created a `ServiceMonitor` object named `prometheus-coo-example-monitor` in the `ns1-coo` namespace.
18+
19+
.Procedure
20+
21+
. Create a YAML file for the `MonitoringStack` object configuration. For this example, name the file `example-coo-monitoring-stack.yaml`.
22+
23+
. Add the following `MonitoringStack` object configuration details:
24+
+
25+
.Example `MonitoringStack` object
26+
+
27+
[source,yaml]
28+
----
29+
apiVersion: monitoring.rhobs/v1alpha1
30+
kind: MonitoringStack
31+
metadata:
32+
name: example-coo-monitoring-stack
33+
namespace: ns1-coo
34+
spec:
35+
logLevel: debug
36+
retention: 1d
37+
resourceSelector:
38+
matchLabels:
39+
k8s-app: prometheus-coo-example-monitor
40+
----
41+
42+
. Apply the `MonitoringStack` object by running the following command:
43+
+
44+
[source,terminal]
45+
----
46+
$ oc apply -f example-coo-monitoring-stack.yaml
47+
----
48+
49+
. Verify that the `MonitoringStack` object is available by running the following command and inspecting the output:
50+
+
51+
[source,terminal]
52+
----
53+
$ oc -n ns1-coo get monitoringstack
54+
----
55+
+
56+
.Example output
57+
[source,terminal]
58+
----
59+
NAME AGE
60+
example-coo-monitoring-stack 81m
61+
----
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Module included in the following assemblies:
2+
//
3+
// monitoring/cluster-observability-operator/configuring-the-cluster-observability-operator-to-monitor-a-service.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="deploying-a-sample-service-for-cluster-observability-operator_{context}"]
7+
= Deploying a sample service for Cluster Observability Operator
8+
9+
This configuration deploys a sample service named `prometheus-coo-example-app` in the user-defined `ns1-coo` project.
10+
The service exposes the custom `version` metric.
11+
12+
.Prerequisites
13+
14+
* 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.
15+
16+
.Procedure
17+
18+
. Create a YAML file named `prometheus-coo-example-app.yaml` that contains the following configuration details for a namespace, deployment, and service:
19+
+
20+
[source,yaml]
21+
----
22+
apiVersion: v1
23+
kind: Namespace
24+
metadata:
25+
name: ns1-coo
26+
---
27+
apiVersion: apps/v1
28+
kind: Deployment
29+
metadata:
30+
labels:
31+
app: prometheus-coo-example-app
32+
name: prometheus-coo-example-app
33+
namespace: ns1-coo
34+
spec:
35+
replicas: 1
36+
selector:
37+
matchLabels:
38+
app: prometheus-coo-example-app
39+
template:
40+
metadata:
41+
labels:
42+
app: prometheus-coo-example-app
43+
spec:
44+
containers:
45+
- image: ghcr.io/rhobs/prometheus-example-app:0.4.1
46+
imagePullPolicy: IfNotPresent
47+
name: prometheus-coo-example-app
48+
---
49+
apiVersion: v1
50+
kind: Service
51+
metadata:
52+
labels:
53+
app: prometheus-coo-example-app
54+
name: prometheus-coo-example-app
55+
namespace: ns1-coo
56+
spec:
57+
ports:
58+
- port: 8080
59+
protocol: TCP
60+
targetPort: 8080
61+
name: web
62+
selector:
63+
app: prometheus-coo-example-app
64+
type: ClusterIP
65+
----
66+
67+
. Save the file.
68+
69+
. Apply the configuration to the cluster by running the following command:
70+
+
71+
[source,terminal]
72+
----
73+
$ oc apply -f prometheus-coo-example-app.yaml
74+
----
75+
76+
. Verify that the pod is running by running the following command and observing the output:
77+
+
78+
[source,terminal]
79+
----
80+
$ oc -n -ns1-coo get pod
81+
----
82+
+
83+
.Example output
84+
[source,terminal]
85+
----
86+
NAME READY STATUS RESTARTS AGE
87+
prometheus-coo-example-app-0927545cb7-anskj 1/1 Running 0 81m
88+
----
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Module included in the following assemblies:
2+
//
3+
// monitoring/cluster-observability-operator/configuring-the-cluster-observability-operator-to-monitor-a-service.adoc
4+
5+
:_mod-docs-content-type: PROCEDURE
6+
[id="specifying-how-a-service-is-monitored-by-cluster-observability-operator_{context}"]
7+
= Specifying how a service is monitored by Cluster Observability Operator
8+
9+
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.
10+
11+
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.
12+
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.
13+
14+
This procedure shows how to create a `ServiceMonitor` object for a sample service named `prometheus-coo-example-app` in the `ns1-coo` namespace.
15+
16+
.Prerequisites
17+
18+
* 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.
19+
* You have installed the Cluster Observability Operator.
20+
* You have deployed the `prometheus-coo-example-app` sample service in the `ns1-coo` namespace.
21+
+
22+
[NOTE]
23+
====
24+
The `prometheus-coo-example-app` sample service does not support TLS authentication.
25+
====
26+
27+
.Procedure
28+
29+
. Create a YAML file named `example-coo-app-service-monitor.yaml` that contains the following `ServiceMonitor` object configuration details:
30+
+
31+
[source,yaml]
32+
----
33+
apiVersion: monitoring.rhobs/v1alpha1
34+
kind: ServiceMonitor
35+
metadata:
36+
labels:
37+
k8s-app: prometheus-coo-example-monitor
38+
name: prometheus-coo-example-monitor
39+
namespace: ns1-coo
40+
spec:
41+
endpoints:
42+
- interval: 30s
43+
port: web
44+
scheme: http
45+
selector:
46+
matchLabels:
47+
app: prometheus-coo-example-app
48+
----
49+
+
50+
This configuration defines a `ServiceMonitor` object that the `MonitoringStack` object will reference to scrape the metrics data exposed by the `prometheus-coo-example-app` sample service.
51+
52+
. Apply the configuration to the cluster by running the following command:
53+
+
54+
[source,terminal]
55+
----
56+
$ oc apply -f example-app-service-monitor.yaml
57+
----
58+
59+
. Verify that the `ServiceMonitor` resource is created by running the following command and observing the output:
60+
+
61+
[source,terminal]
62+
----
63+
$ oc -n ns1-coo get servicemonitor
64+
----
65+
+
66+
.Example output
67+
[source,terminal]
68+
----
69+
NAME AGE
70+
prometheus-coo-example-monitor 81m
71+
----
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
:_mod-docs-content-type: ASSEMBLY
2+
[id="configuring-the-cluster-observability-operator-to-monitor-a-service"]
3+
= Configuring the Cluster Observability Operator to monitor a service
4+
include::_attributes/common-attributes.adoc[]
5+
:context: configuring_the_cluster_observability_operator_to_monitor_a_service
6+
7+
toc::[]
8+
9+
:FeatureName: The Cluster Observability Operator
10+
include::snippets/technology-preview.adoc[leveloffset=+2]
11+
12+
You can monitor metrics for a service by configuring monitoring stacks managed by the Cluster Observability Operator (COO).
13+
14+
To test monitoring a service, follow these steps:
15+
16+
* Deploy a sample service that defines a service endpoint.
17+
* Create a `ServiceMonitor` object that specifies how the service is to be monitored by the COO.
18+
* Create a `MonitoringStack` object to discover the `ServiceMonitor` object.
19+
20+
// Deploy a sample service for Cluster Observability Operator
21+
include::modules/monitoring-deploying-a-sample-service-for-cluster-observability-operator.adoc[leveloffset=+1]
22+
23+
// Specify how the sample COO service is monitored
24+
include::modules/monitoring-specifying-how-a-service-is-monitored-by-cluster-observability-operator.adoc[leveloffset=+1]
25+
26+
// Create a MonitoringStack object to discover the service monitor
27+
include::modules/monitoring-creating-a-monitoringstack-object-for-cluster-observability-operator.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)