prometheus: Cannot scrape targets specified by mDNS name
What did you do?
I am trying to scrape a target that runs node_exporter
by its mDNS name (published through Avahi) in my local network (see configuration below).
What did you expect to see?
The same behavior as specifying the IP address in targets
(which works as expected).
What did you see instead? Under which circumstances?
State of the endpoint is DOWN
in http://ptometheus.local:9090/targets, while ping
works as expected.
Environment
- System information:
# uname -srm
Linux 4.4.21-69-default x86_64
- Prometheus version:
Latest released:
# /opt/prometheus/prometheus -version
prometheus, version 1.5.2 (branch: master, revision: bd1182d29f462c39544f94cc822830e1c64cf55b)
build user: root@a8af9200f95d
build date: 20170210-14:41:22
go version: go1.7.5
Also reproduced on self-built master
:
# /opt/prometheus/prometheus -version
prometheus, version 1.5.2 (branch: master, revision: 29f05680a29afe9aa6cf119563e99723a41765bd)
build user: silvio@lenovo
build date: 20170328-11:31:33
go version: go1.7.3
- Prometheus configuration file:
global:
scrape_interval: 5s
scrape_configs:
- job_name: 'avahi'
static_configs:
- targets: ['avahi.local:9100']
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 9
- Comments: 23 (16 by maintainers)
Can I poke on this issue? It was opened on March/2017 and the last comment was December/2021 and while there’s been some interesting discussion, it has not led to any resolving of the situation-at-hand.
I would like to point out that in this day-n-age, one would expect an MDNS based hostname (RFC6763 etc) to be accepted by ALL software running on a modern-day operating system. If the
host(1)
command shows resolution of a hostname, then similar resolution should be provided. Sadly, most of the discussion here is all about GoLang’s purity vs actually solving @moio’s initial (five and half year old) issue.While I know the right thing for me to do it to buck up and send in a PR; sadly, I’m a C & Python kinda person and GoLang isn’t my forte. But I am someone that’s used Prometheus for a long time and was shocked when I spun Prometheus up at home to do some testing and found it would not cooperate across my two simply configured hosts within my
.local
DNS range. I was basically shocked (until I read this, then I was further shocked).Summary: If all other system s/w can resolve a host in the
.local
domain, so should Prometheus.Arguably it’s by far the most common SD mechanism. Not in your typical server infrastructure but using Prometheus in a home network/IoT is IMO a reasonable use case.
@msiebuhr I fully agree with this. I don’t know why proprietary, vendor specific SD mechanisms for things like triton or azure are in scope while the most widely deployed open mechanism isn’t.
I know that @SuperQ would also like to see mDNS support. So if we can find lazy consensus here, I’d probably call in a official vote on this.
@msiebuhr What were the main reasons to close the PR? I’d actually love to see this in Prometheus, with the influx of people using Prometheus for IoT use cases etc.
According to my understanding this is not the case - the Go issue above is not really about implementing mDNS resolution in the pure Go resolver.
Reproducer (
main.go
):On the commandline:
So to me the original description of this issue is still valid.
It drags in quite a few large dependencies (low-level networking to get mDNS working), and I was told in private conversation (perhaps @brian-brazil ; cannot remember) that new service discovery mechanism preferably should be built outside core prometheus.
Edit: Just re-read @brian-brazil mention a moratorium on new SD’s above. That may be where I got it from…
But yes, I generally find it weird (from a hobbyist/IoT point-of-view) that Prometheus comes with complex discovery mechanisms for some really big systems and everyone else must implement some custom cron/daemon thing poking at
file_sd
.We continue to have a moratorium on new SD mechanisms, and once the example file_sd code is in the plan is to close all existing feature requests and point to that instead.
SDs take a lot of work to maintain, and history shows that there’s little interest in doing so.
We support DNS, with would require specific mDNS support to be added.