Merge pull request #9638 from prometheus/superq/agentMode

Add agent mode identifier
pull/10736/head
Ben Kochie 2022-05-24 10:11:21 +02:00 committed by GitHub
commit 9570924511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 3 deletions

View File

@ -525,7 +525,14 @@ func main() {
klogv2.ClampLevel(6)
klogv2.SetLogger(log.With(logger, "component", "k8s_client_runtime"))
level.Info(logger).Log("msg", "Starting Prometheus", "version", version.Info())
modeAppName := "Prometheus Server"
mode := "server"
if agentMode {
modeAppName = "Prometheus Agent"
mode = "agent"
}
level.Info(logger).Log("msg", "Starting "+modeAppName, "mode", mode, "version", version.Info())
if bits.UintSize < 64 {
level.Warn(logger).Log("msg", "This Prometheus binary has not been compiled for a 64-bit architecture. Due to virtual memory constraints of 32-bit systems, it is highly recommended to switch to a 64-bit binary of Prometheus.", "GOARCH", runtime.GOARCH)
}
@ -629,6 +636,7 @@ func main() {
cfg.web.Notifier = notifierManager
cfg.web.LookbackDelta = time.Duration(cfg.lookbackDelta)
cfg.web.IsAgent = agentMode
cfg.web.AppName = modeAppName
cfg.web.Version = &web.PrometheusVersion{
Version: version.Version,

View File

@ -258,6 +258,7 @@ type Options struct {
RemoteReadBytesInFrame int
EnableRemoteWriteReceiver bool
IsAgent bool
AppName string
Gatherer prometheus.Gatherer
Registerer prometheus.Registerer
@ -468,11 +469,11 @@ func New(logger log.Logger, o *Options) *Handler {
router.Get("/-/healthy", func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Prometheus is Healthy.\n")
fmt.Fprintf(w, o.AppName+" is Healthy.\n")
})
router.Get("/-/ready", readyf(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Prometheus is Ready.\n")
fmt.Fprintf(w, o.AppName+" is Ready.\n")
}))
return h