-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add the user workload monitoring documentation #18788
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
sheriff-rh
merged 16 commits into
openshift:master
from
rh-max:enterprise-4.3-monitoring-user-workload
Jan 21, 2020
Merged
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f8228c3
Add the user workload monitoring documentation
rh-max ebf7d34
Remove two xrefs
rh-max 7fe68bc
Move an xref from a module to the assembly
rh-max b89b91e
Fix an xref
rh-max 2d46784
Small fixes
rh-max b4dc611
Various improvements
rh-max 088fed1
Add a separate procedure for creating a ServiceMonitor
rh-max f79f615
Add the procedure for creating an alerting rule
rh-max 264938e
Add a detail on how user workload monitoring is enabled
rh-max 6842469
Some additional information on admins and developers
rh-max 4b9c816
s/User workload monitoring/Monitoring your own services/ + many changes
rh-max 1d88b7a
Many changes
rh-max dfedefe
Add a section on giving view permissions; many changes
rh-max 63f08aa
Add a clarification
rh-max a3186c6
Add two notes, fix a link name
rh-max 319b232
Add link to API docs
rh-max File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * monitoring/user-workload-monitoring.adoc | ||
|
|
||
| [id="accessing-user-workload-metrics_{context}"] | ||
| = Accessing user workload metrics | ||
|
|
||
| Once you have enabled user workload monitoring, deployed the workload, and, optionally, gave additional view permissions, you can access the custom metrics as the cluster administrator, as a developer, or as another user with permissions. | ||
|
|
||
| .Prerequisites | ||
|
|
||
| * You need to have deployed the workload that you want to monitor, such as an application or a service. This example uses the application described in "Deploying a sample application". | ||
| * You need to have user workload monitoring enabled. | ||
| * If accessing metrics as an arbitrary user, the user needs to have the permissions as described in "Granting a user access to metrics". | ||
|
|
||
| .Procedure | ||
|
|
||
| . Access the Prometheus web interface: | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
| + | ||
| * To access the metrics as a cluster administrator, go to the OpenShift Container Platform web console, switch to the Administrator Perspective, and click *Monitoring* -> *Metrics*. | ||
|
rh-max marked this conversation as resolved.
Outdated
rh-max marked this conversation as resolved.
Outdated
|
||
| * To access the metrics as a developer or a user with permissions, go to the OpenShift Container Platform web console, switch to the Developer Perspective, then click *Advanced* -> *Metrics*. Select the project where the user workload resides. | ||
|
rh-max marked this conversation as resolved.
Outdated
rh-max marked this conversation as resolved.
Outdated
|
||
| . Use the PromQL interface to run queries for user workload metrics. This works the same as with cluster metrics queries. | ||
|
|
||
| .Additional resources | ||
|
|
||
| * See the xref:../monitoring/cluster-monitoring/examining-cluster-metrics.adoc#examining-cluster-metrics[section on using the PromQL interface]. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * monitoring/user-workload-monitoring.adoc | ||
|
|
||
| [id="deploying-a-sample-application_{context}"] | ||
| = Deploying a sample application | ||
|
|
||
| To test user workload monitoring, you can deploy a sample application. | ||
|
|
||
| .Procedure | ||
|
|
||
| . Create a YAML file for the application configuration. In this example, it is called `prometheus-example-app.yaml`. | ||
|
|
||
| . Fill the file with the configuration for deploying the application: | ||
| + | ||
| [source,yaml] | ||
| ---- | ||
|
rh-max marked this conversation as resolved.
|
||
| apiVersion: v1 | ||
| kind: Namespace | ||
| metadata: | ||
| name: ns1 | ||
| --- | ||
| apiVersion: extensions/v1beta1 | ||
| kind: Deployment | ||
| metadata: | ||
| labels: | ||
| app: prometheus-example-app | ||
| name: prometheus-example-app | ||
| namespace: ns1 | ||
| spec: | ||
| replicas: 1 | ||
| selector: | ||
| matchLabels: | ||
| app: prometheus-example-app | ||
| template: | ||
| metadata: | ||
| labels: | ||
| app: prometheus-example-app | ||
| spec: | ||
| containers: | ||
| - image: quay.io/brancz/prometheus-example-app:v0.1.0 | ||
| imagePullPolicy: IfNotPresent | ||
| name: prometheus-example-app | ||
| --- | ||
| apiVersion: v1 | ||
| kind: Service | ||
| metadata: | ||
| labels: | ||
| app: prometheus-example-app | ||
| name: prometheus-example-app | ||
| namespace: ns1 | ||
| spec: | ||
| ports: | ||
| - port: 8080 | ||
| protocol: TCP | ||
| targetPort: 8080 | ||
| name: web | ||
| selector: | ||
| app: prometheus-example-app | ||
| type: ClusterIP | ||
| --- | ||
| apiVersion: monitoring.coreos.com/v1 | ||
| kind: ServiceMonitor | ||
| metadata: | ||
| labels: | ||
| k8s-app: prometheus-example-monitor | ||
| name: prometheus-example-monitor | ||
| namespace: ns1 | ||
| spec: | ||
| endpoints: | ||
| - interval: 30s | ||
| port: web | ||
| scheme: http | ||
| selector: | ||
| matchLabels: | ||
| app: prometheus-example-app | ||
| ---- | ||
| + | ||
| This configuration deploys an application named `prometheus-example-app` in the `ns1` namespace. This application exposes the custom `version` metric. | ||
|
|
||
| . Apply the configuration file to the cluster: | ||
| + | ||
| ---- | ||
| $ oc apply -f prometheus-example-app.yaml | ||
| ---- | ||
| + | ||
| It will take some time to deploy the application. | ||
|
|
||
| . You can check that the application is running and exposing metrics: | ||
| + | ||
| ---- | ||
| $ oc -n ns1 get pod | ||
| NAME READY STATUS RESTARTS AGE | ||
| prometheus-example-app-7857545cb7-sbgwq 1/1 Running 0 81m | ||
|
|
||
| $ oc -n ns1 get servicemonitor | ||
| NAME AGE | ||
| prometheus-example-monitor 81m | ||
| ---- | ||
|
rh-max marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * monitoring/user-workload-monitoring.adoc | ||
|
|
||
| [id="enabling-user-workload-monitoring_{context}"] | ||
| = Enabling user workload monitoring | ||
|
|
||
| You can enable user workload monitoring using the cluster monitoring ConfigMap. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
|
|
||
| .Prerequisites | ||
|
|
||
| * Make sure you have the `cluster-monitoring-config` ConfigMap object with the `data/config.yaml` section. | ||
|
|
||
| .Procedure | ||
|
|
||
| . Start editing the `cluster-monitoring-config` ConfigMap: | ||
| + | ||
| ---- | ||
| $ oc -n openshift-monitoring edit configmap cluster-monitoring-config | ||
| ---- | ||
|
|
||
| . Set the `techPreviewUserWorkload` setting to `true` under `data/config.yaml`: | ||
| + | ||
| ---- | ||
| apiVersion: v1 | ||
| kind: ConfigMap | ||
| metadata: | ||
| name: cluster-monitoring-config | ||
| namespace: openshift-monitoring | ||
| data: | ||
| config.yaml: | | ||
| techPreviewUserWorkload: | ||
| enabled: true | ||
| ---- | ||
|
|
||
| . Save the file to apply the changes. The user workload monitoring is enabled automatically. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
|
|
||
| .Additional resources | ||
|
|
||
| * See xref:../monitoring/cluster-monitoring/configuring-the-monitoring-stack.adoc#configuring-the-monitoring-stack[Configuring the monitoring stack] to learn how to create `cluster-monitoring-config`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * monitoring/cluster-monitoring/examining-cluster-metrics.adoc | ||
|
|
||
| [id="examining-metrics-as-a-developer_{context}"] | ||
| = Examining metrics as a developer | ||
|
|
||
| You might enable user workload monitoring for an application or service in a project. In that case, a developer of that project can examine the exposed custom metrics using the Developer Perspective in the Web console. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
|
|
||
| :FeatureName: Examining metrics using the Developer Perspective | ||
| include::modules/technology-preview.adoc[leveloffset=+0] | ||
|
|
||
| .Procedure | ||
|
|
||
| . Open the {product-title} Web console, switch to the Developer Perspective, and navigate to the *Advanced* -> *Metrics* page. Select the project where the user workload resides. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
| + | ||
| image::monitoring-metrics-developer.png[] | ||
|
|
||
| . Now you can work with custom metrics in the same way as with cluster metrics. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Module included in the following assemblies: | ||
| // | ||
| // * monitoring/user-workload-monitoring.adoc | ||
|
|
||
| [id="granting-a-user-access-to-metrics_{context}"] | ||
| = Granting a user access to metrics | ||
|
|
||
| By default, only cluster administrator users have access to user workload metrics. Using the soft tenancy feature, you can also grant metrics access to an arbitrary user, who only has access to a particular project. | ||
|
|
||
| .Prerequisites | ||
|
|
||
| * You need to have deployed the workload that you want to monitor, such as an application or a service. This example uses the application described in xref:../monitoring/user-workload-monitoring.adoc#deploying-a-sample-application[Deploying a sample application]. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
| * You need to have user workload monitoring enabled. | ||
| * You need to have a user created. For the sake of an example, you can create the `johnsmith` user by running `oc create user johnsmith`. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
|
|
||
| .Procedure | ||
|
|
||
| . In the Web console, navigate to *User Management* -> *Role Bindings* -> *Create Binding*. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
| . In the *Role Name* field, enter `cluster-monitoring-view`. | ||
| . In the *Subject Name* enter name of the user, for example `johnsmith`. | ||
| . Confirm the role binding. Now the user has been assigned the `cluster-monitoring-view` role, which allows him to access the metrics. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [id="user-workload-monitoring"] | ||
| = User workload monitoring | ||
| include::modules/common-attributes.adoc[] | ||
| :context: user-workload-monitoring | ||
|
|
||
| toc::[] | ||
|
|
||
| You can use the Prometheus Cluster Monitoring stack to monitor your applications, services, or other custom workloads in addition to monitoring the cluster. This way, you do not need to use an additional monitoring solution. This helps keeping monitoring centralized. | ||
| Additionally, you can extend the access to the custom metrics beyond cluster administrators. This enables developers and arbitrary users to access the metrics. | ||
|
rh-max marked this conversation as resolved.
Outdated
|
||
|
|
||
| :FeatureName: User workload monitoring | ||
| include::modules/technology-preview.adoc[leveloffset=+0] | ||
|
|
||
| include::modules/monitoring-enabling-user-workload-monitoring.adoc[leveloffset=+1] | ||
| include::modules/monitoring-deploying-a-sample-application.adoc[leveloffset=+1] | ||
| include::modules/monitoring-granting-a-user-access-to-metrics.adoc[leveloffset=+1] | ||
| include::modules/monitoring-accessing-user-workload-metrics.adoc[leveloffset=+1] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.