Permission error, binding prometheus data to host

2,025 views
Skip to first unread message

julia...@covus.de

unread,
Feb 28, 2018, 5:29:08 AM2/28/18
to Prometheus Users
Hey @ all,

I searched the internet for 2 hours for a solution for this error but I don't find anything that helped.
On my Mac (local machine) it runs perfect, but not on the Ubuntu 16.04 server.

Any suggestions about how I can bind the volume to my host?

This is my docker-compose.yml

    prometheus:
      build: ./prometheus
      volumes:
        - $PWD/data/prometheus/:/prometheus/
      command:
        - '--config.file=/etc/prometheus/prometheus.yml'
        - '--storage.tsdb.path=/prometheus/'
      ports:
        - 9090:9090

This my dockerfile:
FROM prom/prometheus:latest
COPY ./alert.rules    /etc/prometheus/alert.rules
COPY ./prometheus.yml /etc/prometheus/prometheus.yml

this is my error:
prometheus_1           | level=info ts=2018-02-28T10:11:06.835293385Z caller=main.go:225 msg="Starting Prometheus" version="(version=2.1.0, branch=HEAD, revision=85f23d82a045d103ea7f3c89a91fba4a93e6367a)"
prometheus_1           | level=info ts=2018-02-28T10:11:06.835373127Z caller=main.go:226 build_context="(go=go1.9.2, user=root@6e784304d3ff, date=20180119-12:01:23)"
prometheus_1           | level=info ts=2018-02-28T10:11:06.835399554Z caller=main.go:227 host_details="(Linux 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64 0467824bdb7c (none))"
prometheus_1           | level=info ts=2018-02-28T10:11:06.83542146Z caller=main.go:228 fd_limits="(soft=1048576, hard=1048576)"
prometheus_1           | level=info ts=2018-02-28T10:11:06.869426597Z caller=main.go:499 msg="Starting TSDB ..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.872220317Z caller=main.go:386 msg="Stopping scrape discovery manager..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.872510544Z caller=main.go:400 msg="Stopping notify discovery manager..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.87289764Z caller=main.go:424 msg="Stopping scrape manager..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.873057251Z caller=manager.go:460 component="rule manager" msg="Stopping rule manager..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.873182185Z caller=manager.go:466 component="rule manager" msg="Rule manager stopped"
prometheus_1           | level=info ts=2018-02-28T10:11:06.87332232Z caller=notifier.go:493 component=notifier msg="Stopping notification manager..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.876110262Z caller=web.go:383 component=web msg="Start listening for connections" address=0.0.0.0:9090
prometheus_1           | level=info ts=2018-02-28T10:11:06.877812794Z caller=main.go:382 msg="Scrape discovery manager stopped"
prometheus_1           | level=info ts=2018-02-28T10:11:06.878978146Z caller=main.go:396 msg="Notify discovery manager stopped"
prometheus_1           | level=info ts=2018-02-28T10:11:06.879220291Z caller=manager.go:59 component="scrape manager" msg="Starting scrape manager..."
prometheus_1           | level=info ts=2018-02-28T10:11:06.880479439Z caller=main.go:418 msg="Scrape manager stopped"
prometheus_1           | level=info ts=2018-02-28T10:11:06.88065055Z caller=main.go:570 msg="Notifier manager stopped"
prometheus_1           | level=error ts=2018-02-28T10:11:06.880962262Z caller=main.go:579 err="Opening storage failed open DB in /prometheus/: open /prometheus/588274413: permission denied"
prometheus_1           | level=info ts=2018-02-28T10:11:06.881120429Z caller=main.go:581 msg="See you next time!"

here my folder permission: of ./data/
drwxr-xr-x 3 root   root    4096 Feb 28 10:11 prometheus/

additional Data:
uname -srm
Linux 4.4.0-112-generic x86_64

-prometheus --version
I am using docker -> prom/prometheus:latest
--> msg="Starting Prometheus" version="(version=2.1.0, branch=HEAD, revision=85f23d82a045d103ea7f3c89a91fba4a93e6367a)"

- prometheus.yml
cat prometheus/prometheus.yml
# my global config
global:
  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

  # Attach these labels to any time series or alerts when communicating with
  # external systems (federation, remote storage, Alertmanager).
  external_labels:
      monitor: 'my-monitor'

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first.rules"
  # - "second.rules"
  - "alert.rules"

alerting:
  alertmanagers:
    - static_configs:
      - targets: ['alertmanager:9093']

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'prometheus'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['localhost:9090']

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'node-exporter'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['node-exporter:9100']

  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: 'cadvisor'

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ['cadvisor:8080']


julia...@covus.de

unread,
Feb 28, 2018, 5:42:53 AM2/28/18
to Prometheus Users
Solved this Problem:

created a group "nobody"


:~/mal/data$ sudo addgroup nobody
Done.
:~/mal/data$ sudo usermod -aG nobody nobody
:~/mal/data$ sudo chown nobody:nobody prometheus/
:~/mal/data$ ll
total
20
drwxr
-xr-x 5 worker worker  4096 Feb 28 09:56 ./
drwxrwxr
-x 7 worker worker  4096 Feb 28 10:21 ../
drwxr
-xr-x 3 nobody nobody  4096 Feb 28 10:11 prometheus/

And now this works ... 
@Prometheus team ... maybe add this to your docker README.md page!

Богдан Помазан

unread,
Jan 2, 2020, 5:13:31 AM1/2/20
to Prometheus Users
thank you

середа, 28 лютого 2018 р. 12:42:53 UTC+2 користувач juli...@covus.de написав:
Reply all
Reply to author
Forward
0 new messages