Skip to content

Commit

Permalink
examples: kubernetes: add more explanation about inclusion/exclusion …
Browse files Browse the repository at this point in the history
…logs

Signed-off-by: Dominik Rosiek <[email protected]>
  • Loading branch information
Dominik Rosiek committed Mar 15, 2021
1 parent 21c5fb8 commit b85326c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
17 changes: 17 additions & 0 deletions examples/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,23 @@ This demo is a sample app to build the collector and exercise its kubernetes log

Switch to this directory and run following command: `kubectl apply -n <namespace> -f otel-collector.yaml`

#### Include/Exclude Specific Logs

Kubernetes logs are being stored in `/var/log/pods`.
Path to container logs is constructed using following pattern:

`/var/log/pods/<namespace>_<pod_name>_<pod_uid>/<container>/<run_id>.log`

You can use it to manage from which containers do you want to include and exclude logs.

For example, to include all logs from `default` namespace, you can use following configuration:

```yaml
include:
- /var/log/pods/default_*/*/*.log
exclude: []
```
### Docker Compose
Two steps are required to build and run the demo:
Expand Down
3 changes: 1 addition & 2 deletions examples/kubernetes/otel-collector-config.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
receivers:
filelog:
include:
# - /var/log/pods/namespace_pod-name_pod-uid/container-name/*.log
- /var/log/pods/*/*/*.log
exclude:
# - /var/log/pods/namespace_pod-name_pod-uid/container-name/*.log
# Exclude logs from all containers named otel-collector
- /var/log/pods/*/otel-collector/*.log
start_at: beginning
include_file_path: true
Expand Down
3 changes: 1 addition & 2 deletions examples/kubernetes/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ data:
receivers:
filelog:
include:
# - /var/log/pods/namespace_pod-name_pod-uid/container-name/*.log
- /var/log/pods/*/*/*.log
exclude:
# - /var/log/pods/namespace_pod-name_pod-uid/container-name/*.log
# Exclude logs from all containers named otel-collector
- /var/log/pods/*/otel-collector/*.log
start_at: beginning
include_file_path: true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
2021-02-16T09:21:15.518430714Z stdout F otel-collector: 10 Tue Feb 16 09:21:15 UTC 2021
2021-02-16T09:21:16.519721603Z stdout F otel-collector: 11 Tue Feb 16 09:21:16 UTC 2021
2021-02-16T09:21:17.521307236Z stdout F otel-collector: 12 Tue Feb 16 09:21:17 UTC 2021
2021-02-16T09:21:18.522445945Z stdout F otel-collector: 13 (part of log) Tue Feb 16 09:21:18 UTC 2021
2021-02-16T09:21:18.522445945Z stdout F otel-collector: 13 (end of log) Tue Feb 16 09:21:18 UTC 2021
2021-02-16T09:21:19.523759881Z stdout F otel-collector: 14 Tue Feb 16 09:21:19 UTC 2021
2021-02-16T09:21:20.545525544Z stdout F otel-collector: 15 Tue Feb 16 09:21:20 UTC 2021

0 comments on commit b85326c

Please sign in to comment.