Skip to content

Binding to Unix Socket #759

Closed
Closed

Description

@Omeryl

Best I can tell, it's not possible to bind node_exporter to a unix socket, is this something that we can consider adding? (I couldn't find any issues about this after a few moments of searching, apologies of this is a duplicate issue).

Activity

  1. SuperQ commented on Dec 11, 2017

    @SuperQ
    Member

    Prometheus only supports polling targets over http/tcp. Adding unix socket support to the node_exporter wouldn't be very useful.

    What is the use case you are trying to solve?

  2. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    @SuperQ Having some potentially-sensitive metrics in a shared environment, I'd like to reverse proxy the daemon behind nginx adding basic auth support there. It's a nice to have, but not a complete deal breaker I guess.

  3. mdlayher commented on Dec 12, 2017

    @mdlayher
    Contributor

    Bind to localhost only and then go through nginx?

  4. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    @mdlayher The problem is I don't trust every user on localhost, and there's metrics I want to feed through node_exporter I don't necessarily want exposed.

  5. mdlayher commented on Dec 12, 2017

    @mdlayher
    Contributor

    And nobody else on localhost can use sudo/root and view your metrics?

  6. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    @mdlayher correct.

  7. SuperQ commented on Dec 12, 2017

    @SuperQ
    Member

    If you have sensitive metrics, I recommend not sending them through the node exporter, and adding them directly to your application, or writing your own exporter.

    Also note that basic auth is not secure. It is sent in plain text in the http headers.

  8. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    @SuperQ Why .. this is such a simple thing to add in the long run (only a few lines of change to the node_exporter).

  9. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    "Basic auth is not secure" is also a bit of a cop out here, it's a mechanism (username and password over headers) that can be verified in a number of ways, and can be rolled easily per-platform just like API keys are.

  10. mdlayher commented on Dec 12, 2017

    @mdlayher
    Contributor

    I think the problem is that this is a pretty unusual request when the rest of the prometheus ecosystem uses and expects HTTP. I would also agree that you're probably best off doing a custom exporter as I suspect the data you're concerned about would be sourced from a text file script anyway.

  11. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    @mdlayher Just because it's unusual, doesn't make it irrelevant. The alternative here would be going crazy with iptables, I suppose, but that seems bizarre when it's relatively easy to just patch node_exporter to allow unix sockets. If the Prometheus organization doesn't want to do it in repo, I guess I get to maintain my own builds instead.

  12. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    Instead, a feature request from someone really wanting to use Prometheus in our infrastructure just got shut down as meaningless in under 24 hours, which rather saddens me.

  13. SuperQ commented on Dec 12, 2017

    @SuperQ
    Member

    The node_exporter is only one exporter of hundreds. We only scrape over TCP, so adding UNIX sockets to one exporter is now a pattern we would need to follow in all exporters. This is not something we can support.

    I'm sorry if you feel this was shot down quickly, but we've had this discussion before. It's not our intention to shoot down ideas for no reason.

    Our real end goal is to develop our security guides such that we can eliminate the need for reverse proxies altogether. We think the story will be TLS + client certs. But we're not security experts, so we need time to develop a proper security story.

  14. Omeryl commented on Dec 12, 2017

    @Omeryl
    Author

    Some thoughts after discussion in IRC:

    I've been told that the node_exporter main file is basically copy and pasted between the exporters, so issuing patches would be relatively simple (this was my understanding, not something they said). The fear here is that they don't want to have to potentially support something like this on everything, when they feel like TLS auth is the way to go in the future. It has been requested that instead of this issue, I go email the prometheus-developers mailing list (which I intend to do when I get the time). Just wanted to plop this down for anybody else that stumbles upon this issue.

  15. dwfreed commented on Dec 12, 2017

    @dwfreed

    What's to support? Unix sockets don't behave any differently in the normal case where you don't care about the peer's address and aren't sending any fancy messages across. As far as net/http is concerned, it's the same thing as a TCP socket.

  16. tdewolff commented on Jan 6, 2024

    @tdewolff

    Looking from a security perspective I would love to see this decision being reconsidered. Using Unix sockets is a much cleaner approach regarding locking down access and preventing information leakage. It can be locked down with user permissions and additionally with SELinux. Reading from TCP ports is usually open though, and anyone could quite easily (eg with PHP) read from it.

    I think putting exporters behind a reverse-proxy is a very sensible idea. It prevents from opening a port for every exporter (about 8 in my case), that would double the amount of open ports on my system (and double the amount of possible attack vectors...). Additionally, it simplifies setting up Basic Auth and HTTPS for all exporters in one place, which seem to be re-implemented in about every exporter.

    Also, it would skip the whole TCP overhead locally, while allowing me to use keep alive or connection pools towards the reverse proxy.

    EDIT: just to show how important protecting the information scraped by Prometheus is: https://sysdig.com/blog/exposed-prometheus-exploit-kubernetes-kubeconeu/

  17. ws-weisb commented on Nov 13, 2024

    @ws-weisb

    Additional ports cannot be opened. Port resources are controlled in certain environments. These problems can be solved by reverse proxy, so unix socket is necessary.

  18. Shaeto commented on Nov 20, 2024

    @Shaeto

    my 5 cents - unix sockets definitely are not the same thing as tcp, access can be restricted using file system permissions, no consumption of port numbers. it is very often used for reverse proxy configuration.

  19. brandon1024 commented on Oct 16, 2026

    @brandon1024

    It might be worth revisiting this, given that prometheus now supports unix domain socket scrape targets: prometheus/prometheus#18091

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions