Display correct values for the retention in the flags web gui. (#5322)

* Display correct values for the retention in the flags web gui.

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>

* adding a log entry

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>

* added the retention info to the runtime status page

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>

* simplify the retention display

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
Krasi Georgiev 2019-03-11 19:18:57 +02:00 committed by Ganesh Vernekar
parent b61c8e30dc
commit 9d96ada510
4 changed files with 28 additions and 5 deletions

View file

@ -19,7 +19,6 @@ import (
"crypto/md5" "crypto/md5"
"encoding/json" "encoding/json"
"fmt" "fmt"
"math"
"net" "net"
"net/http" "net/http"
_ "net/http/pprof" // Comment this line to disable pprof endpoint. _ "net/http/pprof" // Comment this line to disable pprof endpoint.
@ -286,9 +285,14 @@ func main() {
level.Info(logger).Log("msg", "no time or size retention was set so using the default time retention", "duration", defaultRetentionDuration) level.Info(logger).Log("msg", "no time or size retention was set so using the default time retention", "duration", defaultRetentionDuration)
} }
// Check for overflows. This limits our max retention to ~292.5y. // Check for overflows. This limits our max retention to 100y.
if cfg.tsdb.RetentionDuration < 0 { if cfg.tsdb.RetentionDuration < 0 {
cfg.tsdb.RetentionDuration = math.MaxInt64 y, err := model.ParseDuration("100y")
if err != nil {
panic(err)
}
cfg.tsdb.RetentionDuration = y
level.Info(logger).Log("msg", "time retention value is too high. Limiting to: "+y.String())
} }
} }
@ -371,6 +375,7 @@ func main() {
cfg.web.ScrapeManager = scrapeManager cfg.web.ScrapeManager = scrapeManager
cfg.web.RuleManager = ruleManager cfg.web.RuleManager = ruleManager
cfg.web.Notifier = notifierManager cfg.web.Notifier = notifierManager
cfg.web.TSDBCfg = cfg.tsdb
cfg.web.Version = &web.PrometheusVersion{ cfg.web.Version = &web.PrometheusVersion{
Version: version.Version, Version: version.Version,

View file

@ -675,9 +675,9 @@ var Assets = func() http.FileSystem {
"/templates/status.html": &vfsgen۰CompressedFileInfo{ "/templates/status.html": &vfsgen۰CompressedFileInfo{
name: "status.html", name: "status.html",
modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC), modTime: time.Date(1970, 1, 1, 0, 0, 1, 0, time.UTC),
uncompressedSize: 2625, uncompressedSize: 2730,
compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x56\x41\x6f\xe2\x3a\x10\xbe\xf3\x2b\xe6\xf9\x58\x3d\x88\xd4\xe3\x53\x88\xd4\xd2\xb7\x74\xa5\xae\x5a\x41\xd9\xee\xd5\xc4\x13\x62\x35\xd8\x68\xec\xd0\xad\x2c\xff\xf7\x95\x43\x92\x92\x15\x29\x2d\x1c\x76\x2f\xe0\xb1\xbf\x7c\xdf\xe4\x9b\xc9\x24\xce\x09\xcc\xa4\x42\x60\x39\x72\xc1\xbc\x8f\xff\x19\x0e\x41\xc9\x9f\x30\x1c\x26\xce\xa1\x12\xde\x0f\x06\x6f\xa8\x54\x2b\x8b\xca\x32\xef\x07\x00\xb1\x90\x5b\x48\x0b\x6e\xcc\xb8\x3a\xe0\x52\x21\x0d\xb3\xa2\x94\x82\x25\x03\x00\x80\x38\xbf\x04\x29\xc6\x8c\x4a\x65\xe5\x1a\x59\x32\xdb\x2d\xe0\xab\xca\x34\xad\xb9\x95\x5a\xc5\x51\x7e\x59\xa3\x2d\x5f\x16\xd8\x30\xee\x82\xea\x77\x68\xd6\xf5\x62\xa9\x49\x20\xa1\x68\xf6\x2d\xc9\x4d\x1b\xe5\x7a\x8b\x54\x2b\x07\xb6\xa5\x16\xaf\x4d\x14\x62\x7a\x0b\x42\x98\x27\x8b\x4d\x48\x26\x8e\x6c\xde\x3d\x11\x89\x73\xa3\x6b\x49\x36\x1f\x2d\x1e\x27\xde\xc7\x91\x15\x7b\x44\xd1\x3e\xd3\x01\xda\x27\x4d\xcf\x52\xad\xe0\x46\x12\xa6\x56\xd3\x6b\x8f\xc2\xe4\xe9\xe6\x28\xb7\x73\x32\x03\xa5\x2d\x8c\x66\x58\x68\x2e\x26\x5a\x65\x72\x35\x2f\xd3\x14\x8d\xf1\xbe\x31\x4b\x70\xb5\x42\x62\x75\xc5\x7e\x4f\x68\x77\x51\x49\x95\xdf\x40\x15\xd1\xe1\x9c\x64\xd6\x23\x54\x2f\xb2\xb2\x70\x0e\x0b\x83\xde\x7f\xe1\xb2\x40\x51\x2b\x7e\xd2\xa1\x3b\x6e\x2c\x98\x96\x12\xd2\x0f\x27\x38\x0a\x97\xee\x72\x7b\x94\x6b\x3c\xa9\x3e\xb7\xc8\x05\xa4\x79\xa9\x9e\x4d\x5f\x65\xc2\xe1\x44\x97\xca\x9e\x46\x5e\xf5\xb8\x41\x92\xd8\xa7\x10\x92\x9f\x57\x80\xd3\x64\x9e\xae\xee\x20\xd5\x44\xe5\x26\x58\xd6\x7b\x1f\x2d\xe2\x34\x95\xa9\x26\x5d\x5a\xa9\x7a\x6f\xa3\x05\x9c\xc8\x7f\xff\xed\xea\xc7\xc3\xec\x7e\x32\xef\xe3\x6f\x01\x27\x70\x4f\x27\xbd\xac\xd3\x77\xbb\x26\x8e\xf6\x66\x47\x1c\x55\xd3\x25\x19\x74\x26\xda\xb2\x94\x85\x90\x6f\x53\x8c\x25\xd7\x61\xe7\xef\x18\x6c\x60\x52\xbd\xc1\x31\x23\xfd\xc2\x92\xef\x48\xa6\xca\xe6\xa0\x15\xf5\x69\xf3\xff\x59\x97\x3b\x4a\x33\xdc\xca\x0f\x48\x35\xb0\xb3\xb4\xae\x89\xab\x34\x3f\xa2\xb4\x03\x9d\xa7\x13\xaa\xba\x30\x48\xc7\xa4\x1a\xdc\xf9\x6a\x37\xdc\xf6\xbd\x93\x3a\x6a\x01\x77\x96\xda\x54\x7f\xac\x37\x5a\xdc\x99\xcf\x0c\x2f\x90\xec\x9a\x2b\xbe\x42\x32\x2c\xb9\xda\x0f\xff\xd0\xc3\x52\x4d\x8a\xff\x95\xd8\x68\xa9\x6c\xd7\x86\xae\x95\xce\x51\x78\xc5\xc2\xa8\x93\x75\xf5\x19\x74\x90\xd8\xb9\xe8\x02\xf6\xb1\xb0\x98\xdd\x19\xe0\xc5\x0b\x7f\x35\x90\xf3\x2d\xc2\x3c\xcd\x71\x8d\xff\xc2\xad\x36\x16\xb8\x12\xf0\xc0\x43\x81\xd0\xc2\x45\xb4\x47\xdc\x96\x63\x87\xf7\xfe\xbf\x28\x8a\x39\xe4\x84\xd9\x98\x75\xb7\x9d\x1b\x05\x32\xef\x59\xd2\x2e\xe3\x88\x87\x20\x70\xbf\xdf\x2c\xcd\xd7\xde\x91\x72\xc6\x91\x90\xdb\x64\xd0\xa0\x7f\x05\x00\x00\xff\xff\x54\xba\xa5\x1f\x41\x0a\x00\x00"), compressedContent: []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xcc\x56\x51\x6f\xda\x30\x10\x7e\xe7\x57\xdc\xf2\x58\x0d\x22\xf5\x71\x0a\x91\x5a\xba\xd1\x49\x9d\x5a\x41\x59\xf7\x6a\xe2\x0b\xb1\x1a\x6c\x74\x76\xe8\x2a\xcb\xff\x7d\x72\x48\x02\x99\x48\x69\xc3\xc3\xf6\x02\x3e\xfb\xcb\xf7\x5d\xee\x2e\x5f\x62\x2d\xc7\x54\x48\x84\x20\x43\xc6\x03\xe7\xa2\x4f\xc3\x21\x48\xf1\x1b\x86\xc3\xd8\x5a\x94\xdc\xb9\xc1\x60\x8f\x4a\x94\x34\x28\x4d\xe0\xdc\x00\x20\xe2\x62\x0b\x49\xce\xb4\x1e\x97\x07\x4c\x48\xa4\x61\x9a\x17\x82\x07\xf1\x00\x00\x20\xca\x2e\x41\xf0\x71\x40\x85\x34\x62\x8d\x41\x3c\xdb\x2d\xe0\xbb\x4c\x15\xad\x99\x11\x4a\x46\x61\x76\x59\xa1\x0d\x5b\xe6\x58\x33\xee\x82\xf2\x77\xa8\xd7\xd5\x62\xa9\x88\x23\x21\xaf\xf7\x0d\x89\x4d\x13\x65\x6a\x8b\x54\x29\x7b\xb6\xa5\xe2\xaf\x75\xe4\x63\xda\x07\x3e\xcc\xe2\xc5\xc6\x27\x13\x85\x26\x6b\x9f\xf0\xd8\xda\xd1\xb5\x20\x93\x8d\x16\x8f\x13\xe7\xa2\xd0\xf0\x03\xa2\xf0\x90\xe9\x08\xed\x93\xa2\x67\x21\x57\x70\x23\x08\x13\xa3\xe8\xb5\x43\x61\xf2\x74\x73\x92\xdb\x5a\x91\x82\x54\x06\x46\x33\xcc\x15\xe3\x13\x25\x53\xb1\x9a\x17\x49\x82\x5a\x3b\x57\x17\x8b\x33\xb9\x42\x0a\xaa\x8e\xfd\x9d\xd0\xee\xa2\x82\xca\x7a\x03\x95\x44\xc7\x73\x12\x69\x87\x50\xb5\x48\x8b\xdc\x5a\xcc\x35\x3a\xf7\x8d\x89\x1c\x79\xa5\xf8\xc1\x0a\xdd\x31\x6d\x40\x37\x94\x90\xbc\x3b\xc1\x91\xbf\x74\x97\xdb\xa3\x58\x63\xaf\xfe\xdc\x22\xe3\x90\x64\x85\x7c\xd6\x5d\x9d\xf1\x87\x13\x55\x48\xd3\x8f\xbc\x9c\x71\x8d\x24\xb0\x4b\xc1\x27\x3f\x2f\x01\xfd\x64\x9e\xae\xee\x20\x51\x44\xc5\xc6\x97\xac\xf3\x3e\x1a\x44\x3f\x95\xa9\x22\x55\x18\x21\x3b\x6f\xa3\x01\xf4\xe4\xbf\xff\x71\xf5\xeb\x61\x76\x3f\x99\x77\xf1\x37\x80\x1e\xdc\xd3\x49\x27\xeb\xf4\xe3\x53\x33\x37\x8a\xd8\x0a\x61\x86\xde\x01\x4b\xe3\x3a\x4a\x5e\xe1\x1a\xd8\x5b\x42\x51\x78\x60\x52\x51\x58\xda\x58\x3c\x68\x59\xe7\xb2\x10\x39\x17\x7b\xbb\x0c\xe2\x6b\xbf\xf3\x7f\x38\x28\xe8\x44\x6d\x70\x1c\x90\x7a\x09\xe2\x9f\x48\xba\xbb\x2c\xd5\x69\xfd\xff\xd1\xf2\xb7\x94\x66\xb8\x15\xef\x90\xaa\x61\x67\x69\x5d\x13\x93\x49\x76\x42\x69\x07\x3a\x4f\xc7\x77\x75\xa1\x91\x4e\x49\xd5\xb8\xf3\xd5\x6e\x98\xe9\x7a\xf9\xb5\xd4\x3c\xee\x2c\xb5\xa9\x7a\xdf\x6c\x34\xb8\x33\x9f\x19\x96\x23\x99\x35\x93\x6c\x85\xa4\x83\xf8\xea\x30\xfc\x47\x0f\x4b\x69\x21\x5f\x25\xdf\x28\x21\x4d\xbb\x0c\xed\x52\x5a\x4b\xfe\x5d\x0e\xa3\x56\xd6\xe5\xf7\xd6\x51\x62\x6b\xc3\x0b\x38\xc4\xc2\x62\x76\xa7\x81\xe5\x2f\xec\x55\x43\xc6\xb6\x08\xf3\x24\xc3\x35\x7e\x86\x5b\xa5\x0d\x30\xc9\xe1\x81\xf9\x06\xa1\x81\x8b\xf0\x80\x78\xef\x60\x25\xde\xb9\x2f\x61\x18\x31\xc8\x08\xd3\x71\xd0\xde\xb6\x76\xe4\xc9\x9c\x0b\xe2\x66\x19\x85\xcc\x07\x9e\xfb\xed\x61\xa9\x3f\x2b\x4f\xb4\x33\x0a\xb9\xd8\xc6\x83\x1a\xfd\x27\x00\x00\xff\xff\x11\xc5\x18\x0b\xaa\x0a\x00\x00"),
}, },
"/templates/targets.html": &vfsgen۰CompressedFileInfo{ "/templates/targets.html": &vfsgen۰CompressedFileInfo{
name: "targets.html", name: "targets.html",

View file

@ -45,6 +45,10 @@
<th>GOGC</th> <th>GOGC</th>
<td>{{.GOGC}}</td> <td>{{.GOGC}}</td>
</tr> </tr>
<tr>
<th>Storage Retention</th>
<td>{{.StorageRetention}}</td>
</tr>
</tbody> </tbody>
</table> </table>

View file

@ -51,6 +51,7 @@ import (
"github.com/prometheus/client_model/go" "github.com/prometheus/client_model/go"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/prometheus/common/route" "github.com/prometheus/common/route"
prometheus_tsdb "github.com/prometheus/prometheus/storage/tsdb"
"github.com/prometheus/tsdb" "github.com/prometheus/tsdb"
"golang.org/x/net/netutil" "golang.org/x/net/netutil"
@ -165,6 +166,7 @@ type PrometheusVersion struct {
type Options struct { type Options struct {
Context context.Context Context context.Context
TSDB func() *tsdb.DB TSDB func() *tsdb.DB
TSDBCfg prometheus_tsdb.Options
Storage storage.Storage Storage storage.Storage
QueryEngine *promql.Engine QueryEngine *promql.Engine
ScrapeManager *scrape.Manager ScrapeManager *scrape.Manager
@ -590,6 +592,7 @@ func (h *Handler) status(w http.ResponseWriter, r *http.Request) {
TimeSeriesCount int64 TimeSeriesCount int64
LastConfigTime time.Time LastConfigTime time.Time
ReloadConfigSuccess bool ReloadConfigSuccess bool
StorageRetention string
}{ }{
Birth: h.birth, Birth: h.birth,
CWD: h.cwd, CWD: h.cwd,
@ -599,6 +602,17 @@ func (h *Handler) status(w http.ResponseWriter, r *http.Request) {
GOMAXPROCS: runtime.GOMAXPROCS(0), GOMAXPROCS: runtime.GOMAXPROCS(0),
GOGC: os.Getenv("GOGC"), GOGC: os.Getenv("GOGC"),
} }
if h.options.TSDBCfg.RetentionDuration != 0 {
status.StorageRetention = h.options.TSDBCfg.RetentionDuration.String()
}
if h.options.TSDBCfg.MaxBytes != 0 {
if status.StorageRetention != "" {
status.StorageRetention = status.StorageRetention + " or "
}
status.StorageRetention = status.StorageRetention + h.options.TSDBCfg.MaxBytes.String()
}
metrics, err := prometheus.DefaultGatherer.Gather() metrics, err := prometheus.DefaultGatherer.Gather()
if err != nil { if err != nil {
http.Error(w, fmt.Sprintf("error gathering runtime status: %s", err), http.StatusInternalServerError) http.Error(w, fmt.Sprintf("error gathering runtime status: %s", err), http.StatusInternalServerError)