mirror of
https://github.com/hanzoai/metrics.git
synced 2026-10-30 20:03:39 +00:00
This commit adds support for [Marathon](https://mesosphere.github.io/marathon/) service discovery to the scrape configuration. The following flag is introduced: ``` -promscrape.marathonSDCheckInterval duration Interval for checking for changes in Marathon service discovery. This works only if marathon_sd_configs is configured in '-promscrape.config' file. See https://docs.victoriametrics.com/sd_configs.html#marathon_sd_configs for details (default 30s) ``` The service discovery could be config like: ```yaml scrape_configs: - job_name: marathon_job marathon_sd_configs: servers: - "..." - "..." ``` See: [https://docs.victoriametrics.com/sd_configs/#marathon_sd_configs](https://github.com/VictoriaMetrics/VictoriaMetrics/blob/b555d94d1a861925759669daa86e4a9f635b0746/docs/sd_configs.md#marathon_sd_configs) related issue: https://github.com/VictoriaMetrics/VictoriaMetrics/issues/6642 --------- Co-authored-by: Zakhar Bessarab <[email protected]>
24 lines
475 B
Go
24 lines
475 B
Go
package marathon
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
)
|
|
|
|
type mockMarathonServer struct {
|
|
*httptest.Server
|
|
responseFunc func() []byte
|
|
}
|
|
|
|
func newMockMarathonServer(responseFunc func() []byte) *mockMarathonServer {
|
|
var s mockMarathonServer
|
|
s.responseFunc = responseFunc
|
|
s.Server = httptest.NewServer(http.HandlerFunc(s.handler))
|
|
return &s
|
|
}
|
|
|
|
func (s *mockMarathonServer) handler(w http.ResponseWriter, _ *http.Request) {
|
|
data := s.responseFunc()
|
|
w.Write(data)
|
|
}
|