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
Copy file name to clipboardExpand all lines: modules/cluster-logging-collector-log-forward-logs-from-application-pods.adoc
+28-12Lines changed: 28 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,8 @@ As a cluster administrator, you can use Kubernetes pod labels to gather log data
5
5
6
6
Suppose that you have an application composed of pods running alongside other pods in various namespaces. If those pods have labels that identify the application, you can gather and output their log data to a specific log collector.
7
7
8
+
To specify the pod labels, you use one or more `matchLabels` key-value pairs. If you specify multiple key-value pairs, the pods must match all of them to be selected.
9
+
8
10
.Procedure
9
11
10
12
. Create a `ClusterLogForwarder` custom resource (CR) YAML file.
@@ -23,33 +25,47 @@ spec:
23
25
pipelines:
24
26
- inputRefs: [ myAppLogData ] <3>
25
27
outputRefs: [ default ] <4>
26
-
inputs:
28
+
inputs: <5>
27
29
- name: myAppLogData
28
30
application:
29
31
selector:
30
-
matchLabels:
31
-
environment: production <5>
32
-
app: nginx <5>
33
-
namespaces: <6>
32
+
matchLabels: <6>
33
+
environment: production
34
+
app: nginx
35
+
namespaces: <7>
34
36
- app1
35
37
- app2
36
-
outputs: <7>
37
-
- default <8>
38
+
outputs: <8>
39
+
- default
38
40
...
39
41
----
40
42
<1> The name of the `ClusterLogForwarder` CR must be `instance`.
41
43
<2> The namespace for the `ClusterLogForwarder` CR must be `openshift-logging`.
42
-
<3> Specify the input for the pipeline.
43
-
<4> Specify the output for the pipeline.
44
-
<5> Specify the labels of pods whose log data you want to gather.
45
-
<6> Optional: Specify one or more namespaces.
46
-
<7> Specify the output to forward your log data to. The optional `default` output shown here sends log data to the internal Elasticsearch instance.
44
+
<3> Specify one or more comma-separated values from `inputs[].name`.
45
+
<4> Specify one or more comma-separated values from `outputs[]`.
46
+
<5> Define a unique `inputs[].name` for each application that has a unique set of pod labels.
47
+
<6> Specify the key-value pairs of pod labels whose log data you want to gather. You must specify both a key and value, not just a key. To be selected, the pods must match all the key-value pairs.
48
+
<7> Optional: Specify one or more namespaces.
49
+
<8> Specify one or more outputs to forward your log data to. The optional `default` output shown here sends log data to the internal Elasticsearch instance.
47
50
48
51
. Optional: To restrict the gathering of log data to specific namespaces, use `inputs[].name.application.namespaces`, as shown in the preceding example.
49
52
53
+
. Optional: You can send log data from additional applications that have different pod labels to the same pipeline.
54
+
.. For each unique combination of pod labels, create an additional `inputs[].name` section similar to the one shown.
55
+
.. Update the `selectors` to match the pod labels of this application.
56
+
.. Add the new `inputs[].name` value to `inputRefs`. For example:
57
+
+
58
+
----
59
+
- inputRefs: [ myAppLogData, myOtherAppLogData ]
60
+
----
61
+
50
62
. Create the CR object:
51
63
+
52
64
[source,terminal]
53
65
----
54
66
$ oc create -f <file-name>.yaml
55
67
----
68
+
69
+
.Additional resources
70
+
71
+
* For more information on `matchLabels` in Kubernetes, see link:https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#resources-that-support-set-based-requirements[Resources that support set-based requirements].
0 commit comments