mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-11 13:57:36 -08:00
Merge pull request #15784 from sujalshah-bit/15394_server_name_and_time
api: Add two new fields Hostname and ServerTime.
This commit is contained in:
commit
18bb8bf996
|
@ -1158,6 +1158,8 @@ $ curl http://localhost:9090/api/v1/status/runtimeinfo
|
|||
"data": {
|
||||
"startTime": "2019-11-02T17:23:59.301361365+01:00",
|
||||
"CWD": "/",
|
||||
"hostname" : "DESKTOP-717H17Q",
|
||||
"serverTime": "2025-01-05T18:27:33Z",
|
||||
"reloadConfigSuccess": true,
|
||||
"lastConfigTime": "2019-11-02T17:23:59+01:00",
|
||||
"timeSeriesCount": 873,
|
||||
|
|
|
@ -144,6 +144,8 @@ type PrometheusVersion struct {
|
|||
type RuntimeInfo struct {
|
||||
StartTime time.Time `json:"startTime"`
|
||||
CWD string `json:"CWD"`
|
||||
Hostname string `json:"hostname"`
|
||||
ServerTime time.Time `json:"serverTime"`
|
||||
ReloadConfigSuccess bool `json:"reloadConfigSuccess"`
|
||||
LastConfigTime time.Time `json:"lastConfigTime"`
|
||||
CorruptionCount int64 `json:"corruptionCount"`
|
||||
|
|
|
@ -29,6 +29,12 @@ export default function StatusPage() {
|
|||
formatTimestamp(new Date(v as string).valueOf() / 1000, useLocalTime),
|
||||
},
|
||||
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: {
|
||||
title: "Configuration reload",
|
||||
formatValue: (v: string | boolean) => (v ? "Successful" : "Unsuccessful"),
|
||||
|
|
|
@ -806,6 +806,13 @@ func (h *Handler) runtimeInfo() (api_v1.RuntimeInfo, error) {
|
|||
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 {
|
||||
status.StorageRetention = h.options.TSDBRetentionDuration.String()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue