Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,21 @@ $ oc -n ns1-coo get pod
NAME READY STATUS RESTARTS AGE
prometheus-coo-example-app-0927545cb7-anskj 1/1 Running 0 81m
----

.Verification

To verify that the sample service has created a target and is returning metrics, follow these steps:

. Run the following command to verify that the `ServiceMonitor` object has created a target:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run the following command to verify that the promtheus object has discovered the target by ServiceMonitor


[source, terminal]
Copy link

@lihongyan1 lihongyan1 Jul 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To see the targets and query the metrics, you need create servicemonitor like

apiVersion: monitoring.rhobs/v1
kind: ServiceMonitor
metadata:
  labels:
    k8s-app: prometheus-coo-example-monitor
  name: prometheus-coo-example-monitor
spec:
  endpoints:
  - interval: 30s
    port: web
    scheme: http
  selector:
    matchLabels:
      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")'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing steps to create monitoringstack also

----

. Run the following command to verify that the service returns metrics when you query it:

[source, terminal]
----
$ 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' | jq

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found example app only expose the following metrics

          "__name__": "version",
          "__name__": "up",
          "__name__": "scrape_duration_seconds",
          "__name__": "scrape_samples_scraped",
          "__name__": "scrape_samples_post_metric_relabeling",
          "__name__": "scrape_series_added",

----