-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
strip rootfs prefix for run in docker #912
Conversation
54a53e5
to
487d73c
Compare
Run without
Example result metrics:
Run with
example result metric:
|
487d73c
to
0258296
Compare
- relates to prometheus#66 Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
0258296
to
de12c1c
Compare
What about making using path.rootfs as prefix for all paths? In which case you wouldn't have to modify the procfs path flags but only set the prefix flag? Then there wouldn't be a need for detecting/skipping paths. |
@SuperQ btw, you are okay with a change like this in general? Before we waste too much time.. I still think that node-exporter is ideally running on the host but not even I am doing this in most of my deployments because my host OS is immutable and I like to update node-exporter without rebuilding my VM.. |
I do think we should support docker, as long as the changes are sane. It's annoying and convoluted, but I do see the use case. |
Yeah I think the best we can do is a flag which is used consistenly for all procfs stuff, that way you only need one flag and it's easier to handle in code too. |
@discordianfish Do I understand correctly? One flag with prefix instead of 3 flags procfs, sysfs and rootfs. Something like this?
If you need to monitor host from container (for example with kubernetes DaemonSet) than you bind-mount host rootfs and use path.prefix. If this flag is set node_exporter will trim this prefix from /proc/mounts entries. procFilePath and sysFilePath methods are use path.prefix instead path.procfs and path.sysfs. |
Yes though:
I'm suggesting that they would take the path.prefix and prepend to path.procfs/path.sysfs. @SuperQ Does that make sense to you too? |
Hrm, I'm thinking we should keep the rootfs prefix separate from the other two. |
@SuperQ Can you explain what exactly you suggest and the reason for it? My proposal is clear? |
I couldn't find another way to migrate node_exporter on the host to container without breaking metrics. I've built a custom image with this patch. Is it possible to merge this pr? Then I can use official image. |
I would like to keep the docker flags as simple as possible. I like this setup proposal:
With this option do we need to prepend the |
@SuperQ That's what I was suggesting. Create a --path.prefix flag and prepend this in the code to the procfs/sysfs flags. |
@discordianfish I don't think we need to add the prefix to |
|
||
```bash | ||
docker run -d \ | ||
--net="host" \ | ||
--pid="host" \ | ||
quay.io/prometheus/node-exporter | ||
-v "/proc:/host/proc:ro" -v "/sys:/host/sys:ro" \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this PR with:
docker run -d \
--net="host" \
--pid="host" \
-v "/:/host:ro,rslave" \
node-exporter:pr-912 --path.rootfs=/host
I get the expected metrics and labels. It looks like there is no need to adjust the /proc
and /sys
mapping due to the --pid="host"
option to docker.
Ah I see, so yeah guess then we don't need to prefix them. In this case, LGTM! |
Is there any reason this wasn't merged? |
The example README update needs to be adjusted, there's no need to change volume mounts. |
I've rebased in here and updated the readme: https://github.com/prometheus/node_exporter/compare/master...marcbachmann:rootfs_prefix_66?expand=1 But with |
@diafour Can you rebase and do the change SuperQ mentioned? |
Going to close this for now. Freel free to update and re-open. |
relates to this: #66 (comment)
Introduce new argument
path.rootfs
. This argument must match the path in bind-mount of host root. The node_exporter will usepath.rootfs
as prefix to filter entries in ${path.procfs}/mounts and tocleanup it from
mountpoint
label.