feat: add "day" as resolution for temperature graph (#823)
This commit is contained in:
@@ -30,6 +30,7 @@ const (
|
|||||||
// 60seconds * 60minutes * 24hours * 7 days * (52 + 52 + 4)weeks
|
// 60seconds * 60minutes * 24hours * 7 days * (52 + 52 + 4)weeks
|
||||||
RETENTION_PERIOD_25_MONTHS_IN_SECONDS = 65_318_400
|
RETENTION_PERIOD_25_MONTHS_IN_SECONDS = 65_318_400
|
||||||
|
|
||||||
|
DURATION_KEY_DAY = "day"
|
||||||
DURATION_KEY_WEEK = "week"
|
DURATION_KEY_WEEK = "week"
|
||||||
DURATION_KEY_MONTH = "month"
|
DURATION_KEY_MONTH = "month"
|
||||||
DURATION_KEY_YEAR = "year"
|
DURATION_KEY_YEAR = "year"
|
||||||
@@ -446,6 +447,7 @@ func (sr *scrutinyRepository) GetSummary(ctx context.Context) (map[string]*model
|
|||||||
|
|
||||||
func (sr *scrutinyRepository) lookupBucketName(durationKey string) string {
|
func (sr *scrutinyRepository) lookupBucketName(durationKey string) string {
|
||||||
switch durationKey {
|
switch durationKey {
|
||||||
|
case DURATION_KEY_DAY:
|
||||||
case DURATION_KEY_WEEK:
|
case DURATION_KEY_WEEK:
|
||||||
//data stored in the last week
|
//data stored in the last week
|
||||||
return sr.appConfig.GetString("web.influxdb.bucket")
|
return sr.appConfig.GetString("web.influxdb.bucket")
|
||||||
@@ -463,8 +465,10 @@ func (sr *scrutinyRepository) lookupBucketName(durationKey string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sr *scrutinyRepository) lookupDuration(durationKey string) []string {
|
func (sr *scrutinyRepository) lookupDuration(durationKey string) []string {
|
||||||
|
|
||||||
switch durationKey {
|
switch durationKey {
|
||||||
|
case DURATION_KEY_DAY:
|
||||||
|
//data stored in the last day
|
||||||
|
return []string{"-1d", "now()"}
|
||||||
case DURATION_KEY_WEEK:
|
case DURATION_KEY_WEEK:
|
||||||
//data stored in the last week
|
//data stored in the last week
|
||||||
return []string{"-1w", "now()"}
|
return []string{"-1w", "now()"}
|
||||||
@@ -481,8 +485,22 @@ func (sr *scrutinyRepository) lookupDuration(durationKey string) []string {
|
|||||||
return []string{"-1w", "now()"}
|
return []string{"-1w", "now()"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sr *scrutinyRepository) lookupResolution(durationKey string) string {
|
||||||
|
switch durationKey {
|
||||||
|
case DURATION_KEY_DAY:
|
||||||
|
// Return data with higher resolution for daily summaries
|
||||||
|
return "10m"
|
||||||
|
default:
|
||||||
|
// Return data with 1h resolution for other summaries
|
||||||
|
return "1h"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (sr *scrutinyRepository) lookupNestedDurationKeys(durationKey string) []string {
|
func (sr *scrutinyRepository) lookupNestedDurationKeys(durationKey string) []string {
|
||||||
switch durationKey {
|
switch durationKey {
|
||||||
|
case DURATION_KEY_DAY:
|
||||||
|
//all data is stored in a single bucket, but we want a finer resolution
|
||||||
|
return []string{DURATION_KEY_DAY}
|
||||||
case DURATION_KEY_WEEK:
|
case DURATION_KEY_WEEK:
|
||||||
//all data is stored in a single bucket
|
//all data is stored in a single bucket
|
||||||
return []string{DURATION_KEY_WEEK}
|
return []string{DURATION_KEY_WEEK}
|
||||||
|
|||||||
@@ -140,13 +140,14 @@ func (sr *scrutinyRepository) aggregateTempQuery(durationKey string) string {
|
|||||||
for _, nestedDurationKey := range nestedDurationKeys {
|
for _, nestedDurationKey := range nestedDurationKeys {
|
||||||
bucketName := sr.lookupBucketName(nestedDurationKey)
|
bucketName := sr.lookupBucketName(nestedDurationKey)
|
||||||
durationRange := sr.lookupDuration(nestedDurationKey)
|
durationRange := sr.lookupDuration(nestedDurationKey)
|
||||||
|
durationResolution := sr.lookupResolution(nestedDurationKey)
|
||||||
|
|
||||||
subQueryNames = append(subQueryNames, fmt.Sprintf(`%sData`, nestedDurationKey))
|
subQueryNames = append(subQueryNames, fmt.Sprintf(`%sData`, nestedDurationKey))
|
||||||
partialQueryStr = append(partialQueryStr, []string{
|
partialQueryStr = append(partialQueryStr, []string{
|
||||||
fmt.Sprintf(`%sData = from(bucket: "%s")`, nestedDurationKey, bucketName),
|
fmt.Sprintf(`%sData = from(bucket: "%s")`, nestedDurationKey, bucketName),
|
||||||
fmt.Sprintf(`|> range(start: %s, stop: %s)`, durationRange[0], durationRange[1]),
|
fmt.Sprintf(`|> range(start: %s, stop: %s)`, durationRange[0], durationRange[1]),
|
||||||
`|> filter(fn: (r) => r["_measurement"] == "temp" )`,
|
`|> filter(fn: (r) => r["_measurement"] == "temp" )`,
|
||||||
`|> aggregateWindow(every: 1h, fn: mean, createEmpty: false)`,
|
fmt.Sprintf(`|> aggregateWindow(every: %s, fn: mean, createEmpty: false)`, durationResolution),
|
||||||
`|> group(columns: ["device_wwn"])`,
|
`|> group(columns: ["device_wwn"])`,
|
||||||
`|> toInt()`,
|
`|> toInt()`,
|
||||||
"",
|
"",
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
<button (click)="changeSummaryTempDuration('year')" mat-menu-item>year</button>
|
<button (click)="changeSummaryTempDuration('year')" mat-menu-item>year</button>
|
||||||
<button (click)="changeSummaryTempDuration('month')" mat-menu-item>month</button>
|
<button (click)="changeSummaryTempDuration('month')" mat-menu-item>month</button>
|
||||||
<button (click)="changeSummaryTempDuration('week')" mat-menu-item>week</button>
|
<button (click)="changeSummaryTempDuration('week')" mat-menu-item>week</button>
|
||||||
|
<button (click)="changeSummaryTempDuration('day')" mat-menu-item>day</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -272,11 +272,11 @@ export class DashboardComponent implements OnInit, AfterViewInit, OnDestroy
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
DURATION_KEY_DAY = "day"
|
||||||
DURATION_KEY_WEEK = "week"
|
DURATION_KEY_WEEK = "week"
|
||||||
DURATION_KEY_MONTH = "month"
|
DURATION_KEY_MONTH = "month"
|
||||||
DURATION_KEY_YEAR = "year"
|
DURATION_KEY_YEAR = "year"
|
||||||
DURATION_KEY_FOREVER = "forever"
|
DURATION_KEY_FOREVER = "forever"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
changeSummaryTempDuration(durationKey: string): void {
|
changeSummaryTempDuration(durationKey: string): void {
|
||||||
|
|||||||
Reference in New Issue
Block a user