Skip to content

Commit 6e81e35

Browse files
authored
Merge pull request #32550 from rolfedh/RHDEVDOCS-3009
RHDEVDOCS-3009 Add info on Kubernetes matchLabels to "Forwarding application logs from specific pods" topic
2 parents 471c5bb + 95e7aed commit 6e81e35

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

modules/cluster-logging-collector-log-forward-logs-from-application-pods.adoc

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ As a cluster administrator, you can use Kubernetes pod labels to gather log data
55

66
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.
77

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+
810
.Procedure
911

1012
. Create a `ClusterLogForwarder` custom resource (CR) YAML file.
@@ -23,33 +25,47 @@ spec:
2325
pipelines:
2426
- inputRefs: [ myAppLogData ] <3>
2527
outputRefs: [ default ] <4>
26-
inputs:
28+
inputs: <5>
2729
- name: myAppLogData
2830
application:
2931
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>
3436
- app1
3537
- app2
36-
outputs: <7>
37-
- default <8>
38+
outputs: <8>
39+
- default
3840
...
3941
----
4042
<1> The name of the `ClusterLogForwarder` CR must be `instance`.
4143
<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.
4750

4851
. Optional: To restrict the gathering of log data to specific namespaces, use `inputs[].name.application.namespaces`, as shown in the preceding example.
4952

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+
5062
. Create the CR object:
5163
+
5264
[source,terminal]
5365
----
5466
$ oc create -f <file-name>.yaml
5567
----
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

Comments
 (0)