Skip to content

Make prometheus.yml world-readable

Sean McGivern requested to merge prometheus-yml-permissions into main

What does this Merge Request do and why?

Because prometheus.yml is shared with Docker, it needs to have more general permissions so that the Docker guest can actually read it. (By default it was read/write for the user, with everything else denied.)

Making this world-readable doesn't seem harmful.

The reason it gets these permissions in the first place seems to be because we use safe_render!, which creates a tempfile with limited permissions and then moves it to the destination.

Before (the command I'm running is the equivalent of gdk start prometheus):

$ ls -l prometheus/prometheus.yml 
-rw-------   1 smcgivern      smcgiver     1121 2021-05-27 12:42 prometheus/prometheus.yml
/ssh:dev:~/gdk $ docker run -p 9090:9090 -v /home/smcgivern/gdk/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:v2.25.0
level=error ts=2021-06-22T14:27:22.824Z caller=main.go:333 msg="Error loading config (--config.file=/etc/prometheus/prometheus.yml)" err="open /etc/prometheus/prometheus.yml: permission denied"

After:

$ ls -l prometheus/prometheus.yml 
-rw-r--r--   1 smcgivern      smcgiver     1121 2021-05-27 12:42 prometheus/prometheus.yml
/ssh:dev:~/gdk $ docker run -p 9090:9090 -v /home/smcgivern/gdk/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:v2.25.0
level=info ts=2021-06-22T14:31:35.873Z caller=main.go:366 msg="No time or size retention was set so using the default time retention" duration=15d
level=info ts=2021-06-22T14:31:35.874Z caller=main.go:404 msg="Starting Prometheus" version="(version=2.25.0, branch=HEAD, revision=a6be548dbc17780d562a39c0e4bd0bd4c00ad6e2)"
level=info ts=2021-06-22T14:31:35.874Z caller=main.go:409 build_context="(go=go1.15.8, user=root@615f028225c9, date=20210217-14:17:24)"
level=info ts=2021-06-22T14:31:35.875Z caller=main.go:410 host_details="(Linux 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 a9800678b306 (none))"
level=info ts=2021-06-22T14:31:35.875Z caller=main.go:411 fd_limits="(soft=1048576, hard=1048576)"
level=info ts=2021-06-22T14:31:35.875Z caller=main.go:412 vm_limits="(soft=unlimited, hard=unlimited)"
level=info ts=2021-06-22T14:31:35.879Z caller=web.go:532 component=web msg="Start listening for connections" address=0.0.0.0:9090
level=info ts=2021-06-22T14:31:35.881Z caller=main.go:779 msg="Starting TSDB ..."
level=info ts=2021-06-22T14:31:35.890Z caller=head.go:668 component=tsdb msg="Replaying on-disk memory mappable chunks if any"
level=info ts=2021-06-22T14:31:35.890Z caller=head.go:682 component=tsdb msg="On-disk memory mappable chunks replay completed" duration=6.105µs
level=info ts=2021-06-22T14:31:35.891Z caller=head.go:688 component=tsdb msg="Replaying WAL, this may take a while"
level=info ts=2021-06-22T14:31:35.893Z caller=tls_config.go:191 component=web msg="TLS is disabled." http2=false
level=info ts=2021-06-22T14:31:35.894Z caller=head.go:740 component=tsdb msg="WAL segment loaded" segment=0 maxSegment=0
level=info ts=2021-06-22T14:31:35.894Z caller=head.go:745 component=tsdb msg="WAL replay completed" checkpoint_replay_duration=173.677µs wal_replay_duration=2.812675ms total_replay_duration=3.656541ms
level=info ts=2021-06-22T14:31:35.896Z caller=main.go:799 fs_type=EXT4_SUPER_MAGIC
level=info ts=2021-06-22T14:31:35.896Z caller=main.go:802 msg="TSDB started"
level=info ts=2021-06-22T14:31:35.897Z caller=main.go:928 msg="Loading configuration file" filename=/etc/prometheus/prometheus.yml
level=info ts=2021-06-22T14:31:35.898Z caller=main.go:959 msg="Completed loading of configuration file" filename=/etc/prometheus/prometheus.yml totalDuration=1.212556ms remote_storage=1.836µs web_handler=423ns query_engine=1.311µs scrape=327.354µs scrape_sd=74.985µs notify=900ns notify_sd=1.503µs rules=1.173µs
level=info ts=2021-06-22T14:31:35.898Z caller=main.go:751 msg="Server is ready to receive web requests."

Merge Request checklist

  • This change is backward compatible. If not, please include steps to communicate to our users.
  • Tests added for new functionality. If not, please raise Issue to follow-up.
  • Documentation added/updated, if needed.
  • gdk doctor test added, if needed.
  • Add the ~highlight label if this MR should be included in the CHANGELOG.md.
Edited by Sean McGivern

Merge request reports