mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
feat(vmagent): add promscrap config reload suppport via http (#450)
* feat(vmagent): add promscrap config reload suppport via http endpoint `/-/reload` * fix: typo fix
This commit is contained in:
parent
01c17092e1
commit
67511d4165
1 changed files with 13 additions and 0 deletions
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmagent/csvimport"
|
"github.com/VictoriaMetrics/VictoriaMetrics/app/vmagent/csvimport"
|
||||||
|
@ -157,6 +158,15 @@ func requestHandler(w http.ResponseWriter, r *http.Request) bool {
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
promscrape.WriteHumanReadableTargetsStatus(w)
|
promscrape.WriteHumanReadableTargetsStatus(w)
|
||||||
return true
|
return true
|
||||||
|
case "/-/reload":
|
||||||
|
promscrapeConfigReloadRequests.Inc()
|
||||||
|
if err := syscall.Kill(syscall.Getpid(), syscall.SIGHUP); err != nil {
|
||||||
|
promscrapeConfigReloadErrors.Inc()
|
||||||
|
httpserver.Errorf(w, "Fail to reload config file, %s", err)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -177,4 +187,7 @@ var (
|
||||||
influxQueryRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/query", protocol="influx"}`)
|
influxQueryRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/query", protocol="influx"}`)
|
||||||
|
|
||||||
promscrapeTargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/targets"}`)
|
promscrapeTargetsRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/targets"}`)
|
||||||
|
|
||||||
|
promscrapeConfigReloadRequests = metrics.NewCounter(`vmagent_http_requests_total{path="/-/reload"}`)
|
||||||
|
promscrapeConfigReloadErrors = metrics.NewCounter(`vmagent_http_request_errors_total{path="/-/reload"}`)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue