diff options
author | Alex Simkin <sashasimkin@gmail.com> | 2021-07-31 11:43:58 +0300 |
---|---|---|
committer | Paul Spooren <mail@aparcar.org> | 2021-09-09 08:17:08 -1000 |
commit | abf8949a2a996e0c707c62cb96885774b058fa42 (patch) | |
tree | bec5fb2be9031af09a3403e895f07bd370c1fde6 /utils/prometheus/files | |
parent | d0fb2d7a9c796b5c3e1c297e065677d4f36b314a (diff) |
prometheus: Update default tsdb directory handling
Use /srv/prometheus instead of /data, because user `prometheus` doens't
have permissions to create `/data/` in `/`.
Instead this commit puts prometheus data into `/srv/prometheus` by
default, which is a cleaner path, and it'll create tsdb path & then assign
required permissions on each prometheus service start.
This way, also, the cases when users re-configure tsdb to point to
external USB - it'll also be created and assigned required permissions for
prometheus.
Signed-off-by: Alex Simkin <sashasimkin@gmail.com>
Diffstat (limited to 'utils/prometheus/files')
-rwxr-xr-x | utils/prometheus/files/etc/init.d/prometheus | 8 | ||||
-rwxr-xr-x | utils/prometheus/files/etc/uci-defaults/prometheus-defaults | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/utils/prometheus/files/etc/init.d/prometheus b/utils/prometheus/files/etc/init.d/prometheus index a652ddfc6..99b4640b2 100755 --- a/utils/prometheus/files/etc/init.d/prometheus +++ b/utils/prometheus/files/etc/init.d/prometheus @@ -12,8 +12,14 @@ start_service() { local web_listen_address config_load "prometheus" config_get config_file prometheus config_file "$CONFFILE" - config_get storage_tsdb_path prometheus storage_tsdb_path "/data" + config_get storage_tsdb_path prometheus storage_tsdb_path "/srv/prometheus" config_get web_listen_address prometheus web_listen_address "127.0.0.1:9090" + + # Create tsdb dir & permissions if needed + if [ ! -d "$storage_tsdb_path" ]; then + mkdir "$storage_tsdb_path" + chown prometheus:prometheus "$storage_tsdb_path" + fi; procd_open_instance procd_set_param command "$PROG" diff --git a/utils/prometheus/files/etc/uci-defaults/prometheus-defaults b/utils/prometheus/files/etc/uci-defaults/prometheus-defaults index 2ce745259..9c537d2e8 100755 --- a/utils/prometheus/files/etc/uci-defaults/prometheus-defaults +++ b/utils/prometheus/files/etc/uci-defaults/prometheus-defaults @@ -6,7 +6,7 @@ uci -q get prometheus.prometheus || { uci -q batch <<EOF set prometheus.prometheus=prometheus set prometheus.prometheus.config_file='/etc/prometheus.yml' - set prometheus.prometheus.storage_tsdb_path='/data' + set prometheus.prometheus.storage_tsdb_path='/srv/prometheus' set prometheus.prometheus.web_listen_address='127.0.0.1:9090' commit prometheus EOF |