Skip to content

Commit

Permalink
feat: update query load
Browse files Browse the repository at this point in the history
  • Loading branch information
nick-bisonai committed Aug 13, 2024
1 parent e4b524f commit fd7a424
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 11 additions & 1 deletion node/pkg/checker/dal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ func checkDalTraffic(ctx context.Context, pool *pgxpool.Pool) error {
case <-ctx.Done():
return nil
default:
result, err := db.QueryRowTransient[Count](ctx, pool, TrafficCheckQuery, map[string]any{})
result, err := db.QueryRowTransient[Count](ctx, pool, getTrafficCheckQuery(), map[string]any{})
if err != nil {
log.Error().Err(err).Msg("failed to check DAL traffic")
return err
Expand All @@ -300,3 +300,13 @@ func checkDalTraffic(ctx context.Context, pool *pgxpool.Pool) error {
return nil
}
}

func getTrafficCheckQuery() string {
keysToIgnore := strings.Split(IgnoreKeys, ",")
modified := []string{}
for _, desc := range keysToIgnore {
modified = append(modified, fmt.Sprintf("'%s'", desc))
}

return fmt.Sprintf(TrafficCheckQuery, strings.Join(modified, ", "))
}
3 changes: 2 additions & 1 deletion node/pkg/checker/dal/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const (
AlarmOffset = 3
WsDelayThreshold = 9 * time.Second
WsPushThreshold = 5 * time.Second
IgnoreKeys = "test,sentinel,orakl_reporter"
TrafficCheckQuery = `select count(1) from rest_calls where
timestamp > current_timestamp - INTERVAL '10 seconds' AND
api_key NOT IN (SELECT key from keys WHERE description IN ('test', 'sentinel', 'orakl_reporter'))`
api_key NOT IN (SELECT key from keys WHERE description IN (%s))`
TrafficThreshold = 100
)

Expand Down

0 comments on commit fd7a424

Please sign in to comment.