Skip to content

Commit

Permalink
grafanaNet~compatible validation: validate orgId and interval
Browse files Browse the repository at this point in the history
  • Loading branch information
Dieterbe committed Aug 16, 2018
1 parent 6fbfb1d commit 26fbd75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions imperatives/imperatives.go
Expand Up @@ -152,6 +152,7 @@ var errFmtAddDest = errors.New("addDest <routeKey> <dest>") // not implemented y
var errFmtAddRewriter = errors.New("addRewriter <old> <new> <max>")
var errFmtModDest = errors.New("modDest <routeKey> <dest> <addr/prefix/sub/regex=>") // one or more can be specified at once
var errFmtModRoute = errors.New("modRoute <routeKey> <prefix/sub/regex=>") // one or more can be specified at once
var errOrgId0 = errors.New("orgId must be a number > 0")

type Table interface {
AddAggregator(agg *aggregator.Aggregator)
Expand Down Expand Up @@ -527,6 +528,9 @@ func readAddRouteGrafanaNet(s *toki.Scanner, table Table) error {
if err != nil {
return err
}
if orgId < 1 {
return errOrgId0
}
} else {
return errFmtAddRouteGrafanaNet
}
Expand Down Expand Up @@ -598,6 +602,9 @@ func readAddRouteKafkaMdm(s *toki.Scanner, table Table) error {
if err != nil {
return errFmtAddRouteKafkaMdm
}
if orgId < 1 {
return errOrgId0
}

var bufSize = int(1e7) // since a message is typically around 100B this is 1GB
var flushMaxNum = 10000 // number of metrics
Expand Down
6 changes: 6 additions & 0 deletions route/schemas.go
@@ -1,6 +1,7 @@
package route

import (
"errors"
"fmt"
"sort"
"strconv"
Expand All @@ -23,6 +24,11 @@ func getSchemas(file string) (persister.WhisperSchemas, error) {
if len(schema.Retentions) == 0 {
return nil, fmt.Errorf("retention setting cannot be empty")
}
for _, ret := range schema.Retentions {
if ret.SecondsPerPoint() == 0 {
return nil, errors.New("cannot have interval 0")
}
}
}
if !defaultFound {
// good graphite health (not sure what graphite does if there's no .*
Expand Down

0 comments on commit 26fbd75

Please sign in to comment.