diff --git a/cmd/client/main.go b/cmd/client/main.go index 74d715b..b8f2d47 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -174,7 +174,7 @@ func loop(c Coordinator, client *http.Client) error { level.Error(c.logger).Log("msg", "Error parsing url:", "err", err) return errors.Wrap(err, "error parsing url") } - u, err := url.Parse("poll") + u, err := url.Parse("poll/" + *myFqdn) if err != nil { level.Error(c.logger).Log("msg", "Error parsing url:", "err", err) return errors.Wrap(err, "error parsing url poll") diff --git a/cmd/proxy/main.go b/cmd/proxy/main.go index 4ea2246..2f93a13 100644 --- a/cmd/proxy/main.go +++ b/cmd/proxy/main.go @@ -99,6 +99,7 @@ func newHTTPHandler(logger log.Logger, coordinator *Coordinator, mux *http.Serve handlers := map[string]http.HandlerFunc{ "/push": h.handlePush, "/poll": h.handlePoll, + "/poll/": h.handlePollWithPath, "/clients": h.handleListClients, "/metrics": promhttp.Handler().ServeHTTP, } @@ -144,7 +145,17 @@ func (h *httpHandler) handlePush(w http.ResponseWriter, r *http.Request) { // handlePoll handles clients registering and asking for scrapes. func (h *httpHandler) handlePoll(w http.ResponseWriter, r *http.Request) { fqdn, _ := ioutil.ReadAll(r.Body) - request, err := h.coordinator.WaitForScrapeInstruction(strings.TrimSpace(string(fqdn))) + h.pollWithFQDN(string(fqdn), w) +} + +// handlePoll handles clients registering and asking for scrapes. +func (h *httpHandler) handlePollWithPath(w http.ResponseWriter, r *http.Request) { + fqdn := r.URL.Path[len("/poll/"):] + h.pollWithFQDN(fqdn, w) +} + +func (h *httpHandler) pollWithFQDN(fqdn string, w http.ResponseWriter) { + request, err := h.coordinator.WaitForScrapeInstruction(strings.TrimSpace(fqdn)) if err != nil { level.Info(h.logger).Log("msg", "Error WaitForScrapeInstruction:", "err", err) http.Error(w, fmt.Sprintf("Error WaitForScrapeInstruction: %s", err.Error()), 408)