Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝 report when query takes longer than 5 min to execute #1551

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)})
Copy link
Contributor

@jaym jaym Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have the mql, it might make life easier

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i couldnt find where to access the mql string from this context, but ya that would be awesome if we can

}
}()
// TODO(jaym): sendResult may not be correct. We may need to fill in the
// checksum
Expand Down
Loading