@@ -259,13 +259,34 @@ func addPGMonitorExporterToInstancePodSpec(
259259 withBuiltInCollectors :=
260260 ! strings .EqualFold (cluster .Annotations [naming .PostgresExporterCollectorsAnnotation ], "None" )
261261
262+ var cmd []string
263+ // PG 17 does not include some of the columns found in stat_bgwriter with older PGs.
264+ // Selectively turn off the collector for stat_bgwriter in PG 17, unless the user
265+ // requests all collectors to be turned off.
266+ switch {
267+ case cluster .Spec .PostgresVersion == 17 && withBuiltInCollectors && certSecret == nil :
268+ cmd = pgmonitor .ExporterStartCommand (withBuiltInCollectors ,
269+ pgmonitor .ExporterDeactivateStatBGWriterFlag )
270+ case cluster .Spec .PostgresVersion == 17 && withBuiltInCollectors && certSecret != nil :
271+ cmd = pgmonitor .ExporterStartCommand (withBuiltInCollectors ,
272+ pgmonitor .ExporterWebConfigFileFlag ,
273+ pgmonitor .ExporterDeactivateStatBGWriterFlag )
274+ // If you're turning off all built-in collectors, we don't care which
275+ // version of PG you're using.
276+ case certSecret != nil :
277+ cmd = pgmonitor .ExporterStartCommand (withBuiltInCollectors ,
278+ pgmonitor .ExporterWebConfigFileFlag )
279+ default :
280+ cmd = pgmonitor .ExporterStartCommand (withBuiltInCollectors )
281+ }
282+
262283 securityContext := initialize .RestrictedSecurityContext ()
263284 exporterContainer := corev1.Container {
264285 Name : naming .ContainerPGMonitorExporter ,
265286 Image : config .PGExporterContainerImage (cluster ),
266287 ImagePullPolicy : cluster .Spec .ImagePullPolicy ,
267288 Resources : cluster .Spec .Monitoring .PGMonitor .Exporter .Resources ,
268- Command : pgmonitor . ExporterStartCommand ( withBuiltInCollectors ) ,
289+ Command : cmd ,
269290 Env : []corev1.EnvVar {
270291 {Name : "DATA_SOURCE_URI" , Value : fmt .Sprintf ("%s:%d/%s" , pgmonitor .ExporterHost , * cluster .Spec .Port , pgmonitor .ExporterDB )},
271292 {Name : "DATA_SOURCE_USER" , Value : pgmonitor .MonitoringUser },
@@ -357,8 +378,6 @@ func addPGMonitorExporterToInstancePodSpec(
357378 }}
358379
359380 exporterContainer .VolumeMounts = append (exporterContainer .VolumeMounts , mounts ... )
360- exporterContainer .Command = pgmonitor .ExporterStartCommand (
361- withBuiltInCollectors , pgmonitor .ExporterWebConfigFileFlag )
362381 }
363382
364383 template .Spec .Containers = append (template .Spec .Containers , exporterContainer )
0 commit comments