mirror of
https://github.com/ClusterCockpit/cc-metric-store.git
synced 2024-11-13 22:47:25 +01:00
Use time.ParseDuration for intervals in config
This commit is contained in:
parent
af38004a76
commit
f8ec5994c3
38
config.json
38
config.json
@ -1,41 +1,21 @@
|
|||||||
{
|
{
|
||||||
"metrics": {
|
"metrics": {
|
||||||
"load_one": { "frequency": 3, "aggregation": null, "scope": "node" },
|
"flops_any": { "frequency": 15, "aggregation": "sum", "scope": "cpu" },
|
||||||
"load_five": { "frequency": 3, "aggregation": null, "scope": "node" },
|
"flops_dp": { "frequency": 15, "aggregation": "sum", "scope": "cpu" },
|
||||||
"load_fifteen": { "frequency": 3, "aggregation": null, "scope": "node" },
|
"flops_sp": { "frequency": 15, "aggregation": "sum", "scope": "cpu" },
|
||||||
"proc_run": { "frequency": 3, "aggregation": null, "scope": "node" },
|
"mem_bw": { "frequency": 15, "aggregation": "sum", "scope": "socket" },
|
||||||
"proc_total": { "frequency": 3, "aggregation": null, "scope": "node" },
|
"load_one": { "frequency": 15, "aggregation": null, "scope": "node" }
|
||||||
"mem_free": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_cached": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_total": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"swap_total": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_slab": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_buffers": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_sreclaimable": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_available": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"swap_free": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"mem_used": { "frequency": 3, "aggregation": null, "scope": "node" },
|
|
||||||
"cpu_user": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_nice": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_system": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_idle": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_iowait": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_irq": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_softirq": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_steal": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_guest": { "frequency": 3, "aggregation": "sum", "scope": "cpu" },
|
|
||||||
"cpu_guest_nice": { "frequency": 3, "aggregation": "sum", "scope": "cpu" }
|
|
||||||
},
|
},
|
||||||
"checkpoints": {
|
"checkpoints": {
|
||||||
"interval": 60,
|
"interval": "12h",
|
||||||
"directory": "./var/checkpoints",
|
"directory": "./var/checkpoints",
|
||||||
"restore": 120
|
"restore": "48h"
|
||||||
},
|
},
|
||||||
"archive": {
|
"archive": {
|
||||||
"interval": 180,
|
"interval": "168h",
|
||||||
"directory": "./var/archive"
|
"directory": "./var/archive"
|
||||||
},
|
},
|
||||||
"retention-in-memory": 120,
|
"retention-in-memory": "48h",
|
||||||
"http-api-address": "0.0.0.0:8081",
|
"http-api-address": "0.0.0.0:8081",
|
||||||
"nats": null,
|
"nats": null,
|
||||||
"jwt-public-key": "kzfYrYy+TzpanWZHJ5qSdMj5uKUWgq74BWhQG6copP0="
|
"jwt-public-key": "kzfYrYy+TzpanWZHJ5qSdMj5uKUWgq74BWhQG6copP0="
|
||||||
|
@ -22,17 +22,17 @@ type MetricConfig struct {
|
|||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Metrics map[string]MetricConfig `json:"metrics"`
|
Metrics map[string]MetricConfig `json:"metrics"`
|
||||||
RetentionInMemory int `json:"retention-in-memory"`
|
RetentionInMemory string `json:"retention-in-memory"`
|
||||||
Nats string `json:"nats"`
|
Nats string `json:"nats"`
|
||||||
JwtPublicKey string `json:"jwt-public-key"`
|
JwtPublicKey string `json:"jwt-public-key"`
|
||||||
HttpApiAddress string `json:"http-api-address"`
|
HttpApiAddress string `json:"http-api-address"`
|
||||||
Checkpoints struct {
|
Checkpoints struct {
|
||||||
Interval int `json:"interval"`
|
Interval string `json:"interval"`
|
||||||
RootDir string `json:"directory"`
|
RootDir string `json:"directory"`
|
||||||
Restore int `json:"restore"`
|
Restore string `json:"restore"`
|
||||||
} `json:"checkpoints"`
|
} `json:"checkpoints"`
|
||||||
Archive struct {
|
Archive struct {
|
||||||
Interval int `json:"interval"`
|
Interval string `json:"interval"`
|
||||||
RootDir string `json:"directory"`
|
RootDir string `json:"directory"`
|
||||||
} `json:"archive"`
|
} `json:"archive"`
|
||||||
}
|
}
|
||||||
@ -57,10 +57,14 @@ func intervals(wg *sync.WaitGroup, ctx context.Context) {
|
|||||||
wg.Add(3)
|
wg.Add(3)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
d := time.Duration(conf.RetentionInMemory) * time.Second
|
d, err := time.ParseDuration(conf.RetentionInMemory)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
if d <= 0 {
|
if d <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ticks := time.Tick(d / 2)
|
ticks := time.Tick(d / 2)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -82,10 +86,14 @@ func intervals(wg *sync.WaitGroup, ctx context.Context) {
|
|||||||
lastCheckpoint = time.Now()
|
lastCheckpoint = time.Now()
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
d := time.Duration(conf.Checkpoints.Interval) * time.Second
|
d, err := time.ParseDuration(conf.Checkpoints.Interval)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
if d <= 0 {
|
if d <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ticks := time.Tick(d)
|
ticks := time.Tick(d)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -108,10 +116,14 @@ func intervals(wg *sync.WaitGroup, ctx context.Context) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
d := time.Duration(conf.Archive.Interval) * time.Second
|
d, err := time.ParseDuration(conf.Archive.Interval)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
if d <= 0 {
|
if d <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ticks := time.Tick(d)
|
ticks := time.Tick(d)
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
@ -140,7 +152,12 @@ func main() {
|
|||||||
conf = loadConfiguration(configFile)
|
conf = loadConfiguration(configFile)
|
||||||
memoryStore = NewMemoryStore(conf.Metrics)
|
memoryStore = NewMemoryStore(conf.Metrics)
|
||||||
|
|
||||||
restoreFrom := startupTime.Add(-time.Duration(conf.Checkpoints.Restore) * time.Second)
|
d, err := time.ParseDuration(conf.Checkpoints.Restore)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
restoreFrom := startupTime.Add(d)
|
||||||
log.Printf("Loading checkpoints newer than %s\n", restoreFrom.Format(time.RFC3339))
|
log.Printf("Loading checkpoints newer than %s\n", restoreFrom.Format(time.RFC3339))
|
||||||
files, err := memoryStore.FromCheckpoint(conf.Checkpoints.RootDir, restoreFrom.Unix())
|
files, err := memoryStore.FromCheckpoint(conf.Checkpoints.RootDir, restoreFrom.Unix())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user