Skip to content

Commit

Permalink
OBSDOCS-702: Clarify available endpoint auth methods in user workload…
Browse files Browse the repository at this point in the history
… monitoring
  • Loading branch information
eromanova97 committed May 15, 2024
1 parent 63b1d28 commit a920cdb
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions modules/monitoring-specifying-how-a-service-is-monitored.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
[id="specifying-how-a-service-is-monitored_{context}"]
= Specifying how a service is monitored

[role="_abstract"]
To use the metrics exposed by your service, you must configure {product-title} monitoring to scrape metrics from the `/metrics` endpoint. You can do this using a `ServiceMonitor` custom resource definition (CRD) that specifies how a service should be monitored, or a `PodMonitor` CRD that specifies how a pod should be monitored. The former requires a `Service` object, while the latter does not, allowing Prometheus to directly scrape metrics from the metrics endpoint exposed by a pod.

This procedure shows you how to create a `ServiceMonitor` resource for a service in a user-defined project.
Expand All @@ -29,30 +28,32 @@ The `prometheus-example-app` sample service does not support TLS authentication.

.Procedure

. Create a YAML file for the `ServiceMonitor` resource configuration. In this example, the file is called `example-app-service-monitor.yaml`.
. Create a new YAML configuration file named `example-app-service-monitor.yaml`.

. Add the following `ServiceMonitor` resource configuration details:
. Add a `ServiceMonitor` resource to the YAML file. The following example creates a service monitor named `prometheus-example-monitor`:
+
[source,yaml]
----
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
labels:
k8s-app: prometheus-example-monitor
name: prometheus-example-monitor
namespace: ns1
namespace: ns1 #<1>
spec:
endpoints:
- interval: 30s
- authorization:
credentials:
key: token
name: example
interval: 30s
port: web
scheme: http
selector:
selector: #<2>
matchLabels:
app: prometheus-example-app
----
+
This defines a `ServiceMonitor` resource that scrapes the metrics exposed by the `prometheus-example-app` sample service, which includes the `version` metric.
<1> Specify a user-defined namespace where you want the `ServiceMonitor` resource to run.
<2> Configure selector to specify the endpoints objects. This example scrapes the metrics exposed by the `prometheus-example-app` service.
+
[NOTE]
====
Expand All @@ -68,11 +69,11 @@ $ oc apply -f example-app-service-monitor.yaml
+
It takes some time to deploy the `ServiceMonitor` resource.

. You can check that the `ServiceMonitor` resource is running:
. Verify that the `ServiceMonitor` resource is running:
+
[source,terminal]
----
$ oc -n ns1 get servicemonitor
$ oc -n <namespace> get servicemonitor
----
+
.Example output
Expand Down

0 comments on commit a920cdb

Please sign in to comment.