@@ -37,6 +37,10 @@ func NewConfigForPostgresPod(ctx context.Context,
3737//go:embed "generated/postgres_logs_transforms.json"
3838var postgresLogsTransforms json.RawMessage
3939
40+ // PostgresPostRotateScript is the script that is run after postgres's log
41+ // files have been rotated.
42+ const PostgresPostRotateScript = "pkill -USR1 --exact --parent=1 postgres"
43+
4044// postgresCSVNames returns the names of fields in the CSV logs for version.
4145func postgresCSVNames (version int ) string {
4246 // JSON is the preferred format, so use those names.
@@ -100,11 +104,11 @@ func EnablePostgresLogging(
100104 // probably requires another process that deletes the oldest files.
101105 //
102106 // The ".log" suffix is replaced by ".json" for JSON log files.
103- outParameters .Mandatory .Add ("log_filename" , "postgresql-%a.log " )
107+ outParameters .Mandatory .Add ("log_filename" , "postgresql" )
104108 outParameters .Mandatory .Add ("log_file_mode" , "0660" )
105- outParameters .Mandatory .Add ("log_rotation_age" , "1d " )
109+ outParameters .Mandatory .Add ("log_rotation_age" , "0 " )
106110 outParameters .Mandatory .Add ("log_rotation_size" , "0" )
107- outParameters .Mandatory .Add ("log_truncate_on_rotation" , "on " )
111+ outParameters .Mandatory .Add ("log_truncate_on_rotation" , "off " )
108112
109113 // Log in a timezone that the OpenTelemetry Collector will understand.
110114 outParameters .Mandatory .Add ("log_timezone" , "UTC" )
@@ -124,7 +128,7 @@ func EnablePostgresLogging(
124128 // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/filelogreceiver#readme
125129 outConfig .Receivers ["filelog/postgres_csvlog" ] = map [string ]any {
126130 // Read the CSV files and keep track of what has been processed.
127- "include" : []string {directory + "/*.csv" },
131+ "include" : []string {directory + "/*.csv" , directory + "/*.csv.1" },
128132 "storage" : "file_storage/postgres_logs" ,
129133
130134 // Postgres does not escape newlines in its CSV log format. Search for
@@ -155,7 +159,7 @@ func EnablePostgresLogging(
155159 // https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/-/receiver/filelogreceiver#readme
156160 outConfig .Receivers ["filelog/postgres_jsonlog" ] = map [string ]any {
157161 // Read the JSON files and keep track of what has been processed.
158- "include" : []string {directory + "/*.json" },
162+ "include" : []string {directory + "/*.json" , directory + "/*.json.1" },
159163 "storage" : "file_storage/postgres_logs" ,
160164
161165 // Differentiate these from the CSV ones above.
0 commit comments