Commit graph

249 commits

Author SHA1 Message Date
net0pyr
e249d9d3a7
SQL Expressions: Add "NOT" keyword to allow list (#116802)
fix(expressions): allow NOT expressions in SQL transformations

Add *sqlparser.NotExpr to the allowlist in allowedNode() function,
enabling queries like `WHERE NOT column` and `WHERE NOT (value > 5)`.

Fixes #116616
2026-02-04 09:50:37 -05:00
Ryan McKinley
0039714046
SQLSchemas: Move the types to the query types package (#116745) 2026-01-23 17:32:46 +03:00
Will Browne
5694d6371e
Plugins: Upgrade github.com/grafana/grafana-plugin-sdk-go v0.283.0 => v0.284.0 (#114400)
Some checks failed
Integration Tests / Postgres (9/16) (push) Blocked by required conditions
Integration Tests / All backend integration tests complete (push) Blocked by required conditions
publish-technical-documentation-next / sync (push) Waiting to run
Reject GitHub secrets / reject-gh-secrets (push) Waiting to run
Build Release Packages / setup (push) Waiting to run
Build Release Packages / Dispatch grafana-enterprise build (push) Blocked by required conditions
Build Release Packages / / darwin-amd64 (push) Blocked by required conditions
Build Release Packages / / darwin-arm64 (push) Blocked by required conditions
Build Release Packages / / linux-amd64 (push) Blocked by required conditions
Build Release Packages / / linux-armv6 (push) Blocked by required conditions
Build Release Packages / / linux-armv7 (push) Blocked by required conditions
Build Release Packages / / linux-arm64 (push) Blocked by required conditions
Build Release Packages / / linux-s390x (push) Blocked by required conditions
Build Release Packages / / windows-amd64 (push) Blocked by required conditions
Build Release Packages / / windows-arm64 (push) Blocked by required conditions
Build Release Packages / Upload artifacts (push) Blocked by required conditions
Build Release Packages / publish-dockerhub (push) Blocked by required conditions
Build Release Packages / Dispatch publish NPM canaries (push) Blocked by required conditions
Build Release Packages / notify-pr (push) Blocked by required conditions
Run dashboard schema v2 e2e / dashboard-schema-v2-e2e (push) Waiting to run
Shellcheck / Shellcheck scripts (push) Waiting to run
Run Storybook a11y tests / Detect whether code changed (push) Waiting to run
Run Storybook a11y tests / Run Storybook a11y tests (light theme) (push) Blocked by required conditions
Run Storybook a11y tests / Run Storybook a11y tests (dark theme) (push) Blocked by required conditions
Swagger generated code / Detect whether code changed (push) Waiting to run
Swagger generated code / Verify committed API specs match (push) Blocked by required conditions
Dispatch sync to mirror / dispatch-job (push) Waiting to run
trigger-dashboard-search-e2e / trigger-search-e2e (push) Waiting to run
publish-kinds-next / main (push) Has been cancelled
Trivy Scan / trivy-scan (push) Has been cancelled
* upgraded github.com/grafana/grafana-plugin-sdk-go v0.283.0 => v0.284.0

* make update-workspace

* apply fixes

* nolint for FieldTypeNullableJSON instead

* fmt

* fix lint issues
2025-11-25 15:46:07 +00:00
Denis Vodopianov
0e460a267e
chore : Deprecating FeatureToggles.IsEnabled (#113062)
* Deprecating features.IsEnabled

* add one more nolint

* add one more nolint

* Give better hints to devs in the deprecation message of IsEnabledGlobally

* adding more doc strings

* fix linter after rebase

* Extend deprecation message
2025-11-21 18:43:42 +01:00
Kyle Brandt
92a6faeff2
SQL Expressions: Add Functions to Allow list (#113291)
Add assorted math, windowing, json, date/time, regex, string, conditional, and aggregation functions to allow list
2025-10-31 10:45:56 -04:00
Kevin Minehart
0a8d15dcac
SQL: Fix 32 bit arm builds (#113270)
* add arm specific frame_db_conf

* use proper field type and fix error

* add extra mising func
2025-10-31 09:42:25 +00:00
Kyle Brandt
c3d7dbc258
SQL Expressions: Add endpoint to get Schemas (#108864)
Return the SQL schema for all DS queries in request (to provide information to AI / Autocomplete for SQL expressions).

All DS queries are treated as if they were inputs to SQL expressions in terms of conversion, regardless if they are selected in a query or not.

Requires feature toggle queryService = true

Endpoint is apis/query.grafana.app/v0alpha1/namespaces/default/sqlschemas

---------

Co-authored-by: Todd Treece <360020+toddtreece@users.noreply.github.com>
2025-10-30 10:05:12 -04:00
Kyle Brandt
284648df9e
SQL Expressions: Point to grafana GMS fork (#113104)
Use fork that does not have cgo as default, had to revert build tag method attempt since it broke things like running go test on macs (without the tag) #112289.
2025-10-29 15:06:56 +00:00
Kyle Brandt
4bb91a7846
Revert "SQL Expressions: (Chore) Update GMS (go-mysql-server) depende… (#113050) 2025-10-28 06:48:57 +00:00
Kyle Brandt
0e9a3881e7
SQL Expressions: (Chore) Update GMS (go-mysql-server) dependency (#112289)
- Added gms_pure_go build tags to disable cgo - (cgo was added to GMS since we last updated it)
- Docs note on regex limitations

---------

Co-authored-by: Matheus Macabu <macabu.matheus@gmail.com>
2025-10-27 08:22:51 -04:00
Denis Vodopianov
81683d554d
chore : Deprecating FeatureToggles.IsEnabledGlobally (#112885)
* add deprecation on featuremgmt.IsEnabledGlobally

* add nolint reason

* add reasonable deprecation message

* remove junk edits

* add more nolints

* addressing review comments

* Update pkg/services/featuremgmt/models.go

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>

---------

Co-authored-by: Dave Henderson <dave.henderson@grafana.com>
2025-10-24 12:02:53 -04:00
Kyle Brandt
e930b3e6c4
SQL Expressions: Replace NaN/Inf values with Null (#112641)
This is because MySQL doesn't support storing of NaN valuels, and therefore go-mysql-server isn't going to either.

Float fields/columns are always mapped to be nullable now, otherwise we would have to replace NaN/Inf with 0.
2025-10-21 10:43:04 -04:00
Kyle Brandt
3acb8aa20e
SQL Expressions: Fix string constants in frame types (#111946)
s/time_series/timeseries and change from underscores to hyphens in numeric and ts types
This makes it more consistent with the other timeseries kind strings
2025-10-02 17:00:27 +00:00
Kyle Brandt
4583402ba9
SQL Expressions: Instrumentation fix and extra testing (#110778) 2025-09-15 13:00:22 -04:00
Kyle Brandt
00ab80a2f6
SQL Expressions: Add Exemplars to instrumentation (#110481)
follow up to #109633
2025-09-03 17:25:44 +00:00
Kyle Brandt
d97836f407
SQL Expressions: Return error on malformed input (#110479)
Fixup on a misleading error being returned due to a missing return statement in the code. Was returning the error "conversion succeeded but no frames" even though there was an error.
2025-09-02 14:49:04 -04:00
Ihor Yeromin
bdf9583ada
SSE: Return error messages instead of 500 on SSE command parse errors (#109480)
fixes #108897

---------

Co-authored-by: Kyle Brandt <kyle@grafana.com>
2025-09-02 18:00:14 +00:00
Kyle Brandt
dd4ffc9918
SQL Expressions: Add setting to limit length of query (#110165)
sql_expression_query_length_limit

Set the maximum length of a SQL query that can be used in a SQL expression. Default is 10000 characters. A setting of 0 means no limit.
2025-08-27 12:08:25 -04:00
Kyle Brandt
58c8fdad7a
SSE/QuerySvc: (Chore) Remove expression parser code and feature toggle (#110117) 2025-08-26 13:21:24 +00:00
Kyle Brandt
4f0cb47d3c
SQL Expressions: Rework backend errors and error instrumentation (#109633)
* Capture error_type label on metrics/traces
* Make error messages more helpful to user
* Use errutil, categorized errors, and tie them to error_type (category in code)
* Misc trace fixes
* Add metric to track SQL input conversion
2025-08-25 11:13:42 -04:00
Sarah Zinger
d51e6a16bc
DS-Querier: support group queries (#109879) 2025-08-22 14:59:30 -04:00
Gábor Farkas
2e5b55a855
datasources: querier: renamed the "mt" builder to "qs" builder (#109779) 2025-08-19 12:37:56 +02:00
Gábor Farkas
ed2dfd9885
datasources: querier: better error handling (#109789) 2025-08-18 14:44:50 +02:00
Kyle Brandt
466aa70179
Sql Expressions: (Chore) Dedicated logger for expr.sql, and pass context (#109549) 2025-08-13 11:20:14 -04:00
Kyle Brandt
561d5e4403
SQL Expressions: (chore) Set error on SQL Execute span (#109268) 2025-08-07 08:43:39 -04:00
Gábor Farkas
0ccfdbdfae
datasources: querier: better handling of timestamps (#108973)
* query: support query-local timestamps

* make it configurable

* lint fix

* corrected unit test

* fixed unit test
2025-08-05 08:35:57 +02:00
Sarah Zinger
f34127c449
Query Service: Fix Time Bug (#108337) 2025-07-18 18:14:44 +00:00
Sarah Zinger
3fad863fd1
Query Service: Combine SSE handling in single tenant and multi tenant paths (#108041)
* parse via sse

I need to figure out how to handle the pipeline.execute with our own
client. I think this is important for MT reasons, just like using our
own cache (via legacy) is important.

parsing is done though!

* WIP nonsense

* horrible code but i think it works

* Add support for sql expressions config settings

* Cleanup:
- remove spew from nodes.go
- uncomment out plugin context and use in single tenant flow
- make code more readable and add comments

* Cleanup:
- create separate file for mt ds client builder
- ensure error handling is the same for both expressions and regular queries
- other cleanup

* not working but good thoughts

* WIP, vector not working for non sse

* super hacky but i think vectors work now

* delete delete delete

* Comments for future ref

* break out query handling and start test

* add prom debugger

* clean up: remove comments and commented out bits

* fix query_test

* add prom debugger

* create table-driven tests with testsdata files

* Fix test

* Add test

* go mod??

* idk

* Remove comment

* go enterprise issue maybe

* Fix codeowners

* Delete

* Remove test data

* Clean up

* logger

* Remove go changes hopefully

* idk go man

* sad

* idk i ran go mod tidy and this is what it wants

* Fix readme, with much help from adam

* some linting and testing errors

* lint

* fix lint

* fix lint register.go

* another lint

* address lint in test

* fix dead code and linters for query_test

* Go mod?

* Struggling with go mod

* Fix test

* Fix another test

* Revert headers change

* Its difficult to test this in OSS as it depends on functionality defined in enterprise, let's bring these tests back in some form in enterprise

* Fix codeowners

---------

Co-authored-by: Adam Simpson <adam@adamsimpson.net>
2025-07-17 17:22:55 -04:00
Kyle Brandt
8b6329a224
SQL Expressions: Fixes for Prometheus Metric Instrumentation (#106722)
* capture errors on metrics
* rename seconds to sql_command_duration_milliseconds to match unit that has been captured, and update buckets
* rename sql_command_errors_total to sql_command_count
2025-06-17 09:23:56 -04:00
Kyle Brandt
1be9e60667
SQL Expressions: Exclude CTEs from required Tables (#106479)
Fixes #105030

---------

Co-authored-by: Sam Jewell <2903904+samjewell@users.noreply.github.com>
2025-06-11 10:36:28 -04:00
Kyle Brandt
7f1a286ffb
SQL Expressions: Always convert on type first (#106083)
fixes #103124
2025-05-28 12:00:37 -04:00
Kyle Brandt
005f390df4
SSE: Update execution order to move DS queries first (#105686)
This is part of getting SSE more consistent when run from the query service vs part of grafana-server. 
fixes #105680
2025-05-27 09:34:40 -04:00
Laura Fernández
23ecb9d904
i18n: Use grafana/i18n to init the locale and manage the regionalFormat (#105281) 2025-05-19 13:24:33 +02:00
Mariell Hoversholm
467b88eec5
Test: Make timeout 1ns to minimise flakiness (#105437) 2025-05-15 14:18:09 +02:00
Kyle Brandt
5e056c2a3f
SQL Expressions: Add sql expression specific timeout and output limit (#104834)
Adds settings for SQL expressions:
 sql_expression_cell_output_limit

Set the maximum number of cells that can be returned from a SQL expression. Default is 100000.

sql_expression_timeout

The duration a SQL expression will run before being cancelled. The default is 10s.
2025-05-13 15:22:20 -04:00
Kyle Brandt
6a6ba723a9
SQL Expressions: Add internal GMS traces (#104836)
get trace from inside GMS
2025-05-09 14:48:47 -04:00
Gilles De Mey
109267ab03
Alerting: Remove feature toggle for custom recovery threshold (#104455) 2025-04-24 11:58:17 -04:00
Nathan Vērzemnieks
af59c4eb3e
Chore: bump grafana-plugin-sdk-go from v0.275.0 to v0.277.0 (#103971)
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2025-04-17 00:32:25 +03:00
Sam Jewell
5c418196f9
SQL Expressions: Add STDDEV(), VARIANCE() and aliases (#103851)
* SQL Expressions: Bump GMS for STDDEV(), VARIANCE()

Bump Go MySQL Server to the latest version, to get support for STDDEV()
and VARIANCE() functions, and their aliases.

See https://github.com/dolthub/go-mysql-server/pull/2928

* Update app-code to comply with latest GMS version

* Run `go mod tidy`

* Update test which had depended on STDDEV being missing

* Run `make update-workspace`
2025-04-15 10:48:19 +01:00
Sam Jewell
4aa7d67edd
Server-side expressions: Improve error message (#103968)
This error message is more correct
2025-04-14 21:14:03 +00:00
Kevin Yu
fd6fd91115
Prometheus: Add support for cloud partners Prometheus data sources (#103482)
* wip

* Add prom flavor support for data source variables and export/import dashboards (#103321)

* add dashboard and data source var selection

* use match plugin id instead

* use updated matchpluginid

* formatting

* cleanup

* regex anchor

* update error msg

* Alerting: Clean up prometheus-flavored types and functions (#103703)

* clean up types and utility functions for dealing with
prometheus-flavored data sources

* Refactor alerting datasource types to use constants as source of truth

* Alerting: Clean up prometheus-flavored types and functions on the bac… (#103716)

Alerting: Clean up prometheus-flavored types and functions on the backend

* add matchPluginId tests

* Update matchPluginId func to bidirectional (#103746)

* update matchpluginid func to bidirectional

* lint

* formatting

* use actual isSupportedExternalRulesSourceType in test

* add tests in datasource_srv

* betterer

* remove type assertion

* remove unnecessary case

* use satisifies to not have to convert tuple to an array of string

* add prometheus_flavor test

---------

Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
Co-authored-by: Alexander Akhmetov <me@alx.cx>
2025-04-10 12:49:11 -07:00
Sarah Zinger
acd843303e
SQL Expression: Add instrumentation for sql expressions (#103758) 2025-04-10 19:51:44 +01:00
Mariell Hoversholm
757be6365a
CI: Bump golangci-lint to 2.0.2 (#103572) 2025-04-10 14:42:23 +02:00
Scott Lepper
aea8f27c59
Sql Expressions - remove references to poc database (#103618)
Sql Expressions - remove DuckDB references
2025-04-08 10:59:19 -04:00
Sam Jewell
f8a72214cf
SQL Expressions: Add more functions to the allowlist (#103546)
* SQL Expressions: Allow many more functions and nodes

* Also allow the `REGEXP_SUBSTR` function

* Add window functions

* add more JSON support, remove now and current time (for now)

---------

Co-authored-by: Kyle Brandt <kyle@grafana.com>
2025-04-07 21:23:39 +03:00
Kyle Brandt
b1490a10e8
SQL Expressions / Alerting: Do not allow duplicates (#103394) 2025-04-04 10:00:30 -04:00
Kyle Brandt
4a0ec27e5d
SQL Expressions: Query Service Support (#101955)
---------

Co-authored-by: Adam Simpson <adam@adamsimpson.net>
Co-authored-by: Sarah Zinger <sarah.zinger@grafana.com>
2025-04-03 09:36:02 -04:00
Kyle Brandt
c6e52c4766
SQL Expressions: Make SQL Expressions work with Alerting (#101820)
Initial support for alerting with SQL expressions

- When `format` is set to `alerting`, SQL expressions output in a format suitable for alerting evaluation.
- Outstanding TODOs:
  - Deduplicate output rows
  - Add more tests
  - Fix broken alerting UI rendering (likely due to shape change to undocumented full-long format)
- Basic usage:
  - SQL must return one numeric column and one or more string columns.
  - Each row may become an alert.
  - The alert fires if the numeric value is non-zero.
  - String columns are treated as labels.

---------

Co-authored-by: Konrad Lalik <konradlalik@gmail.com>
Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
Co-authored-by: Sam Jewell <sam.jewell@grafana.com>
2025-04-02 09:39:36 -04:00
Kyle Brandt
856dcfd6fe
SQL Expressions: Permit range conditions (between) in queries (#103238) 2025-04-02 15:13:17 +03:00
Sam Jewell
af08a9fae2
SQL Expressions: Add JSON support (#103157)
- Support bi-directional mapping of frame JSON fields and GMS (go-mysql-server) columns 
- Permit GMS json functions

Co-authored-by: Kyle Brandt <kyle@grafana.com>
2025-04-01 07:45:01 -04:00