39 Commits

Author SHA1 Message Date
8ef8471b23 Chore: Remove prometheusUsesCombobox feature toggle (#103940)
* remove prometheusUsesCombobox feature toggle

* betterer

* fix the unit test

* create MetricsLabelsSection unit tests

* fix unit tests

* fix unit tests in PromQueryBuilder.test.tsx

* prettier

* remove timeouts

* Revert "remove timeouts"

This reverts commit 84af1fd46bad807e9b42a8c1b1ce308700ab36c9.
2025-04-22 18:54:10 +02:00
10eb8aeeee Prometheus: Remove /series endpoint usage from Metrics Browser (#101705)
* convert it to functional component

* useReducer

* usePromQueryFieldEffects

* clean up the code

* remove localStorage provider

* introduce usePromQueryFieldEffects.test.ts

* simpler state management

* remove mocks

* linting + betterer

* Split PrometheusMetricsBrowser into small functional components

* remove /series endpoint usages for Metrics Browser

* add time ranges

* remove unused file

* fix unit test

* use limit

* re-fetch labels when a label value is selected

* reset the label keys when selector is empty

* select multiple labelValue

* fix unit tests

* add comments

* don't show unpresented labelKeys

* don't clear out selected label keys that are in local storage

* show values properly

* fix clearing

* don't discard already selected label values when a new label value selected

* remove unnecessary unit test

* clear all selections

* if metrics list is empty remove all label keys too

* re-populate values when all label selections are removed

* safety

* more comments

* updating the whole fetching mechanism

* buildSafeSelector

* loadSelectedLabelsFromStorage

* fetchMetrics

* fetchLabelKeys

* fetchLabelValues

* more unit test and comment

* timeRange changes will trigger re-fetch

* some more comments

* fix the unit test

* lint

* fix unit tests

* fix timerange causing problem

* remove fethcing message

* proper initialization

* fix value fetching during metric selection

* fix value fetching

* fix unit tests

* fix a bug

* comments

* some precaution

* fix the test

* fetch metrics when metric selection is changed

* trigger initialize when seriesLimit is change

* Revert "trigger initialize when seriesLimit is change"

This reverts commit c6cbbc138634c722ee1adbb9c8dabb3fa8819e52.

* remove redundant comments
2025-04-16 08:36:23 +02:00
8fadade4b8 Chore: Split PrometheusMetricsBrowser into small functional components (#101703)
* convert it to functional component

* useReducer

* usePromQueryFieldEffects

* clean up the code

* remove localStorage provider

* introduce usePromQueryFieldEffects.test.ts

* simpler state management

* remove mocks

* linting + betterer

* Split PrometheusMetricsBrowser into small functional components

* prettier
2025-04-04 18:58:46 +02:00
23e0f63790 Chore: Convert prometheus query field to a functional component (#101515)
* convert it to functional component

* useReducer

* usePromQueryFieldEffects

* clean up the code

* remove localStorage provider

* introduce usePromQueryFieldEffects.test.ts

* simpler state management

* remove mocks

* linting + betterer

* remove unnecessary check

* use range

* remove unused languageProvider

* prettier
2025-04-04 17:56:31 +02:00
1a988df143 Prometheus: Support new info function in code editor (#97850)
* first attempt to have info function

* unit test for query modeller

* enable info function in devenv

* fix unit test

* add unit test for info function

* throw error when trying to visualize the info function

* remove visual query support

* Update packages/grafana-prometheus/src/promql.ts

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* Update packages/grafana-prometheus/src/querybuilder/parsing.test.ts

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>

* update info function detail

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2025-04-04 13:50:54 +02:00
bf456179e7 Prometheus: Use timeRange parameter in each language provider method (#101889)
* remove range from class

* remove range from language provider

* use range parameters in MetricsLabelsSection

* use range parameters in metric_find_query

* pass range parameter in monaco-query-field

* typo

* use range in prometheus metrics browser languageProvider calls

* fix unit tests

* fix unit tests

* update unit tests

* lint
2025-03-21 10:08:23 +01:00
c15c9f8af6 Prometheus: Fix cursor jump in prometheus code editor (#100273)
* set save view state prop

* remove custom onChange function
2025-02-11 16:55:54 +01:00
0bd4e3bda2 Theme: properly clip corners in loki/prom query editor (#100253)
properly clip corners in loki/prom query editor
2025-02-07 17:17:46 +00:00
2dfb796f21 Prometheus package: Replace deprecated @grafana/experimental with @grafana/plugin-ui and @grafana/llm (#99385)
* Prometheus package: Replace deprecated @grafana/experimental with @grafana/plugin-ui and @grafana/llm

* Fix @grafana/llm mock in test

* Keep version exact

* Keep version exact

* Update lock
2025-01-24 12:46:31 +01:00
106af5d0ee Prometheus: UTF8 support in metrics browser (#98612)
* utf8 metrics for prometheus devenv

* introduce utf8 support

* completions and suggestions

* don't wrap the utf8 label in quotes

* linting

* support utf8 labels and metrics on visual query builder

* lint

* update raw view for utf8 metric syntax

* betterer

* support utf8 metric names in explore metrics

* utf8 support in grouop by

* utf8 support in label break down

* utf8 metric and label support in metric_find_query for label values

* use the same regex to check label values

* no need to escape

* support series endpoint

* support series endpoint

* support series endpoint

* support series endpoint

* fix tests

* fix extracting labels from labelValuesQuery

* show explanation with right syntax

* support utf8 metrics and labels
2025-01-16 17:50:35 +02:00
4c0fa629da Prometheus: Support utf8 metric/label/label value suggestions in code mode (#98253)
* utf8 metrics for prometheus devenv

* introduce utf8 support

* completions and suggestions

* don't wrap the utf8 label in quotes

* linting

* support series endpoint
2025-01-16 15:01:51 +01:00
a798bb74e5 Prometheus: Add double_exponential_smoothing function (#98312)
* add double_exponential_smoothing function

* add in operations
2025-01-02 22:19:49 +01:00
721c50a304 Prometheus: Improve handling of special chars in label values (#96067)
* fix: handling of special chars

* docs: add clarity

* fix: escaping

* refactor: put changes behind new feature toggle

* docs: use consistent comment style

* refactor: rename feature toggle for brevity

* use single quotes

* fix unit tests

* remove redundant json entry

* fix: keep all changes behind feature toggle

* fix: support builder mode

* fix: don't escape when using regex operators

* fix: code mode label values completions with special chars

* refactor: remove unneeded changes

* move feature toggle up so new changes from main won't conflict with ours

* fix: escape label values in metric select scene

* refactor: ensure changes are behind feature toggle

---------

Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
2024-12-18 16:31:08 -05:00
466688436e Prometheus: Performant Code Mode autocomplete with long metric names (#96580)
* fix: autocomplete performance

* refactor: simplify the complex search strategy

* chore: allow json imports to aid testing

* perf: prefer for loop for perf-critical path

* perf: use ufuzzy in intraMode: 0 (#96584)

* refactor: add clarity

* refactor: simplify

---------

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
2024-11-18 12:12:25 -05:00
b1c5aa0929 Update dependency @prometheus-io/lezer-promql to v0.55.1 (#95272)
* Update dependency @prometheus-io/lezer-promql to v0.55.1

* chore(grafana-prometheus): update type import

* fix duration resolver

* fix unit test

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
Co-authored-by: ismail simsek <ismailsimsek09@gmail.com>
2024-11-09 01:16:51 +02:00
4bf350cc62 Prometheus: Variable query editor, display selected label when using query type of label values (#92513)
display label, add test
2024-09-04 08:11:17 -05:00
68f545210d Prometheus: Fix label names select component when there are too many options (#92026)
* add more doc info for truncate function and how we use it

* truncate label names and allow users to search all labels on typing

* remove unused import

* handle labels select in variable query in addition with truncated list
2024-08-16 13:55:03 -05:00
f01263803a Prometheus: Add a limit for the series resource api in metrics browser (#91555)
* add a limit for the series resource api in metrics browser

* decouple serieslimit from options and only use in metrics browser

* add series limit input to metrics browser

* add warning

* add and fix tests

* add new param to jsdoc

* do not use the limit in other calls outside metrics browser

* update test

* trim limit

* fix tests, remove limit from non labels calls
2024-08-15 23:39:42 +03:00
b8ebc5d463 Chore: Update lezer package of prometheus frontend (#91252)
* update lezer package

* Use UnquotedLabelMatcher instead of LabelMatcher

* Use UnquotedLabelMatcher instead of LabelMatcher in parsing.ts
2024-08-11 23:48:04 +02:00
7f5dde6ed3 Chore: Cleanup duplicated code in grafana-prometheus package (#89542)
* remove redundant test matchers

* use amendTable, trimTable functions from @grafana/data package

* move getMockDataSource function into the mocks.ts

* use LocalStorageValueProvider from @grafana/o11y-ds-frontend

* move all mocks under __mocks__ directory

* use store from @grafana/o11y-ds-frontend

* move test related files under test directory

* use getNextRefId from @grafana/data instead of deprecated getNextRefIdChar
See: https://github.com/grafana/grafana/pull/87460

* betterer

* remove unnecessary mockings

* import from @grafana/data

* import from @grafana/data
2024-07-03 16:21:29 +02:00
8f2daacf78 Chore: Remove CancelablePromise (#89564)
* Remove CancelablePromise.ts as it wasn't used in anywhere

* Move cancelable-promise to the place where it is used
2024-06-27 13:33:35 +02:00
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
ca1afff886 Chore: Remove deprecated Layout components (#89376)
* Removed depricated HorizontalLayout from PrometheusMetricsBrowser

* Removed commented import

* typo fix

* Removed depricated HorizontalLayout from RawInfluxQLEditor

* Replaced InlineFormLabel to InlineField in RawInlfuxEditor.tsx

* Removed depricated HorizontalLayout from GraphiteFunctionEditor

* Changed div to instead use stack

* Changed htmlFor attribute from selectElementId to aliasElementId

* Updated the betterer results

* Updated prettier write to the updated files

* Changed htmlFor label to fix the text
2024-06-24 20:59:41 +02:00
ceaf510a7d Chore: SCSS cleanup (#89355)
* remove/migrate normalize.scss

* fix typo

* migrate _explore styles

* make json-formatter styles global
2024-06-19 13:28:00 +01:00
7334f71e09 CodeEditor: Improved styles when the code editor is loading (#88102)
* fix: monaco loading state

* chore: betterer

* test: leverage e2e selectors

* refactor: prefer HOC to wrap with testid

* refactor: add clarity

* docs: add clarity

* refactor: loading messaging

* test: rename vars to improve clarity

* test: rename vars to improve clarity
2024-05-29 15:55:18 -04:00
56fe0102a6 Prometheus Variable Editor: Fix typo - double "Enter" in help text (#88204)
Fix double "Enter" in help text
2024-05-23 14:46:32 +02:00
1654b719e9 Chore: Fix lint error in grafana-prometheus (#87421) 2024-05-07 12:40:55 +03:00
b68f40d5c5 Chore: Rewrite grafana-prometheus css using object styles (#86835) 2024-05-07 10:11:49 +01:00
57bea68453 Chore: Remove unused functions form prometheus data source (#86461)
* remove createQuery

* remove redundant unit test

* update unit tests

* remove redundant mock

* exclude mocks from build

* remove it

* prettier
2024-04-19 16:00:26 -04:00
f9a8e34b32 Prometheus: Update lezer-promql package (#85942)
* Update @lezer/lr to v1.4.0

* Update @prometheus-io/lezer-promql to v0.37.0

* Update @prometheus-io/lezer-promql to v0.38.0

* Update @prometheus-io/lezer-promql to v0.39.0

* Update @prometheus-io/lezer-promql to v0.40.0

* add jest config

* update code

* fix code to pass "handles things" test

* fix retrieving labels

* fix code to pass "handles label values" test

* fix code to pass "simple binary comparison" test

* use BoolModifier

* add changed lines as comments

* fix for ambiguous query parsing tests

* resolve rebase conflict

* fix retrieving labels, aggregation with/out labels

* add error

* fix comment

* fix "reports error on parenthesis" unit test

* fix for "handles binary operation with vector matchers" test

* fix for "handles multiple binary scalar operations" test

* fix for "parses query without metric" test

* fix indentation and import style

* remove commented lines

* add todo items and comments

* remove dependency update from tempo datasource

* apply same changes in core prometheus frontend

* prettier

* add new test case

* use old version of lezer in the root package.json

* Revert "apply same changes in core prometheus frontend"

This reverts commit 83fd6ac7

* fix indentation

* use latest version of lezer-promql v0.51.2

* Update packages/grafana-prometheus/src/querybuilder/parsing.ts

Co-authored-by: Nick Richmond <5732000+NWRichmond@users.noreply.github.com>

* enable native histogram test

---------

Co-authored-by: Nick Richmond <5732000+NWRichmond@users.noreply.github.com>
2024-04-19 11:54:56 +02:00
ec43edd8a1 Loki/Prometheus Query Editor: Disabled cmd/ctrl+f keybinding within the editor (#86418)
* Prom: disable cmd f within the editor

* Loki: disable cmd f within the editor

* Update public/app/plugins/datasource/loki/components/monaco-query-field/MonacoQueryField.tsx

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>

* Monaco: upgrade to 0.34.1

* Loki/Prometheus: allow native search to be displayed

* Formatting

* Monaco: upgrade to 0.34.1

https://github.com/microsoft/monaco-editor/issues/102#issuecomment-1282897640

---------

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
2024-04-17 16:38:43 +02:00
1ffe858e06 chore: remove repetitive words (#86412)
Signed-off-by: TechVest <techdashen@qq.com>
2024-04-17 13:08:00 +01:00
f85470d652 Prometheus: Use the frontend package in Prometheus and remove feature toggle (#86080)
* add history links for monaco completion provider folder

* add history links for monaco query field folder

* add history links for components folder

* add history links for configuration folder

* add history links for dashboard json folder

* add history links for gcopypaste folder

* add history link for variableMigration

* add history link for querybuilder/components/metrics-modal folder

* add history link for querybuilder/components/promqail folder

* add history links for querybuilder/components folder

* add history links for querybuilder/hooks folder

* add history links for querybuilder/shared folder

* add history links for querybuilder folder

* add history links for querycache folder

* add history links for src folder

* use frontend package and custom auth in module.ts

* remove files and fix import issues

* remove usePrometheusFrontendPackage

* remove extra files

* update betterer

* remove extra files after rebase

* fix betterer for rebase

* fix e2e flakiness
2024-04-15 16:45:23 -05:00
7c156274cd Prometheus: Add native histogram functions (#86002)
* add native histogram functions to code editor

* add native histogram function types for query builder

* add functions to query builder

* add test to show parsing breaks from code to builder

* add histogram_avg to code editor

* add histogram_avg to builder and make parity between package and core

* add functions to hard coded promql file for highlighting

* remove native histogram test so that it can be added in #85942

* remove functions from core prometheus js to prevent merge conflict in #86080

* use xit for test instead of removing it
2024-04-15 14:26:51 -05:00
559fab9dc6 Prometheus: Fuzzy search for metric names in Code Mode (#85396)
* perf: limit metric names in Code Mode suggestions

* feat: configurable metric names limit

* feat: code mode autocomplete info/disclaimer

* chore: put new functionality behind new feature toggle

* refactor: avoid type assertions

* refactor: avoid explicit `any`

refactor: type guards

* refactor: type guards

* chore: add testdata results

* fix: add missing feature toggle guard

* perf: prefer array access to `Array.prototype.at`

* test: add missing config override

* test: refactor for brevity & clarity

* perf: avoid unnecessary mapping

* chore: undo testdata changes

* fix: use correct limit; perf optimizations

* refactor: avoid unnecessary `async`s

* types: simplify

* test: add missing tests

* fix: avoid hardcoding

* test: update mock path

* docs: fix typo

style: remove formatting artifact

style: remove formatting artifact

style: remove formatting artifact

* fix: event scope regression

* style: refactor for clarity

* refactor: prefer `useCallback` to in-effect handler

* refactor: simplify & broaden `filter`

* refactor: rename file to keep with conventions

* chore: mirror Prometheus package changes in app

* refactor: prefer no `@ts-ignore`

* chore: update betterer results

* docs: use type in TSDoc `@link` without `@ts-ignore`

* test: add missing provider

* test: fix jest mock path

* fix: display disclaimer in empty input case
2024-04-04 23:38:23 +03:00
c6f8462a06 Prometheus: Library fixes for using in external vendor DS (#82115)
* fix stateSlice type errors for build, do not export stateSlice in the future

* fix exports for consistency

* fix package.json for rollup, update licence, keep private

* rollup as devdependencies

* try a different version of @testing-library/dom to try to fix the aria-query issue in drone

* remove testUtils export

* change @testing-library/dom version back

* remove icon bundling, grafana-ui handles this

* remove unused dependencies

* components folder: avoid nested barrel files and use named exports

* configuration folder: avoid nested barrel files and use named exports

* querybuilder folder: avoid nested barrel files and use named exports

* general files: use named exports

* fix loader issue with promql for external ds

* default to support labels match api

* export things necessary for custom config auth

* remove changes to core datasource.test.ts

* Update packages/grafana-prometheus/package.json

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>

* remove icons script, not needed

* update readme, remove references to grafana/ui

* remove private property

* check tests

* remove private property in package.json

* update changelog

* update npm drone script for file checks

* debug why updating test in script broke another library that had never been tested before

* fix npm test for checking licenses

* fix npm test for checking licenses

* fix npm test for checking licenses

* fix npm test for checking licenses

* update license file for npm drone test

* fix bash script

---------

Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com>
2024-02-16 12:55:39 -06:00
765a1f8533 Chore: fix some bad uses of userEvent (#82191)
* fix some bad uses of userEvent

* wrap advance call in act

* don't use act

* remove skip

* need act here (see https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning#1-when-using-jestusefaketimers)

* remove test that isn't correct anymore

* implement same change in grafana-prometheus
2024-02-09 10:04:35 +00:00
ec0eb8fd79 Prometheus: Frontend library exports (#81909)
* fix components folders for exports

* export files in the components folder

* export metrics modal and fix exports

* export promquail and fix exports

* export querybuilder/components and fix exports

* export querybuilder

* main index file exports

* run prettier
2024-02-06 08:27:09 -06:00
75c2d39f79 Prometheus: Create Prometheus library (#81641)
* Move to the library

* copy from library

* move them in src

* have additional files

* add unmigrated/dulicated code and files

* migrate from brendan's pr
module.ts, query_hints.ts, tracking.ts, and remove plugin.json

* migrate from brendan's pr
metric_find_query.test.ts

* migrate from brendan's pr
language_utils.test.ts

* migrate from brendan's pr
index.ts in root and in configuration

* migrate from brendan's pr
datasource.test.ts

* migrate from brendan's pr
typings folder

* migrate from brendan's pr
querycache folder

* migrate from brendan's pr
monaco-query-field folder

* migrate from brendan's pr
components folder without monaco-query-field folder

* migrate from brendan's pr
configuration/overhaul folder

* migrate from brendan's pr
AlertingSettingsOverhaul.tsx

* Remove azure related code

* migrate from brendan's pr
ConfigEditor.tsx, DataSourceHttpSettingsOverhaul.tsx, ExemplarSetting.tsx, configuration/mocks.ts, PromSettings.test.tsx, PromSettings.tsx

* migrate from brendan's pr
useFlag.ts

* migrate from brendan's pr
metrics-modal folder

* migrate from brendan's pr
files inside components folder

* migrate from brendan's pr
LabelFilters* files because they are now under components folder

* migrate from brendan's pr
files under querybuilder/shared folder

* migrate from brendan's pr
aggregations.ts, QueryPattern.tsx, QueryPatternsModal.tsx, state.ts, testUtils.ts under querybuilder folder

* Apply Ivana's PR https://github.com/grafana/grafana/pull/81656

* Apply jack's suggestions in this PR https://github.com/grafana/grafana/pull/77762

* Apply Ivana's PR https://github.com/grafana/grafana/pull/81656

* Fix type import

* add monaco-promql to transformIgnorePatterns to run prometheus frontend library tests

* remove Loki specific tests because we removed Loki code to decouple Loki

* add prometheus specific references

* We are moving these betterer issues from core Prometheus to the Library and we promise to remove all issues in the future, thank you

* include prometheus library in package.json

* add yarn lock with prometheus frontend library

* decouple final core import from metric_find_query.test.ts

* run prettier

* fix core imports in promqail

* fix lint errors

* run prettier

* add grafana-ui to devdeps to fix lint errors

* update yarn.lock

* grafana-ui fix

* trying to fix grafana-ui type errors with lerna drone check

* trying to fix grafana-ui type errors with lerna drone check

* trying to fix grafana-ui type errors with lerna drone check

* trying to fix grafana-ui type errors with lerna drone check

* try to pass typecheck

---------

Co-authored-by: Brendan O'Handley <brendan.ohandley@grafana.com>
2024-02-02 15:30:14 +01:00