Commit Graph

58 Commits

Author SHA1 Message Date
Alex Spencer 84bd99f1c1
SQL Expressions: Update to feature badges (#112795)
* chore: update badge + update logic

* chore: update comment
2025-11-04 08:18:15 -08:00
Alex Spencer e478ee2e5f
Event Tracking: Add event tracking for expression queries (#110983)
* chore: add event tracking for expressions

* chore: fix lint

* chore: cleanup

* fix: update commenet

* chore: prune suppressions

* feedback

* update events

* chore: more pr feedback

* chore: only add __expr__ query types to event tracking

* chore: make it work with v2 dashboard spec!

* chore: linter!

* chore: tests!
2025-10-20 09:25:43 +01:00
Sonia Aguilar 4ea85b7feb
Alerting: Fix threshold params (#111645)
* fix threshold params

* update tests
2025-09-26 08:28:33 +02:00
Alex Spencer 73a1320334
SQL Expressions: Add editor toolbox (#109298)
* init: feature work

* chore: i18n

* feat: add run query + keyboard shortcuts

* chore: i18n

* chore: initial query formatted

* chore: resolve some issues

* chore: a bit of refactor to clean it up

---------

Co-authored-by: Kristina Durivage <kristina.durivage@grafana.com>
2025-08-13 11:43:01 -07:00
Alex Spencer 31fc7d5d7a
SQL Expressions: LLM plugin integration - SQL suggestions and SQL explanations (#107545)
* init: first pass at AI generated SQL expressions

* chore: fixes to tests

* i18n

* chore: small GenAIButton style update

* lazy load the genAI button - circular dependency issue in our test mocks...?

* chore: polish

* fix: i18n

* feat: make it a whole lot more capable

* chore: extract prompt logic to common file

* chore: consolidate state management to custom hooks

* chore: clean up, update GenAIButton API, etc.

* chore: major sql prompt improvement + plan for future + genAIButton api update

* chore: polish for now

* chore: clean up folder structure

* chore: conditionally use hooks + improve prompt

* chore: betterer....

* chore: polish

* feat: testing 🚀

* chore: polish polish polish

* chore: remove startWithPrompt

* chore: timeout 30

* chore: add experimental badge

* i18n + 60 sec timeout

* chore: MOAR POLISH

* chore: clean up explanation drawer

* chore: update tests

* chore: update FF checks

* chore: get the rendering w/FF correct

* chore: fix tests

* chore: re-work ai tooltips

* chore: cleanup

* chore: handle sql button styling differently

* chore: fix styling last time
2025-08-13 09:24:04 -07:00
Kristina 5bfed408ed
SQL Expressions: Enable Auto-complete (#106511)
* First draft autocomplete

* Better naming

* Change suggestion to table/column population

* Remove all suggestions, just use table/column population but trigger on space

* Gate feature flag behind a feature flag

* Reorganize and add function list

* Add blurb about autocomplete to docs

* Update public/app/features/expressions/utils/metaSqlExpr.ts

Co-authored-by: Alex Spencer <52186778+alexjonspencer1@users.noreply.github.com>

* Add try catch, remove promise resolve

---------

Co-authored-by: Alex Spencer <52186778+alexjonspencer1@users.noreply.github.com>
2025-07-23 16:49:58 -05:00
Alex Spencer 869094bb37
SQL Expressions: Reconfigure add expression button for improved UX (#106797)
* feat: reconfigure expression button for improved UX

* chore: fix broken test

* chore: refactor to use improved UX + combine another UI PR.

* chore: i18n

* chore: memoize options + add data test ids for tracking

* chore: common component for expression dropdown

* chore: streamline common component

* chore: add event tracking

* chore: put event tracking in its own PR
2025-07-08 14:11:54 -07:00
Hugo Häggmark 2b8c74de2e
i18n: removes useTranslate hook (#106556)
* i18n: removes useTranslate hook

* chore: fix duplicate imports

* chore: fix import sorting and hook dependencies
2025-06-12 11:03:52 +02:00
Hugo Häggmark 119d5897ea
i18n: imports use @grafana/i18n (#105177)
* i18n: everything should target @grafana/i18n

* wip

* chore: updates after PR feedback

* Trigger build

* Trigger build

* Trigger build

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: skip flaky tests

* chore: revert all flaky tests

* chore: some incorrect usages of useTranslate
2025-05-15 09:17:14 +02:00
Pepe Cano d6d5771aff
alerting: update UI text to clarify recovery threshold for pending state (#102788)
* alerting: update UI text to clarify recovery threshold for pending state

* Update recent translation
2025-04-28 10:42:37 +02:00
Gilles De Mey 109267ab03
Alerting: Remove feature toggle for custom recovery threshold (#104455) 2025-04-24 11:58:17 -04:00
Ashley Harrison e42cca9527
Chore: fix translations missing keys (#104314)
fix translations missing keys
2025-04-22 17:51:32 +01:00
Ashley Harrison 9ed3c9ee8a
Internationalisation: Final mark up of strings (#104165)
* some more markup

* more markup

* more markup

* almost there...

* more markup

* more markup

* last markup!

* fix unit tests
2025-04-22 11:02:01 +01:00
Ashley Harrison a2b06e2ec9
Internationalisation: More markup (#103970)
* more markup!

* fix tests

* use times symbol
2025-04-15 10:05:03 +01: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
Sam Jewell cd30742616
SQL Expressions: Mount front-end component right first time (#103087)
* Call onChange method once on render so we have access to the value on init

---------

Co-authored-by: Tom Ratcliffe <tom.ratcliffe@grafana.com>
2025-04-01 11:49:39 -04:00
Sam Jewell 3366d74411
SQL Expressions: Improve placeholder SQL Query (#103092)
This gives the user more hints as to how to succeed with SQL Expressions
2025-03-31 13:29:12 +01:00
Ashley Harrison dc5badd9b2
Internationalisation: More automatic markup (#102792)
* more automatic i18n markup

* better labels

* little bit of tidy up

* fix unit tests
2025-03-27 10:12:25 +00:00
Sam Jewell 8cc352f4ba
SQL Expressions: Add syntax highlighting and autocomplete (#102018)
* SQL Expressions: Add syntax highlighting and autocomplete

Here we add syntax highlighting and autocomplete for MySQL dialect of
SQL. We don't yet have the full functionality that other SQL monaco
editors have, namely
- No autocomplete of table or column names
- No autoformatting yet (meaning no formatting of template variables)

But this is a vast improvement already. The above improvements can come
later - they are slightly harder to do.

* Improvements, based on review from LLM
2025-03-12 11:27:31 +00:00
Sam Jewell 47f82a0c16
SQL Expressions: Resizable code-editor (#101407)
* Resizeable SQL expressions text-area

Generated by an LLM for me - we'll see. It expands quite large on first
page-load

* Switch to useLayoutEffect to avoid visual flashing

* Get the LLM to rewrite the approach, inspired by InfluxDB

The Influx DB text-area is also resizable vertically, but that one isn't
a Monaco editor (we need to tell Monaco to update its own size when the
outer div is resized), so this is necessarily a little more complex than
Influx. But still this approach looks simpler: The Javascript here is
shorter

* Start at 240px, to match the current default size

Question: Is there a better approach to achieve this?

* Don't clip the bottom border of the Monaco editor

* Fix linting errors
2025-03-05 15:52:07 +00:00
Paulo Dias 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
Ivana Huckova 7c15d33304
Remove @grafana/experimental in the last various places (#99875)
* Remove @grafana/experimental in the last various places

* Remove experimental from yarn.lock

* Fix import order
2025-01-31 15:43:58 +02:00
Tom Ratcliffe 52c95f77cd
Alerting: Include error from current condition when previewing queries (#98202) 2025-01-20 17:56:21 +00:00
Gilles De Mey 0e4b503352
Alerting: Hide reducer hint for alert creation editor (#98410) 2024-12-31 11:58:01 +01:00
Shubhankar Unhale 436f68da3a
Expressions: Add notification for Strict Mode behavior in Reduce component (#97224)
* Add strict mode notification to Reduce component with i18n support

* Added translation keys
2024-12-29 11:58:21 +00:00
Sonia Aguilar d92e17ee55
Alerting: Create reusable components for threshold (#94045)
* Create reusable components for threshold

* update translations

* do not use capital letters for keys in translations
2024-11-08 18:15:29 +02:00
Ashley Harrison b23b6d228a
Chore: Convert styles to use emotion object syntax (#94989)
* convert to use emotion object syntax

* missed one

* review comments

* set back to 0 and disable lint rule
2024-10-23 15:25:28 +01:00
Lu Shueh Chou 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
Ashley Harrison 47f8717149
React: Use new JSX transform (#88802)
* update eslint, tsconfig + esbuild to handle new jsx transform

* remove thing that breaks the new jsx transform

* remove react imports

* adjust grafana-icons build

* is this the correct syntax?

* try this

* well this was much easier than expected...

* change grafana-plugin-configs webpack config

* fixes

* fix lockfile

* fix 2 more violations

* use path.resolve instead of require.resolve

* remove react import

* fix react imports

* more fixes

* remove React import

* remove import React from docs

* remove another react import
2024-06-25 12:43:47 +01:00
Ashley Harrison 670960f70c
Chore: Upgrade redux (#86877)
* update packages

* fix type errors

* upgrade redux toolkit as well

* don't need eslint-disable command

* remove comment

* fix unit tests

* call rtk query selector directly

* remove unnecessary checks
2024-05-10 14:28:51 +01:00
Scott Lepper 70009201d4
Expressions: Sql expressions with Duckdb (#81666)
duckdb temp storage of dataframes using parquet and querying from sql expressions
---------

Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-02-27 16:16:00 -05:00
Yuri Tseretyan f6a46744a6
Alerting: Support hysteresis command expression (#75189)
Backend: 

* Update the Grafana Alerting engine to provide feedback to HysteresisCommand. The feedback information is stored in state.Manager as a fingerprint of each state. The fingerprint is persisted to the database. Only fingerprints that belong to Pending and Alerting states are considered as "loaded" and provided back to the command.
   - add ResultFingerprint to state.State. It's different from other fingerprints we store in the state because it is calculated from the result labels.
  -  add rule_fingerprint column to alert_instance
   - update alerting evaluator to accept AlertingResultsReader via context, and update scheduler to provide it.
   - add AlertingResultsFromRuleState that implements the new interface in eval package
   - update getExprRequest to patch the hysteresis command.

* Only one "Recovery Threshold" query is allowed to be used in the alert rule and it must be the Condition.


Frontend:

* Add hysteresis option to Threshold in UI. It's called "Recovery Threshold"
* Add test for getUnloadEvaluatorTypeFromCondition
* Hide hysteresis in panel expressions

* Refactor isInvalid and add test for it
* Remove unnecesary React.memo
* Add tests for updateEvaluatorConditions

---------

Co-authored-by: Sonia Aguilar <soniaaguilarpeiron@gmail.com>
2024-01-04 11:47:13 -05:00
Alex Khomenko 25779bb6e5
Stack: Use the component from grafana/ui (#77543)
* grafana/ui: Move Stack out of unstable

* grafana/ui: Replace imports

* Replace the import from experimental

* Cleanup

* Remove invalid prop

* Add flexGrow

* Remove Stack used in Field

* Remove import
2023-11-06 18:15:52 +02:00
Ashley Harrison 963fffeef1
Chore: fix some more types (#72726)
fix some more types
2023-08-14 16:04:04 +01:00
Ashley Harrison e0587dfb30
Chore: Replace deprecated usage of `shape.borderRadius()` (#72672)
* properly mark borderRadius() as deprecated, replace borderRadius() with default

* undo a couple of changes

* use radius.pill in FilterPill
2023-08-01 14:46:07 +01:00
Sonia Aguilar 0e4a8b01ab
Alerting: Use ToggleTip instead of Hovercard in the info popup on Math expressions (#70881)
* Use ToggleTip instead of Hovercard in the info popup on Math expressions

* Address review comments
2023-06-29 20:02:30 +02:00
Sonia Aguilar b0ac49926d
Alerting: Expression card improvements (#70395)
* Show description for each expression type in the body and change widht depending on the type

* Move condition indicator to the header

* Make order of fields in expressions to be consistent for each expression type

* Add tooltip for expression type menu

* Update styles depending on the expression type

* Update styles and move add query button under queries

* Add NeedHelpInfo component

* Adress PR review comments

* Apply description updates from #70540

* Rename gelTypes to expressionTypes

* Update layout for expressions according to the real usecases

* Update footer to include series count in all expressions

---------

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2023-06-27 11:35:56 +02:00
Ryan McKinley d710507bc5
Chore: Avoid explicit `React.FC<Props>` when possible (#64722) 2023-03-14 16:38:21 +02:00
Konrad Lalik 384322dc14
Alerting: Access query details of provisioned alerts (#59626)
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
2022-12-15 13:33:41 +01:00
kay delaney a8c181bf6a
Chore: Migrate usage of v1 theme to v2 (#58154) 2022-11-03 18:15:55 +00:00
Gilles De Mey 7414ba7279
Expressions: make reduce inputs compacter (#56404) 2022-10-25 16:28:11 +02:00
Zoltán Bedi c0b778134e
Revert: Query editor components from grafana-ui (#57436)
* Revert: QueryEditor components from grafana-ui

* Use local version of experimental

* Use experimental for query editor components

* Fix type issues in MSSQL

* point to actual version of experimental package

* point to latest version of experimental

Co-authored-by: Erik Sundell <erik.sundell87@gmail.com>
2022-10-24 17:12:36 +02:00
Gilles De Mey 87cba8836f
Alerting: Expressions pipeline redesign (#54601) 2022-10-05 14:35:15 +02:00
Gilles De Mey 9aa61ddd0e
Alerting: Add threshold expression (#55102) 2022-09-26 16:05:44 +02:00
Scott Lepper de956fc3d8
Core code editor/builder components (#52421)
* migrate experimental to core grafana - update refs

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
2022-07-20 12:50:08 -04:00
Konrad Lalik e46ee78bed
Alerting: Add default input parameters for expressions (#51810) 2022-07-12 11:50:58 +02:00
Sriram a3071b7797
Expression: Filter query, mixed mode fixes and panel error message (#50218)
* implement filterQuery to support query.hide

* Fixed - expression ds name in mixed mode

* Execute expression query on blur

* show actual error message when ds return Query data error
2022-06-06 11:51:23 +01:00
Peter Holmberg 1402c85ce1
Alerting: change from cta to secondary (#49321) 2022-05-23 11:15:46 +02:00
Gilles De Mey 1a7ca3f0de
Expressions: adds inline documentation for the Math expression (#48784) 2022-05-16 11:30:27 +02:00
Ashley Harrison 06d3c27bc1
Select: Portal menu by default (#48176)
* Remove menuShouldPortal from all <Select /> components

* fix unit tests

* leave menuShouldPortal as an escape hatch

* Fix import order
2022-05-04 15:12:59 +01:00