Commit Graph

16 Commits

Author SHA1 Message Date
Sven Grossmann
423a451858
Loki: Fix filtering with structured metadata (#73955)
* check languageProvider to work with non-indexed metadata

* change loki devenv to work with non-indexed metadata

* trigger ci

* add forced labels after parsers

* add comment

* Update public/app/plugins/datasource/loki/modifyQuery.ts

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

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2023-08-31 15:24:03 +02:00
Matias Chomicki
84f94cdc24
Logs: Show active state of "filter for value" buttons in Logs Details (#70328)
* Datasource test: fix describe nesting

* Parsing: export handleQuotes function

* Modify query: add functions to detect the presence of a label and remove it

* Loki: add support to toggle filters if already present

* Datasource test: fix describe nesting

* Loki: add support to toggle filter out if present

* Remove label: handle escaped values

* Datasource: add test case for escaped label values

* Loki: remove = filter when applying !=

* Remove selector: add support for Selector node being far from Matcher

* Modify query: add unit tests

* Elasticsearch: create modifyQuery for elastic

* Elastic modify query: implement functions

* Elasticsearch: implement modifyQuery functions in datasource

* Elasticsearch: update datasource test

* Loki modify query: check for streamSelectorPositions length

* Elasticsearch query has filter: escape filter value in regex

* Remove unused type

* Modify query: add functions to detect the presence of a label and remove it

* Remove label: handle escaped values

* Logs: create props to check for label filters in the query

* Log Details Row: use label state props to show visual feedback

* Make isCallbacks async

* Explore: add placeholder for checking for filter in query

* Datasource: define new API method

* Inspect query: add base implementation

* Remove isFilterOutLabelActive as it will not be needed

* Check for "isActive" on every render

Otherwise the active state will be out of sync

* Elasticsearch: implement inspectQuery in the datasource

* Logs: update test

* Log details: update test

* Datasources: update tests

* Inspect query: rename to analize query to prevent confusion

* Datasource types: mark method as alpha

* Explore: add comment to log-specific functions

* Remove duplicated code from bad rebase

* Remove label filter: check node type

* getMatchersWithFilter: rename argument

* Fix bad rebase

* Create DataSourceWithQueryManipulationSupport interface

* Implement type guard for DataSourceWithQueryManipulationSupport

* DataSourceWithQueryManipulationSupport: move to logs module

* hasQueryManipulationSupport: change implementation

`modifyQuery` comes from the prototype.

* DataSourceWithQueryManipulationSupport: expand code comments

* AnalyzeQueryOptions: move to logs module

* DataSourceWithQueryManipulationSupport: add support for more return types

* Fix merge error

* Update packages/grafana-data/src/types/logs.ts

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

* DatasourceAPI: deprecate modifyQuery

* Explore: refactor isFilterLabelActive

* DataSourceWithQueryModificationSupport: rename interface

* Split interfaces into Analyze and Modify

* Query analysis: better name for interface

* Fix guard

* Create feature flag for active state

* Use new feature flag in Explore

* DataSourceToggleableQueryFiltersSupport: create a specific interface for this feature

* Rename feature flag

* De-deprecate modifyQuery

* DataSourceToggleableQueryFiltersSupport: Rethink types and methods

* Explore: adjust modifyQuery and isFilterLabelActive to new methods

* Loki: implement new interface and revert modifyQuery

* DataSourceToggleableQueryFiltersSupport: better name for arguments

* Elasticsearch: implement new interface and revert modifyQuery

* Loki: better name for arguments

* Explore: document current limitation on isFilterLabelActive

* Explore: place toggleable filters under feature flag

* Loki: add tests for the new methods

* Loki: add legacy modifyQuery tests

* Elasticsearch: add tests for the new methods

* Elasticsearch: add legacy modifyQuery tests

* Toggle filter action: improve type values

* Logs types: update interface description

* DataSourceWithToggleableQueryFiltersSupport: update interface name

* Update feature flag description

* Explore: add todo comment for isFilterLabelActive

---------

Co-authored-by: Sven Grossmann <sven.grossmann@grafana.com>
2023-07-24 11:22:47 +03:00
Sven Grossmann
13dd821961
Loki: Fix wrong query expression with inline comments (#70947)
fix remove comments from query
2023-06-30 11:35:43 +02:00
Matias Chomicki
4c4bd69eb6
Logs: Add toggle behavior support for "filter for" and "filter out" label within Logs Details (#70091)
* Datasource test: fix describe nesting

* Parsing: export handleQuotes function

* Modify query: add functions to detect the presence of a label and remove it

* Loki: add support to toggle filters if already present

* Datasource test: fix describe nesting

* Loki: add support to toggle filter out if present

* Remove label: handle escaped values

* Datasource: add test case for escaped label values

* Loki: remove = filter when applying !=

* Remove selector: add support for Selector node being far from Matcher

* Modify query: add unit tests

* Elasticsearch: create modifyQuery for elastic

* Elastic modify query: implement functions

* Elasticsearch: implement modifyQuery functions in datasource

* Elasticsearch: update datasource test

* Loki modify query: check for streamSelectorPositions length

* Elasticsearch query has filter: escape filter value in regex

* Remove unused type

* Modify query: use query modeller instance from module
2023-06-26 16:45:33 +02:00
Sven Grossmann
d7337e4f9c
Loki: Preserve pipeline stages in context query (#70472)
* add pipeline stages to context query

* add ui

* improve `Postion`

* add `processPipelineStagesToExpr` to logcontextprovider

* add ui toggle

* fix lokicontextui tests

* remove import

* contextually hide the toggle

* Update `SHOULD_INCLUDE_PIPELINE_OPERATIONS` name

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

* add setIncludePipelineOperations to false in revert

* add prepareExpression method

* remove unused method

* fix test and add `runContextQuery`

* set correct revert state

* let let be const

* remove argument

---------

Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
2023-06-22 17:34:43 +02:00
Ivana Huckova
2509dec0cb
Loki: Fix ad hoc filters when used with number and > and < operators (#66579)
Loki: Fix ad hoc filters when used with number and >< operators
2023-04-17 10:27:38 +02:00
Ivana Huckova
a996344e14
Loki: Add autocomplete updates for improved suggestions (#64744)
* Loki: Add autocomplete updates for improved suggestions

* Use trimEnd for trailing pipeline

* Update public/app/plugins/datasource/loki/components/monaco-query-field/monaco-completion-provider/completions.ts

Co-authored-by: Matias Chomicki <matyax@gmail.com>

* Fix unused imports

---------

Co-authored-by: Matias Chomicki <matyax@gmail.com>
2023-03-15 14:26:46 +01:00
Gareth Dawson
b2c8126e6e
Loki: Show query size approximation (#62109)
* feat: make api request to /loki/api/v1/index/stats

* fix: add /index/stats to callResource valid urls

* feat: make call to getQueryStats when the query changes

* feat: render user tooltip displaying the estimated value for processed data

* fix: add new props to component tests

* test: add tests for query size estimation

* fix: disable error message on request failure

* refactor: add suggestions from code review

* refactor: only pass required query string
2023-01-27 17:32:53 +00:00
Ivana Huckova
8bda8b8272
Log volume: Fix functionality if query has multiple comments (#61306)
* Log volume: Fix functionality if query has comments

* Add additional test
2023-01-11 16:21:02 +00:00
Gareth Dawson
bd9cce2866
Loki: Add hints for query filters (#60293)
* add hint for label filter

* add hint for line filter

* add feature tracking for hints click

* fix failing tests

* add tests for new query builder hints

* update hint labels

* fix: hint continues to render after adding operation

* add missing title property to hints

* make use of isQueryWithParser and remove isQueryWithLogFmt

* refactor isQueryWithLabelFilter

* always render label operation, even if incomplete

* suggestion

* fix oversight in feature tracking name on hint click

* update query hint label

* improvements

* add missing test for ADD_NO_PIPELINE_ERROR
2023-01-05 13:56:31 +00:00
Sven Grossmann
932349b5ab
Loki: Fix wrongly escaped label values when using LabelFilter (#59812)
* change backticks to quotes

* add unescaping to `addFilterAsLabelFilter`

* fix removal of wrong quotes

* change unescape order
2022-12-06 12:30:03 +01:00
Ivana Huckova
28c390bc90
Loki: Fix adhoc parsing if multiple stream selectors and some empty (#58658) 2022-11-25 14:00:48 +01:00
Ivana Huckova
7928f170ce
Loki: Fix adding of adhoc filters to stream selector when query with empty stream selector (#57280)
* disable double stringify

* Refactor test for addLabelToQuery

* Add tests (TDD for expected behaviour)

* Fix adding ad hoc filters to correct place when no stream selector

* Update

* Update comment

* Fix getAllPositionsInNodeByType

Co-authored-by: Sven Grossmann <svennergr@gmail.com>
2022-10-19 17:24:00 +02:00
GitStart
46f0672215
Loki: Remove hardcoded values for parsed query parts (#54755)
Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev>
Co-authored-by: gitstart <gitstart@users.noreply.github.com>
Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com>
Co-authored-by: Murilo Amaral <87545137+MuriloAmarals@users.noreply.github.com>
Co-authored-by: gitstart <gitstart@gitstart.com>
Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com>
Co-authored-by: Matheus Benini <matheus_benini@hotmail.com>
Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com>
Co-authored-by: Júlio Piubello da Silva Cabral <julio.piubello@gitstart.dev>

Co-authored-by: gitstart <gitstart@users.noreply.github.com>
Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev>
Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com>
Co-authored-by: Murilo Amaral <87545137+MuriloAmarals@users.noreply.github.com>
Co-authored-by: gitstart <gitstart@gitstart.com>
Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com>
Co-authored-by: Matheus Benini <matheus_benini@hotmail.com>
Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com>
Co-authored-by: Júlio Piubello da Silva Cabral <julio.piubello@gitstart.dev>
2022-09-16 15:35:20 +02:00
renovate[bot]
4c8ea0bb89
Update dependency @lezer/common to v1 (#50866)
* Update dependency @lezer/common to v1

* Bump lezer/lr as well

* Fix broken code

* Add new lezer-promql and update lezer-logql

* Change to prometheus lezer-promql, fix lezer-logql code

* Update tests for Loki

* fix typeErrors

* fix tests by adding new error node to expected objects

* refactor usages of node references to differentiate usage from node object

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Zoltán Bedi <zoltan.bedi@gmail.com>
Co-authored-by: Ivana Huckova <ivana.huckova@gmail.com>
Co-authored-by: gtk-grafana <galen.kistler@grafana.com>
2022-08-22 08:45:29 -05:00
Ivana Huckova
bf3fa4a445
Loki: Fix producing correct log volume query for query with comments (#53254)
* Loki: Remove comments from log volume query

* Update, add more tests

* Update based on suggestions

* Update

* Update tests to use it.each
2022-08-04 17:58:39 +02:00