@@ -259,13 +259,34 @@ func addPGMonitorExporterToInstancePodSpec(
259
259
withBuiltInCollectors :=
260
260
! strings .EqualFold (cluster .Annotations [naming .PostgresExporterCollectorsAnnotation ], "None" )
261
261
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
+
262
283
securityContext := initialize .RestrictedSecurityContext ()
263
284
exporterContainer := corev1.Container {
264
285
Name : naming .ContainerPGMonitorExporter ,
265
286
Image : config .PGExporterContainerImage (cluster ),
266
287
ImagePullPolicy : cluster .Spec .ImagePullPolicy ,
267
288
Resources : cluster .Spec .Monitoring .PGMonitor .Exporter .Resources ,
268
- Command : pgmonitor . ExporterStartCommand ( withBuiltInCollectors ) ,
289
+ Command : cmd ,
269
290
Env : []corev1.EnvVar {
270
291
{Name : "DATA_SOURCE_URI" , Value : fmt .Sprintf ("%s:%d/%s" , pgmonitor .ExporterHost , * cluster .Spec .Port , pgmonitor .ExporterDB )},
271
292
{Name : "DATA_SOURCE_USER" , Value : pgmonitor .MonitoringUser },
@@ -357,8 +378,6 @@ func addPGMonitorExporterToInstancePodSpec(
357
378
}}
358
379
359
380
exporterContainer .VolumeMounts = append (exporterContainer .VolumeMounts , mounts ... )
360
- exporterContainer .Command = pgmonitor .ExporterStartCommand (
361
- withBuiltInCollectors , pgmonitor .ExporterWebConfigFileFlag )
362
381
}
363
382
364
383
template .Spec .Containers = append (template .Spec .Containers , exporterContainer )
0 commit comments