Skip to content

Commit

Permalink
📝 report when query takes longer than 5 min to execute (#1551)
Browse files Browse the repository at this point in the history
* 📝 report when query takes longer than 5 min to execute

* update cnquery
  • Loading branch information
vjeffrey authored Jan 22, 2025
1 parent df2c4b7 commit a899278
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
github.com/zclconf/go-cty v1.16.1
go.mondoo.com/cnquery/v11 v11.38.0
go.mondoo.com/cnquery/v11 v11.38.1-0.20250121201112-35e8551e1b12
go.mondoo.com/mondoo-go v0.0.0-20250108144440-673a4fac8289
go.mondoo.com/ranger-rpc v0.6.5
go.opentelemetry.io/otel v1.34.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1005,8 +1005,8 @@ github.com/zclconf/go-cty-debug v0.0.0-20240509010212-0d6042c53940/go.mod h1:CmB
go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs=
go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g=
go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs=
go.mondoo.com/cnquery/v11 v11.38.0 h1:aHW/v3zQruaZYRitmox+EH2/If2flszCSqK6otPXX5c=
go.mondoo.com/cnquery/v11 v11.38.0/go.mod h1:kUmxTpKCauaNiC/Z7yrPx2qWpxf1Z7lVyBud7jFYas4=
go.mondoo.com/cnquery/v11 v11.38.1-0.20250121201112-35e8551e1b12 h1:ukQVujP+6T8bwfAJ049aTMb8K9TKQHKu2DdIrGCuDfo=
go.mondoo.com/cnquery/v11 v11.38.1-0.20250121201112-35e8551e1b12/go.mod h1:kUmxTpKCauaNiC/Z7yrPx2qWpxf1Z7lVyBud7jFYas4=
go.mondoo.com/mondoo-go v0.0.0-20250108144440-673a4fac8289 h1:D47xahKosrO4gjRtjnBte3tlHbtDAGYkEWyPXheRaac=
go.mondoo.com/mondoo-go v0.0.0-20250108144440-673a4fac8289/go.mod h1:dGj5d8BoLzVppdYI2k0Oay9pcg7bqsCYbyiBH9uhKGc=
go.mondoo.com/ranger-rpc v0.6.5 h1:KKoeTGPonJI3T6lrT9oxdH9eNlZC6pdqYvsuWZWyB6w=
Expand Down
4 changes: 4 additions & 0 deletions policy/executor/internal/execution_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ func (em *executionManager) executeCodeBundle(codeBundle *llx.CodeBundle, props
Str("qrid", codeID).
Dur("duration", time.Since(startTime)).
Msg("finished query execution")
if time.Since(startTime) > 5*time.Minute {
// if the query duration was more than 5 minutes, send an alert to platform
health.ReportSlowQuery("cnspec", cnspec.Version, cnspec.Build, health.SlowQueryInfo{Query: codeID, Duration: time.Since(startTime)})
}
}()
// TODO(jaym): sendResult may not be correct. We may need to fill in the
// checksum
Expand Down

0 comments on commit a899278

Please sign in to comment.