diff --git a/internal/pgmonitor/exporter.go b/internal/pgmonitor/exporter.go index 7c0a5d0418..8d253b089e 100644 --- a/internal/pgmonitor/exporter.go +++ b/internal/pgmonitor/exporter.go @@ -122,6 +122,17 @@ func GenerateDefaultExporterQueries(ctx context.Context, cluster *v1beta1.Postgr // the source queries files. func ExporterStartCommand(commandFlags []string) []string { script := strings.Join([]string{ + // Check to see if the postgres_exporter command is successful. If it is, we are + // using an image that has the command on the PATH. If it isn't, we have an older + // image that does not have it on the PATH and we should find the directory that + // holds the postgres_exporter binary and add it to the PATH. + `rc=0`, + `postgres_exporter --version || rc=$?`, + `if [ $rc -ne 0 ]; then`, + ` dir=$(find /opt/cpm/bin/postgres_exporter* -type d)`, + ` export PATH=$PATH:$dir`, + `fi`, + // Set up temporary file to hold postgres_exporter process id `POSTGRES_EXPORTER_PIDFILE=/tmp/postgres_exporter.pid`,