That's the correct way to do it - and I've just tested with prometheus 2.45.0 to be sure.
Therefore, if it's not working, it means you're not applying this option correctly.
Use "ps auxwwww | grep prometheus" to see what actual command line options you're passing.
If this is in a .service file, you will need to run "systemctl daemon-reload" to get systemd to re-read your modified file, before "systemctl restart prometheus"
I prefer to do it like this:
--------
[Unit]
Description=Prometheus Server
Documentation=
https://prometheus.io/docs/introduction/overview/After=network-online.target
[Service]
User=prometheus
Restart=on-failure
RestartSec=5
TimeoutStopSec=300
WorkingDirectory=/opt/prometheus
EnvironmentFile=/etc/default/prometheus
ExecStart=/opt/prometheus/prometheus $OPTIONS
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
--------
where /etc/default/prometheus contains
OPTIONS='--web.enable-admin-api --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus/data/ --storage.tsdb.wal-compression --log.level=info --storage.tsdb.retention.time=366d --web.enable-remote-write-receiver'
When you change the options here, no "daemon-reload" is necessary, just a restart.