Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PathTemplate to customize the directory for exporting logs #36

Merged
merged 7 commits into from
Jan 10, 2025

Conversation

sharkpc138
Copy link
Contributor

@sharkpc138 sharkpc138 commented Jan 7, 2025

PathTemplate

  • As the exported logs are transformed into various formats, the requirements for log paths have also increased
  • With the PathTemplate based on Go templates, you can freely structure fields using the template fields described below

Template Fields

  • Reserved keywords are provided to allow flexible directory composition in the path
  • Each field can be used multiple times
  • If this feature is not used, the default path structure is applied
    • /{time layout(2006-01)}/{Namespace}/{LobsterSink name}/{Contents name}/{Pod}/{Container}/{Start time of log}_{End time of log}.log
Field Description
{{TimeFunc "2006-01-02"}} Time based directory layout
{{.Cluster}} Cluster name
{{.Namespace}} Log source namespace name
{{.SinkName}} Lobster sink name
{{.RuleName}} Rule name in Lobster sink
{{.Pod}} Pod name
{{.Container}} Container name or __emptydir__
{{.SourceType}} stdstream or emptydir
{{.SourcePath}} A file path within an emptyDir volume

Example

spec:
  logExportRules:
  - basicBucket:
      destination: http://a-dev.nubes.sto.navercorp.com:8000/v1/n3r-logging
      pathTemplate: /pathtest/{{TimeFunc "20060102"}}/{{.Container}}
  ...
PathTemplate Exported file
/lobster /lobster/2025-01-06T14:17:15%2B09:00_2025-01-06T14:17:17%2B09:00.log
/{{TimeFunc "2006-01"}} /2025-01/2025-01-06T14:17:15%2B09:00_2025-01-06T14:17:17%2B09:00.log
/{{.Pod}} /loggen-123/2025-01-06T14:17:15%2B09:00_2025-01-06T14:17:17%2B09:00.log
/{{.SourcePath}} /renamed_namespaceA_test.log/loggen-123/2025-01-06T14:17:15%2B09:00_2025-01-06T14:17:17%2B09:00.log
/lobster/{{TimeFunc "2006-01"}}/123/{{.SourcePath}} /lobster/2025-01/123/renamed_namespaceA_test.log/2025-01-06T14:17:15%2B09:00_2025-01-06T14:17:17%2B09:00.log
/{{TimeFunc "2006-01"}}/{{Time "2006-01-02"}} /2025-01-06/2025-01/2025-01-06T14:17:15%2B09:00_2025-01-06T14:17:17%2B09:00.log

Cautions

  • Customization introduces potential risks of conflicts due to insufficient delimiters
  • For example, with configurations like /{{.Pod}}, where delimiters are insufficient,
    conflicts may arise when exporting logs from multiple containers, each having the same log timestamp
    • container A - 2025-01-06T18:20:24%252B09:00_2025-01-06T18:21:23%252B09:00.log
    • container B - 2025-01-06T18:20:24%252B09:00_2025-01-06T18:21:23%252B09:00.log

@sharkpc138 sharkpc138 force-pushed the add-customize_log_export_dir branch from 21bd66b to e53b379 Compare January 8, 2025 05:23
@sharkpc138 sharkpc138 force-pushed the add-customize_log_export_dir branch from e53b379 to 31d45f6 Compare January 8, 2025 05:29
@sharkpc138 sharkpc138 force-pushed the add-customize_log_export_dir branch from d98e21d to 897d10c Compare January 9, 2025 01:16
add a pod list cache to continue tailing logs even if the API server or kubelet fails
@sharkpc138 sharkpc138 merged commit 0d87951 into fix-request_logs Jan 10, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant