Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 3. Cluster logging
3.1. Configuring log settings for Serving and Eventing Link kopierenLink in die Zwischenablage kopiert!
You can configure logging for OpenShift Serverless Serving and OpenShift Serverless Eventing by using the KnativeServing and KnativeEventing custom resource (CR). The specified loglevel value determines the logging level.
3.1.1. Supported log levels Link kopierenLink in die Zwischenablage kopiert!
The following loglevel values are supported:
| Log level | Description |
|---|---|
|
| Fine-grained debugging |
|
| Normal logging |
|
| Unexpected but non-critical errors |
|
| Critical errors; unexpected during normal operation |
|
| In debug mode, trigger a panic (crash) |
Using the debug level for production might negatively affect performance.
3.1.2. Configuring log settings Link kopierenLink in die Zwischenablage kopiert!
You can configure logging for Serving and Eventing in the KnativeServing custom resource (CR) and KnativeEventing CR.
Procedure
Configure the log settings for Serving and Eventing by setting or modifying the
loglevelvalue in theKnativeServingandKnativeEventingCR. Here are two example configurations with all possible logging options set to levelinfo:apiVersion: operator.knative.dev/v1beta1 kind: KnativeServing metadata: name: knative-serving namespace: knative-serving spec: config: logging: loglevel.controller: "info" loglevel.autoscaler: "info" loglevel.queueproxy: "info" loglevel.webhook: "info" loglevel.activator: "info" loglevel.hpaautoscaler: "info" loglevel.net-certmanager-controller: "info" loglevel.net-istio-controller: "info" loglevel.net-kourier-controller: "info"apiVersion: operator.knative.dev/v1beta1 kind: KnativeEventing metadata: name: knative-eventing namespace: knative-eventing spec: config: logging: loglevel.controller: "info" loglevel.eventing-webhook: "info" loglevel.inmemorychannel-dispatcher: "info" loglevel.inmemorychannel-webhook: "info" loglevel.mt-broker-controller: "info" loglevel.mt_broker_filter: "info" loglevel.mt_broker_ingress: "info" loglevel.pingsource-mt-adapter: "info"
3.1.3. Configuring request log settings Link kopierenLink in die Zwischenablage kopiert!
You can configure request logging for your service in the observability field of your KnativeServing custom resource (CR).
For information about the available parameters for configuring request logging, see "Parameters of request logging".
Procedure
Configure request logging for your service by modifying the
observabilityfield in yourKnativeServingCR:You get an output similar to the following example:
apiVersion: operator.knative.dev/v1beta1 kind: KnativeServing metadata: name: knative-serving namespace: knative-serving # ... spec: config: observability: logging.enable-request-log: true logging.enable-probe-request-log: true logging.request-log-template: '{"httpRequest": {"requestMethod": "{{.Request.Method}}", "requestUrl": "{{js .Request.RequestURI}}", "requestSize": "{{.Request.ContentLength}}", "status": {{.Response.Code}}, "responseSize": "{{.Response.Size}}", "userAgent": "{{js .Request.UserAgent}}", "remoteIp": "{{js .Request.RemoteAddr}}", "serverIp": "{{.Revision.PodIP}}", "referer": "{{js .Request.Referer}}", "latency": "{{.Response.Latency}}s", "protocol": "{{.Request.Proto}}"}, "traceId": "{{index .Request.Header "X-B3-Traceid"}}"}' # ...
3.1.4. Parameters of request logging Link kopierenLink in die Zwischenablage kopiert!
The following table describes parameters used to configure request logging.
| Parameter | Type | Description |
|---|---|---|
|
|
Boolean ( |
Set to |
|
|
Boolean ( |
Set to |
|
|
Go | Decide the shape of the request logs. Use a single line to prevent logs from being split into many records. |
The logging.request-log-template parameter includes the following functions:
-
Requestis anhttp.Requestrepresenting an HTTP request received by the server. Responserepresents the HTTP response and includes the following fields:-
Codeis the HTTP status code. -
Sizeis the response size in bytes. -
Latencyis the response latency in seconds.
-
Revisionhas revision details and includes the following fields:-
Nameis the name of the revision. -
Namespaceis the namespace of the revision. -
Serviceis the name of the service. -
Configurationis the name of the configuration. -
PodNameis the name of the pod hosting the revision. -
PodIPis the IP address of the hosting pod.
-