Skip to content

Commit d624310

Browse files
bburt-rhopenshift-cherrypick-robot
authored andcommitted
RHDEVDOCS-3611 - configure-request-logging-for-thanos-querier
1 parent 7ec4746 commit d624310

File tree

2 files changed

+95
-1
lines changed

2 files changed

+95
-1
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * monitoring/configuring-the-monitoring-stack.adoc
4+
5+
[id="enabling-query-logging-for-thanos-querier_{context}"]
6+
:_content-type: PROCEDURE
7+
= Enabling query logging for Thanos Querier
8+
9+
[role="_abstract"]
10+
For default platform monitoring in the `openshift-monitoring` project, you can enable the Cluster Monitoring Operator to log all queries run by Thanos Querier.
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+
* You have access to the cluster as a user with the `cluster-admin` role.
21+
* You have created the `cluster-monitoring-config` `ConfigMap` object.
22+
23+
.Procedure
24+
25+
You can enable query logging for Thanos Querier in the `openshift-monitoring` project:
26+
27+
. Edit the `cluster-monitoring-config` `ConfigMap` object in the `openshift-monitoring` project:
28+
+
29+
[source,terminal]
30+
----
31+
$ oc -n openshift-monitoring edit configmap cluster-monitoring-config
32+
----
33+
+
34+
. Add a `thanosQuerier` section under `data/config.yaml` and add values as shown in the following example:
35+
+
36+
[source,yaml]
37+
----
38+
apiVersion: v1
39+
kind: ConfigMap
40+
metadata:
41+
name: cluster-monitoring-config
42+
namespace: openshift-monitoring
43+
data:
44+
config.yaml: |
45+
thanosQuerier:
46+
enableRequestLogging: <value> <1>
47+
logLevel: <value> <2>
48+
49+
50+
----
51+
<1> Set the value to `true` to enable logging and `false` to disable logging. The default value is `false`.
52+
<2> Set the value to `debug`, `info`, `warn`, or `error`. If no value exists for `logLevel`, the log level defaults to `error`.
53+
+
54+
. Save the file to apply the changes.
55+
+
56+
[WARNING]
57+
====
58+
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.
59+
====
60+
61+
.Verification
62+
63+
. Verify that the Thanos Querier pods are running. The following sample command lists the status of pods in the `openshift-monitoring` project:
64+
+
65+
[source,terminal]
66+
----
67+
$ oc -n openshift-monitoring get pods
68+
----
69+
+
70+
. Run a test query using the following sample commands as a model:
71+
+
72+
[source,terminal]
73+
----
74+
$ token=`oc sa get-token prometheus-k8s -n openshift-monitoring`
75+
$ oc -n openshift-monitoring exec -c prometheus prometheus-k8s-0 -- curl -k -H "Authorization: Bearer $token" 'https://thanos-querier.openshift-monitoring.svc:9091/api/v1/query?query=cluster_version'
76+
----
77+
. Run the following command to read the query log:
78+
+
79+
[source,terminal]
80+
----
81+
$ oc -n openshift-monitoring logs <thanos_querier_pod_name> -c thanos-query
82+
----
83+
+
84+
[NOTE]
85+
====
86+
Because the `thanos-querier` pods are highly available (HA) pods, you might be able to see logs in only one pod.
87+
====
88+
+
89+
. After you examine the logged query information, disable query logging by changing the `enableRequestLogging` value to `false` in the config map.
90+

monitoring/configuring-the-monitoring-stack.adoc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ include::modules/monitoring-attaching-additional-labels-to-your-time-series-and-
139139

140140
* 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
141141
* xref:../monitoring/enabling-monitoring-for-user-defined-projects.adoc#enabling-monitoring-for-user-defined-projects[Enabling monitoring for user-defined projects]
142-
* 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
143142

144143
// Setting log levels for monitoring components
145144
include::modules/monitoring-setting-log-levels-for-monitoring-components.adoc[leveloffset=+1]
@@ -153,6 +152,11 @@ include::modules/monitoring-setting-query-log-file-for-prometheus.adoc[leveloffs
153152
* 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
154153
* 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.
155154

155+
// Enabling query logging for Thanos Querier
156+
include::modules/monitoring-enabling-query-logging-for-thanos-querier.adoc[leveloffset=+1]
157+
158+
* 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.
159+
156160
// Disabling the default Grafana deployment
157161
include::modules/monitoring-disabling-grafana.adoc[leveloffset=+1]
158162

0 commit comments

Comments
 (0)