Skip to content

Commit

Permalink
Merge pull request GoogleCloudPlatform#2202 from justinsb/monitoringd…
Browse files Browse the repository at this point in the history
…ashboard_gcp_fidelity_5

mockgcp: monitoringDashboard should default minAlignmentPeriod in timeSeriesTable
  • Loading branch information
google-oss-prow[bot] authored Jul 1, 2024
2 parents 7a160fe + 0f2be4c commit eb03df2
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions mockgcp/mockmonitoring/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"
"fmt"
"strings"
"time"

"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -123,6 +124,12 @@ func (d *dashboardDefaulter) visitWidget(obj *pb.Widget) {

case *pb.Widget_Text:
d.visitTextWidget(content)

case *pb.Widget_PieChart:
d.visitPieChart(content.PieChart)

case *pb.Widget_TimeSeriesTable:
d.visitTimeSeriesTable(content.TimeSeriesTable)
}
}

Expand Down Expand Up @@ -153,6 +160,17 @@ func (d *dashboardDefaulter) visitTextWidget(obj *pb.Widget_Text) {
}
}

func (d *dashboardDefaulter) visitPieChart(obj *pb.PieChart) {
}

func (d *dashboardDefaulter) visitTimeSeriesTable(obj *pb.TimeSeriesTable) {
for _, dataSet := range obj.DataSets {
if dataSet.MinAlignmentPeriod == nil {
dataSet.MinAlignmentPeriod = durationpb.New(time.Duration(0))
}
}
}

type dashboardValidator struct {
errors []error
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ spec:
- column: column2
visible: false
dataSets:
- timeSeriesQuery:
- minAlignmentPeriod: 0s
timeSeriesQuery:
timeSeriesFilter:
aggregation:
alignmentPeriod: "60"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down Expand Up @@ -812,6 +813,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down Expand Up @@ -1261,6 +1263,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down Expand Up @@ -1495,6 +1498,7 @@ X-Xss-Protection: 0
],
"dataSets": [
{
"minAlignmentPeriod": "0s",
"timeSeriesQuery": {
"timeSeriesFilter": {
"aggregation": {
Expand Down

0 comments on commit eb03df2

Please sign in to comment.