Skip to content

Docs on use of flags in combination with config.file non-existent #1214

@camac2025

Description

@camac2025

What did you do?
Create a file called postgres_exporter.yml alongside the binary i.e. in same directory. Populated it with a variety of combinations of:

collector.postmaster collector.stat_checkpointer

or

--collector.postmaster  
--collector.stat_checkpointer

trying different spaces, newlines, dashes etc. etc.

What did you expect to see?
I expected to see the file be located and my supplied flags be applied.

What did you see instead? Under which circumstances?
Initially when using systemctl wrapper under rocky 9 I saw:

"Error loading config" err="Error opening config file \"postgres_exporter.yml\": open postgres_exporter.yml: no such file or directory"

So I assumed there was something wrong with execution environment as setup by systemd and I tried an explicit call - this resulted in unmarshalling errors, suggesting to my not-very-go-aware mind that I have the format wrong..?

$ ./postgres_exporter --config.file=./postgres_exporter.yml
time=2025-10-28T18:28:17.679Z level=WARN source=main.go:85 msg="Error loading config" err="Error parsing config file \"./postgres_exporter.yml\": yaml: unmarshal errors:\n  line 1: cannot unmarshal !!str `collect...` into config.Config"

Environment

  • System information:
Linux 5.14.0-570.32.1.el9_6.x86_64 x86_64
  • postgres_exporter version:
postgres_exporter, version 0.17.1 (branch: HEAD, revision: 1e574cf4fd2a75a8a707d424eafcaa0b88cb7af4)
  build user:       root@b0ba132eddb0
  build date:       20250226-13:53:15
  go version:       go1.23.6
  platform:         linux/amd64
  tags:             unknown
  • postgres_exporter flags:
    Well, I was hoping for these!
--collector.postmaster 
--collector.stat_checkpointer
  • PostgreSQL version:
 PostgreSQL 17.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 11.5.0 20240719 (Red Hat 11.5.0-5), 64-bit
  • Logs:
insert logs relevant to the issue here

I really think the docs need an example of how to set up a config.file incorporating flags, assuming that is possible and I do not need to edit my systemd service script to add explicit CLI options.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions