Skip to content

Commit e82513f

Browse files
authored
Merge pull request #49065 from bburt-rh/RHDEVDOCS-4036-CMO-config-map-option-for-body-size-limit-b
RHDEVDoCS-4036 - CMO config map option for body size limit for metrics scraping
2 parents 2c357b3 + 8660706 commit e82513f

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed
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/configuring-the-monitoring-stack.adoc
4+
5+
:_content-type: PROCEDURE
6+
[id="setting-the-body-size-limit-for-metrics-scraping_{context}"]
7+
= Setting the body size limit for metrics scraping
8+
9+
By default, no limit exists for the uncompressed body size for data returned from scraped metrics targets.
10+
You can set a body size limit to help avoid situations in which Prometheus consumes excessive amounts of memory when scraped targets return a response that contains a large amount of data.
11+
In addition, by setting a body size limit, you can reduce the impact that a malicious target might have on Prometheus and on the cluster as a whole.
12+
13+
After you set a value for `enforcedBodySizeLimit`, the alert `PrometheusScrapeBodySizeLimitHit` fires when at least one Prometheus scrape target replies with a response body larger than the configured value.
14+
15+
[NOTE]
16+
====
17+
If metrics data scraped from a target has an uncompressed body size exceeding the configured size limit, the scrape fails.
18+
Prometheus then considers this target to be down and sets its `up` metric value to `0`, which can trigger the `TargetDown` alert.
19+
====
20+
21+
.Prerequisites
22+
23+
* You have access to the cluster as a user with the `cluster-admin` role.
24+
* You have installed the OpenShift CLI (`oc`).
25+
26+
.Procedure
27+
28+
. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` namespace:
29+
+
30+
[source,terminal]
31+
----
32+
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
33+
----
34+
35+
. Add a value for `enforcedBodySizeLimit` to `data/config.yaml/prometheusK8s` to limit the body size that can be accepted per target scrape:
36+
+
37+
[source,yaml]
38+
----
39+
apiVersion: v1
40+
kind: ConfigMap
41+
metadata:
42+
name: cluster-monitoring-config
43+
namespace: openshift-monitoring
44+
data:
45+
config.yaml: |-
46+
prometheusK8s:
47+
enforcedBodySizeLimit: 40MB <1>
48+
----
49+
<1> Specify the maximum body size for scraped metrics targets.
50+
This `enforcedBodySizeLimit` example limits the uncompressed size per target scrape to 40 megabytes.
51+
Valid numeric values use the Prometheus data size format: B (bytes), KB (kilobytes), MB (megabytes), GB (gigabytes), TB (terabytes), PB (petabytes), and EB (exabytes).
52+
The default value is `0`, which specifies no limit.
53+
You can also set the value to `automatic` to calculate the limit automatically based on cluster capacity.
54+
55+
. Save the file to apply the changes automatically.
56+
+
57+
[WARNING]
58+
====
59+
When you save changes to a `cluster-monitoring-config` config map, the pods and other resources in the `openshift-monitoring` project might be redeployed.
60+
The running monitoring processes in that project might also restart.
61+
====

monitoring/configuring-the-monitoring-stack.adoc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ include::modules/monitoring-assigning-tolerations-to-monitoring-components.adoc[
6868
* See the xref:../nodes/scheduling/nodes-scheduler-taints-tolerations.adoc#nodes-scheduler-taints-tolerations[{product-title} documentation] on taints and tolerations
6969
* See the link:https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/[Kubernetes documentation] on taints and tolerations
7070

71+
// Setting the body size limit for metrics scraping
72+
include::modules/monitoring-setting-the-body-size-limit-for-metrics-scraping.adoc[leveloffset=+1]
73+
74+
[role="_additional-resources"]
75+
.Additional resources
76+
77+
* link:https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config[Prometheus scrape configuration documentation]
78+
7179
// Configuring persistent storage
7280
include::modules/monitoring-configuring-persistent-storage.adoc[leveloffset=+1]
7381
include::modules/monitoring-configuring-a-local-persistent-volume-claim.adoc[leveloffset=+2]
@@ -168,4 +176,4 @@ include::modules/monitoring-disabling-the-local-alertmanager.adoc[leveloffset=+1
168176
== Next steps
169177

170178
* xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
171-
* Learn about xref:../support/remote_health_monitoring/opting-out-of-remote-health-reporting.adoc#opting-out-remote-health-reporting_opting-out-remote-health-reporting[remote health reporting] and, if necessary, opt out of it.
179+
* Learn about xref:../support/remote_health_monitoring/opting-out-of-remote-health-reporting.adoc#opting-out-remote-health-reporting_opting-out-remote-health-reporting[remote health reporting] and, if necessary, opt out of it.

0 commit comments

Comments
 (0)