mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 13:57:36 -08:00
api: Add two new fields Node and ServerTime.
This commit introduced two field in `/status` endpoint: - The node currently serving the request. - The current server time for debugging time drift issues. fixes #15394. Signed-off-by: sujal shah <sujalshah28092004@gmail.com>
This commit is contained in:
parent
8784e28e18
commit
73a3438c1b
|
@ -1158,6 +1158,8 @@ $ curl http://localhost:9090/api/v1/status/runtimeinfo
|
||||||
"data": {
|
"data": {
|
||||||
"startTime": "2019-11-02T17:23:59.301361365+01:00",
|
"startTime": "2019-11-02T17:23:59.301361365+01:00",
|
||||||
"CWD": "/",
|
"CWD": "/",
|
||||||
|
"hostname" : "DESKTOP-717H17Q",
|
||||||
|
"serverTime": "2025-01-05T18:27:33Z",
|
||||||
"reloadConfigSuccess": true,
|
"reloadConfigSuccess": true,
|
||||||
"lastConfigTime": "2019-11-02T17:23:59+01:00",
|
"lastConfigTime": "2019-11-02T17:23:59+01:00",
|
||||||
"timeSeriesCount": 873,
|
"timeSeriesCount": 873,
|
||||||
|
|
|
@ -144,6 +144,8 @@ type PrometheusVersion struct {
|
||||||
type RuntimeInfo struct {
|
type RuntimeInfo struct {
|
||||||
StartTime time.Time `json:"startTime"`
|
StartTime time.Time `json:"startTime"`
|
||||||
CWD string `json:"CWD"`
|
CWD string `json:"CWD"`
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
ServerTime time.Time `json:"serverTime"`
|
||||||
ReloadConfigSuccess bool `json:"reloadConfigSuccess"`
|
ReloadConfigSuccess bool `json:"reloadConfigSuccess"`
|
||||||
LastConfigTime time.Time `json:"lastConfigTime"`
|
LastConfigTime time.Time `json:"lastConfigTime"`
|
||||||
CorruptionCount int64 `json:"corruptionCount"`
|
CorruptionCount int64 `json:"corruptionCount"`
|
||||||
|
|
|
@ -29,6 +29,12 @@ export default function StatusPage() {
|
||||||
formatTimestamp(new Date(v as string).valueOf() / 1000, useLocalTime),
|
formatTimestamp(new Date(v as string).valueOf() / 1000, useLocalTime),
|
||||||
},
|
},
|
||||||
CWD: { title: "Working directory" },
|
CWD: { title: "Working directory" },
|
||||||
|
hostname: { title: "Hostname" },
|
||||||
|
serverTime: {
|
||||||
|
title: "Server Time",
|
||||||
|
formatValue: (v: string | boolean) =>
|
||||||
|
formatTimestamp(new Date(v as string).valueOf() / 1000, useLocalTime),
|
||||||
|
},
|
||||||
reloadConfigSuccess: {
|
reloadConfigSuccess: {
|
||||||
title: "Configuration reload",
|
title: "Configuration reload",
|
||||||
formatValue: (v: string | boolean) => (v ? "Successful" : "Unsuccessful"),
|
formatValue: (v: string | boolean) => (v ? "Successful" : "Unsuccessful"),
|
||||||
|
|
|
@ -804,6 +804,13 @@ func (h *Handler) runtimeInfo() (api_v1.RuntimeInfo, error) {
|
||||||
GODEBUG: os.Getenv("GODEBUG"),
|
GODEBUG: os.Getenv("GODEBUG"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hostname, err := os.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
return status, fmt.Errorf("Error getting hostname: %w", err)
|
||||||
|
}
|
||||||
|
status.Hostname = hostname
|
||||||
|
status.ServerTime = time.Now().UTC()
|
||||||
|
|
||||||
if h.options.TSDBRetentionDuration != 0 {
|
if h.options.TSDBRetentionDuration != 0 {
|
||||||
status.StorageRetention = h.options.TSDBRetentionDuration.String()
|
status.StorageRetention = h.options.TSDBRetentionDuration.String()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue