Skip to content

Commit 44d272e

Browse files
committed
monitoring: Describe query log file feature for Prometheus
1 parent 7476817 commit 44d272e

File tree

2 files changed

+136
-1
lines changed

2 files changed

+136
-1
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * monitoring/configuring-the-monitoring-stack.adoc
4+
5+
[id="setting-query-log-file-for-prometheus_{context}"]
6+
:_content-type: PROCEDURE
7+
= Enabling the query log file for Prometheus
8+
9+
[role="_abstract"]
10+
You can configure Prometheus to write all queries that have been run by the engine to a log file. You can do so for default platform monitoring and for user-defined workload monitoring.
11+
12+
[IMPORTANT]
13+
====
14+
Because log rotation is not supported, only enable this feature temporarily when you need to troubleshoot an issue. After you finish troubleshooting, disable query logging by reverting the changes you made to the `ConfigMap` object to enable the feature.
15+
====
16+
17+
.Prerequisites
18+
19+
* You have installed the OpenShift CLI (`oc`).
20+
* *If you are enabling the query log file feature for Prometheus in the `openshift-monitoring` project*:
21+
** You have access to the cluster as a user with the `cluster-admin` role.
22+
** You have created the `cluster-monitoring-config` `ConfigMap` object.
23+
* *If you are enabling the query log file feature for Prometheus in the `openshift-user-workload-monitoring` project*:
24+
** You have access to the cluster as a user with the `cluster-admin` role, or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project.
25+
** You have created the `user-workload-monitoring-config` `ConfigMap` object.
26+
27+
.Procedure
28+
29+
** *To set the query log file for Prometheus in the `openshift-monitoring` project*:
30+
. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` project:
31+
+
32+
[source,terminal]
33+
----
34+
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
35+
----
36+
+
37+
. Add `queryLogFile: <path>` for `prometheusK8s` under `data/config.yaml`:
38+
+
39+
[source,yaml]
40+
----
41+
apiVersion: v1
42+
kind: ConfigMap
43+
metadata:
44+
name: cluster-monitoring-config
45+
namespace: openshift-monitoring
46+
data:
47+
config.yaml: |
48+
prometheusK8s:
49+
queryLogFile: <path> <1>
50+
----
51+
<1> The full path to the file in which queries will be logged.
52+
+
53+
. Save the file to apply the changes.
54+
+
55+
[WARNING]
56+
====
57+
When you save changes to a monitoring config map, pods and other resources in the related project might be redeployed. The running monitoring processes in that project might also be restarted.
58+
====
59+
+
60+
. Verify that the pods for the component are running. The following sample command lists the status of pods in the `openshift-monitoring` project:
61+
+
62+
[source,terminal]
63+
----
64+
$ oc -n openshift-monitoring get pods
65+
----
66+
+
67+
. Read the query log:
68+
+
69+
[source,terminal]
70+
----
71+
$ oc -n openshift-monitoring exec prometheus-k8s-0 -- cat <path>
72+
----
73+
+
74+
[IMPORTANT]
75+
====
76+
Revert the setting in the config map after you have examined the logged query information.
77+
====
78+
79+
** *To set the query log file for Prometheus in the `openshift-user-workload-monitoring` project*:
80+
. Edit the `user-workload-monitoring-config` `ConfigMap` object in the `openshift-user-workload-monitoring` project:
81+
+
82+
[source,terminal]
83+
----
84+
$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config
85+
----
86+
+
87+
. Add `queryLogFile: <path>` for `prometheus` under `data/config.yaml`:
88+
+
89+
[source,yaml]
90+
----
91+
apiVersion: v1
92+
kind: ConfigMap
93+
metadata:
94+
name: user-workload-monitoring-config
95+
namespace: openshift-user-workload-monitoring
96+
data:
97+
config.yaml: |
98+
prometheus:
99+
queryLogFile: <path> <1>
100+
----
101+
<1> The full path to the file in which queries will be logged.
102+
+
103+
. Save the file to apply the changes.
104+
+
105+
[NOTE]
106+
====
107+
Configurations applied to the `user-workload-monitoring-config` `ConfigMap` object are not activated unless a cluster administrator has enabled monitoring for user-defined projects.
108+
====
109+
+
110+
[WARNING]
111+
====
112+
When you save changes to a monitoring config map, pods and other resources in the related project might be redeployed. The running monitoring processes in that project might also be restarted.
113+
====
114+
+
115+
. Verify that the pods for the component are running. The following example command lists the status of pods in the `openshift-user-workload-monitoring` project:
116+
+
117+
[source,terminal]
118+
----
119+
$ oc -n openshift-user-workload-monitoring get pods
120+
----
121+
+
122+
. Read the query log:
123+
+
124+
[source,terminal]
125+
----
126+
$ oc -n openshift-user-workload-monitoring exec prometheus-user-workload-0 -- cat <path>
127+
----
128+
+
129+
[IMPORTANT]
130+
====
131+
Revert the setting in the config map after you have examined the logged query information.
132+
====

monitoring/configuring-the-monitoring-stack.adoc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,14 @@ include::modules/monitoring-attaching-additional-labels-to-your-time-series-and-
149149
// Setting log levels for monitoring components
150150
include::modules/monitoring-setting-log-levels-for-monitoring-components.adoc[leveloffset=+1]
151151

152+
// Setting query log for Prometheus
153+
include::modules/monitoring-setting-query-log-file-for-prometheus.adoc[leveloffset=+1]
154+
152155
[role="_additional-resources"]
153156
.Additional resources
154157

155158
* See xref:../monitoring/configuring-the-monitoring-stack.adoc#preparing-to-configure-the-monitoring-stack[Preparing to configure the monitoring stack] for steps to create monitoring config maps
156-
* xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
159+
* See xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects] for steps to enable user-defined monitoring.
157160

158161
// Disabling the default Grafana deployment
159162
include::modules/monitoring-disabling-grafana.adoc[leveloffset=+1]

0 commit comments

Comments
 (0)