You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Logs including JSON logs are usually represented as a string inside the `message` field. That makes it hard for users to query specific fields inside a JSON document. OpenShift Logging's Log Forwarding API enables you to parse JSON logs into a structured object and forward them to either OpenShift Logging-managed Elasticsearch or any other third-party system supported by the Log Forwarding API.
4
+
You can use a `ClusterLogForwarder` object to parse JSON logs into a structured object and forward them to a supported output.
5
5
6
-
To illustrate how this works, suppose that you have the following structured JSON log entry.
6
+
To illustrate how this works, suppose that you have the following structured JSON log entry:
7
7
8
8
.Example structured JSON log entry
9
9
[source,yaml]
10
10
----
11
11
{"level":"info","name":"fred","home":"bedrock"}
12
12
----
13
13
14
-
Normally, the `ClusterLogForwarder` custom resource (CR) forwards that log entry in the `message` field. The `message` field contains the JSON-quoted string equivalent of the JSON log entry, as shown in the following example.
To enable parsing JSON log, you add `parse: json` to a pipeline in the `ClusterLogForwarder` CR, as shown in the following example.
14
+
To enable parsing JSON log, you add `parse: json` to a pipeline in the `ClusterLogForwarder` CR, as shown in the following example:
24
15
25
16
.Example snippet showing `parse: json`
26
17
[source,yaml]
@@ -31,7 +22,7 @@ pipelines:
31
22
parse: json
32
23
----
33
24
34
-
When you enable parsing JSON logs by using `parse: json`, the CR copies the JSON-structured log entry in a `structured` field, as shown in the following example. This does not modify the original `message` field.
25
+
When you enable parsing JSON logs by using `parse: json`, the CR copies the JSON-structured log entry in a `structured` field, as shown in the following example:
35
26
36
27
.Example `structured` output containing the structured JSON log entry
37
28
[source,yaml]
@@ -42,5 +33,5 @@ When you enable parsing JSON logs by using `parse: json`, the CR copies the JSON
42
33
43
34
[IMPORTANT]
44
35
====
45
-
If the log entry does not contain valid structured JSON, the `structured` field will be absent.
36
+
If the log entry does not contain valid structured JSON, the `structured` field is absent.
0 commit comments