Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sanity when working with relative paths in config #2247

Closed
msiebuhr opened this Issue Dec 3, 2016 · 8 comments

Comments

Projects
None yet
4 participants
@msiebuhr
Copy link
Contributor

msiebuhr commented Dec 3, 2016

What did you do?
Inserted a relative path in prometheus.yml (see #2246 for some context).

scrape_configs:
  - job_name: 'mdns-sd'
    file_sd_configs:
      - files:
        - "./mdns-sd.json"

What did you expect to see?
That it resolved relative to the path of prometheus.yml (element of least surprise and all), imported the service-definitions of the file and so on.

What did you see instead? Under which circumstances?
Nothing. No errors, no internal metrics to indicate no files were found/imported.

Given I was working in an unfamiliar environment (FreeBSD jail; I'm a linux-guy), I couldn't readily find a way to find out what the working directory of the running prometheus server was (/proc/$pid/cwd doesn't exist, nor strace. Some poking at ktrace and dtrace didn't look promising without investing a lot of time in learning them, ...)

Though I did expect the menu statusRuntime & Build information to show the CWD, it didn't.

Environment

  • System information:

    FreeBSD 10.3-STABLE amd64

  • Prometheus version:

    build user:
    build date:
    go version: go1.7.3

@msiebuhr

This comment has been minimized.

Copy link
Contributor Author

msiebuhr commented Dec 3, 2016

For the record, I ended up just banging in the absolute path in the config. Ugly, but working.

@msiebuhr msiebuhr changed the title Hand out working directory in /status-page Sanity when working with relative paths in config Dec 3, 2016

@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Dec 5, 2016

Nothing. No errors, no internal metrics to indicate no files were found/imported.

That's intended behavior. We expect rule and target files to not necessarily exist at startup time.

Generally, just using absolute paths in a production config is generally more sane but might indeed be ugly for longer paths.

For rule files an API endpoint (and corresponding UI view) showing what files were discovered were could help. But exposing equally detailed runtime information on file SD etc. would be quite the maintenance burden.

@msiebuhr

This comment has been minimized.

Copy link
Contributor Author

msiebuhr commented Dec 5, 2016

Right. I can see how it'll be difficult to expose meaningful info in such corner-cases.

Wrt. the metrics, I did expect something to show up on how many targets each service-discovery mechanism coughs up with (might also be relevant in comparison w. number of scraped services).

Another brainfart - expand relative paths to absolute ones when rendering the config.file in the UI. I have a hunch that'd also be a lot of work for very little gain, but not much more.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Dec 5, 2016

I'm not sure we should be munging paths in the config. I can imagine that catching users out where the base of the path is dynamic, and they want to do a straight config copy elsewhere.

@powerman

This comment has been minimized.

Copy link

powerman commented Mar 1, 2017

Guys, do not go crazy, just resolve relative paths in config as relative to config file location - like everybody else does. Anything else is counter-intuitive and doesn't makes much sense.

Another option is ban relative paths at all. But resolving relative paths in config as relative to directory where prometheus binary was executed - is just plain wrong because may result in undefined behaviour depending on subtle environment change.

But, if you insist on current behaviour, then lifehack is:

cd /etc/prometheus && prometheus -config.file ./prometheus.yml …
@fabxc

This comment has been minimized.

Copy link
Member

fabxc commented Jul 3, 2017

So what's missing to resolve this is to apply the resolution of files paths relative to the config to file SD? (https://github.com/prometheus/prometheus/blob/dev-2.0/config/config.go#L248)
Seems like merely an oversight in the past but by now probably a breaking change.

@brian-brazil

This comment has been minimized.

Copy link
Member

brian-brazil commented Jul 3, 2017

That sounds about right to me. I think this should go in 2.0.

@fabxc fabxc closed this Jul 4, 2017

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 23, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.