diff --git a/cmd/api/README.md b/cmd/api/README.md index cd1e6f556..3006d4943 100644 --- a/cmd/api/README.md +++ b/cmd/api/README.md @@ -29,6 +29,7 @@ | LOGS_TYPE | Determine Logs storage backend type | File (default) | | LOGS_BUFFER_SIZE | Buffer for streaming logs | 32768 (default) | | LOGS_PATH | Logs storage path | logs (default) | +| LOGS_TIMESTAMPS | Collect logs with timestamps | false (default) | | S3_BUCKET_NAME | S3 Bucket name | | | S3_ENDPOINT | S3 Endpoint | https://s3.ap-south-1.amazonaws.com | | S3_HOSTNAME_IMMUTABLE | S3 Hostname immutable | false (default) | diff --git a/cmd/watcher/main.go b/cmd/watcher/main.go index 9463b73bd..ff265df47 100644 --- a/cmd/watcher/main.go +++ b/cmd/watcher/main.go @@ -66,6 +66,7 @@ var ( qps = flag.Float64("qps", float64(rest.DefaultQPS), "Kubernetes client QPS setting") burst = flag.Int("burst", rest.DefaultBurst, "Kubernetes client Burst setting") logsAPI = flag.Bool("logs_api", true, "Disable sending logs. If not set, the logs will be sent only if server support API for it") + logsTimestamps = flag.Bool("logs_timestamps", false, "Collect logs with timestamps") labelSelector = flag.String("label_selector", "", "Selector (label query) to filter objects to be deleted. Matching objects must satisfy all labels requirements to be eligible for deletion") requeueInterval = flag.Duration("requeue_interval", 10*time.Minute, "How long the Watcher waits to reprocess keys on certain events (e.g. an object doesn't match the provided selectors)") namespace = flag.String("namespace", corev1.NamespaceAll, "Should the Watcher only watch a single namespace, then this value needs to be set to the namespace name otherwise leave it empty.") @@ -108,6 +109,7 @@ func main() { UpdateLogTimeout: updateLogTimeout, DynamicReconcileTimeout: dynamicReconcileTimeout, StoreEvent: *storeEvent, + LogsTimestamps: *logsTimestamps, } log.Printf("dynamic reconcile timeout %s and update log timeout is %s", cfg.DynamicReconcileTimeout.String(), cfg.UpdateLogTimeout.String()) diff --git a/config/base/env/config b/config/base/env/config index d45307dc3..5008b9306 100644 --- a/config/base/env/config +++ b/config/base/env/config @@ -24,6 +24,7 @@ LOGS_API=false LOGS_TYPE=File LOGS_BUFFER_SIZE=32768 LOGS_PATH=/logs +LOGS_TIMESTAMPS=false S3_BUCKET_NAME= S3_ENDPOINT= S3_HOSTNAME_IMMUTABLE=false diff --git a/pkg/api/server/config/config.go b/pkg/api/server/config/config.go index 49c788bdc..dadb70a0f 100644 --- a/pkg/api/server/config/config.go +++ b/pkg/api/server/config/config.go @@ -34,6 +34,7 @@ type Config struct { LOGS_TYPE string `mapstructure:"LOGS_TYPE"` LOGS_BUFFER_SIZE int `mapstructure:"LOGS_BUFFER_SIZE"` LOGS_PATH string `mapstructure:"LOGS_PATH"` + LOGS_TIMESTAMPS bool `mapstructure:"LOGS_TIMESTAMPS"` PROFILING bool `mapstructure:"PROFILING"` PROFILING_PORT string `mapstructure:"PROFILING_PORT"` diff --git a/pkg/watcher/reconciler/config.go b/pkg/watcher/reconciler/config.go index 0cedfa98f..3d94f0cea 100644 --- a/pkg/watcher/reconciler/config.go +++ b/pkg/watcher/reconciler/config.go @@ -49,6 +49,8 @@ type Config struct { DynamicReconcileTimeout *time.Duration // Whether to Store Events related to Taskrun and Pipelineruns StoreEvent bool + // Collect logs with timestamps + LogsTimestamps bool } // GetDisableAnnotationUpdate returns whether annotation updates should be diff --git a/pkg/watcher/reconciler/dynamic/dynamic.go b/pkg/watcher/reconciler/dynamic/dynamic.go index 22d270c29..910f306fa 100644 --- a/pkg/watcher/reconciler/dynamic/dynamic.go +++ b/pkg/watcher/reconciler/dynamic/dynamic.go @@ -520,6 +520,7 @@ func (r *Reconciler) streamLogs(ctx context.Context, o results.Object, logType, Params: tknParams, PipelineRunName: o.GetName(), TaskrunName: o.GetName(), + Timestamps: r.cfg.LogsTimestamps, Stream: &cli.Stream{ Out: inMemWriteBufferStdout, Err: inMemWriteBufferStderr,