40 Commits

Author SHA1 Message Date
acd843303e SQL Expression: Add instrumentation for sql expressions (#103758) 2025-04-10 19:51:44 +01:00
3539764008 Hackaton: Add more unit tests, take 3 (#101525)
* serviceaccounts/secretscan: test Service more thoroughly

* middleware/cookies: add tests for CookieOptions

* anonymous/anonimpl: cover a couple more methods

* components/imguploader: Implement WebDAV integration tests

* components/apikeygen: also check IsValid method

* bus: cover invalid callback signature cases

* cloudmigration/objectstorage: add basic unit tests

* login/social/connectors: add test case for GitHub OAuth fetch emails+orgs

* expr/classic: cover more evaluator types in tests
2025-03-05 08:00:12 +01:00
2d2e595555 Alerting: Add multiple threshold operators (#99516)
The following operators are being added:
- Equal
- Not Equal
- Greater or Equal
- Less or Equal
- Within Range Inclusive
- Outside Range Inclusive
2025-02-21 19:11:16 +02:00
126169f3ca Alerting: Add LogicOr operation option (#89258)
---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
2024-08-16 11:02:14 -04:00
9dc4221508 Alerting: Log expression command types during evaluation (#84614) 2024-03-19 10:00:03 -04:00
5f6bf93dd5 Expressions: Use enumerations rather than strings (#83741) 2024-03-01 19:38:32 +02:00
f23f50f58d Expressions: Add model struct for the query types (not map[string]any) (#82745) 2024-02-17 02:59:11 +02:00
0128d0403f Tracing: Use tracing.InitializeTracerForTest (#75479) 2023-09-27 09:51:57 +02:00
025b2f3011 Chore: use any rather than interface{} (#74066) 2023-08-30 18:46:47 +03:00
840fb32ad8 SSE: (Instrumentation) Add Tracing (#66700)
spans are prefixed `SSE.`
2023-04-18 08:04:51 -04:00
0bdb105df2 Chore: Remove xorcare/pointer dependency (#63900)
* Chore: remove pointer dependency

* fix type casts

* deprecate xorcare/pointer library in linter

* rooky mistake
2023-03-06 05:23:15 -05:00
f8ec35e643 Chore: Fix goimports grouping (#62427)
* fix goimports order

* fix goimports order
2023-01-30 09:38:51 +01:00
402dc5e4d6 Alerting: Redo refactoring from reverted fix in #56812 (#61051)
This pull request re-applies the refactoring of ConditionsCmd from a
reverted fix #56812 for mathexp.noData. It does not add the fix, or
tests for the fix, because those were added in #56816. We use the
additional test coverage added in #56816 and #58650 to avoid the
reoccurrence of regressions that caused us to revert #56812 the
first time.
2023-01-09 17:01:19 +00:00
110fdf4da9 Alerting: Fix ConditionsCmd behavior when last is No Data (#58953) 2022-11-28 21:56:22 +00:00
c9286ff794 Alerting: Remove comments for fixed behavior (#58951) 2022-11-23 15:37:15 +01:00
b77c3946a5 Alerting: Fix ConditionsCmd No Data for "has no value" (#58634)
This commit fixes a bug where ConditionsCmd returns No Data even when
the condition checks for "has no value". It should return 1 with a nil
match.
2022-11-18 09:28:21 +00:00
48c34d310c Alerting: Add tests that check current No Data behaviour with two conditions (#58650) 2022-11-18 09:04:43 +00:00
bd87b46b15 Alerting: Improve test coverage for ConditionsCmd (#58603) 2022-11-11 09:27:35 +00:00
acfa066ba2 Alerting: Change TestConditionsCmd to assert on mathexp.Results (#58434) 2022-11-09 16:07:43 +00:00
fdeefaee42 Alerting: Reorder tests in classic_test.go (#58425) 2022-11-09 09:13:47 +00:00
aa69a8463f Revert "Alerting: Fix mathexp.NoData in ConditionsCmd (#56812)" (#58423)
This reverts commit 5fa0936b7e6ee8346f7b821a5076269baac506d9.
2022-11-08 13:35:58 +00:00
5fa0936b7e Alerting: Fix mathexp.NoData in ConditionsCmd (#56812)
This commit fixes an issue where mathexp.NoData would return an error
in ConditionsCmd (Classic Condition) instead of no data. It further
refactors the Execute method to make it easier to understand.
2022-11-08 11:41:57 +00:00
2d20c8db7b Chore: Expression engine to support relative time range (#57474)
* make TimeRange interface and add relative range
* make Execute methods support the current time
* update resample to support relative time range
* update DSNode to support relative time range
* update query service to create queries with absolute time
* make alerting evaluator create relative time ranges
2022-10-26 16:13:58 -04:00
004bb7689d Alerting: Fix mathexp.NoData for ConditionsCmd (#56816) 2022-10-12 17:34:28 +01:00
67d93ceea0 Alerting: Add doc comments to classic.go (#56724) 2022-10-12 10:55:48 +01:00
2d38664fe6 Alerting: Improve validation of query and expressions on rule submit (#53258)
* Improve error messages of server-side expression 
* move validation of alert queries and a condition to eval package
2022-09-21 15:14:11 -04:00
b287047052 Chore: Upgrade Go to 1.19.1 (#54902)
* WIP

* Set public_suffix to a pre Ruby 2.6 version

* we don't need to install python

* Stretch->Buster

* Bump versions in lib.star

* Manually update linter

Sort of messy, but the .mod-file need to contain all dependencies that
use 1.16+ features, otherwise they're assumed to be compiled with
-lang=go1.16 and cannot access generics et al.

Bingo doesn't seem to understand that, but it's possible to manually
update things to get Bingo happy.

* undo reformatting

* Various lint improvements

* More from the linter

* goimports -w ./pkg/

* Disable gocritic

* Add/modify linter exceptions

* lint + flatten nested list

Go 1.19 doesn't support nested lists, and there wasn't an obvious workaround.
https://go.dev/doc/comment#lists
2022-09-12 12:03:49 +02:00
01ef899753 SSE/Alerting: Support prom instant vector responses (#44865)
* SSE/Alerting: (Draft) Support prom instant vector responses
fixes #35663
* reduce\classic expressions to handle mathexp.Number
* use Notice for warning

Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
2022-05-23 10:08:14 -04:00
a578cf0f7c SSE: Fix NoData when some series were no data but others not (#45867)
Co-authored-by: Santiago <santiagohernandez.1997@gmail.com>
2022-02-24 21:01:04 -03:00
040ce40113 SSE: Mode to drop NaN/Inf/Null in Reduction operations (#43583)
Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
2022-02-02 14:50:44 +01:00
b6a7156300 Alerting: Handle marshaling Inf values (#36947)
* SSE: change EvalMatch json value encoding to string
* update MarshalJSON on null.Float to handle inf as null
fixes #36424
2021-07-21 10:04:40 -04:00
f4e9dcd40b Alerting/SSE: Fix "count_non_null" reducer validation (#35451)
fixes error "reducer 'count_non_null' in condition 2 is not a valid reducer"
2021-06-09 14:42:48 -04:00
4093fae99a SSE: Refactor to simplify Series type (#35063)
Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
2021-06-02 12:29:19 -04:00
e19b3df1a9 Alerting: added possibility to preview grafana managed alert rules. (#34600)
* starting to add eval logic.

* wip

* first version of test rule.

* reverted file.

* add info colum to result to show error or (with CC evalmatches)

* fix labels in evalmatch

* fix be test

* refactored using observables.

* moved widht/height div to outside panel rendere.

* adding docs api level.

* adding container styles to error div.

* increasing size of preview.

Co-authored-by: kyle <kyle@grafana.com>
2021-05-26 10:06:28 +02:00
6395c649c8 SSE: fix casing on classic conditions model. (#32754) 2021-04-07 16:12:22 +02:00
0ec8879436 SSE/Alerting: Fix classic condition logic and some more tests (#32615) 2021-04-02 08:46:32 -04:00
512faa7c9c SSE: Support time series frames with non-nullable float64 values (#32608)
* SSE: fix reduce to handle non-null
* add type for data.Field that is float64 or *float64
* resample fix for non-null input case, add couple non-null tests
2021-04-01 14:33:35 -04:00
1cd8981be4 SSE/NG: Add expression metadata for EvalMatch (#32213)
- Add the ability to stick metadata attached to a value in expressions. Currently uses Frame.Meta.Custom.
- None of this is consumed by anything yet, so an incremental step.
2021-03-23 12:23:54 -04:00
7bb79158ed SSE/Alerting: First pass at query/condition translation (#31693)
- Takes the conditions property from the settings column of an alert from alerts table and turns into an ng alerting condition with the queries and classic condition.
- Has temp API rest endpoint that will take the dashboard conditions json, translate it to SEE queries + classic condition, and execute it (only enabled in dev mode).
- Changes expressions to catch query responses with a non-nil error property
- Adds two new states for an NG instance result (NoData, Error) and updates evaluation to match those states
- Changes the AsDataFrame (for frontend) from Bool to string to represent additional states
- Fix bug in condition model to accept first Operator as empty string.
- In ngalert, adds GetQueryDataRequest, which was part of execute and is still called from there. But this allows me to get the Expression request from a condition to make the "pipeline" can be built.
- Update AsDataFrame for evalresult to be row based so it displays a little better for now
2021-03-23 12:11:15 -04:00
a488ab8393 SSE: Add "Classic Condition" on backend (#31511)
This is a translation of services/alerting/conditions. Main Changes:

- Work with types in SSE (series/number) which are data frames (no more null.Float).
- The query part from alerting/conditions is handled by SSE logic
- Convey / simplejson removed.
- Time range no longer part of "query" in the condition
2021-03-02 13:51:33 -05:00