67 Commits

Author SHA1 Message Date
8fd5739576 [unified-storage/search] Don't expire file-based indexes, check for resource stats when building index on-demand (#107886)
* Get ResourceStats before indexing
* Replaced localcache.CacheService to handle expiration faster (localcache.CacheService / gocache.Cache only expires values at specific interval, but we need to close index faster)
* singleflight getOrBuildIndex for the same key
* expire only in-memory indexes
* file-based indexes have new name on each rebuild
* Sanitize file path segments, verify that generated path is within the root dir.
* Add comment and test for cleanOldIndexes.
2025-07-10 11:54:10 +00:00
9d2eadcfd2 PoC: replace using testing.Short in storage/unified package with integration test skip method (#107887)
* PoC: check if testing.Short is called from integration tests only.

* Rename helper function.

* Fix logic.

* Remove skipping of integration tests from non-integration tests.

* Remove skipping of integration tests from non-integration tests.

* Fix import.
2025-07-09 15:32:10 +00:00
0982cfd9a0 Unified Storage/Search: Add max count config for indexing (#107255)
* Add max count config for indexing
* Build empty index when max count is exceeded
* Address linting
* Refactor buildIndexes
* Add test for max count threshold
* Update test doc comments
* Refactor TestBuildIndexes_MaxCountThreshold to not use mock framework
* Rename mocks used in TestBuildIndexes_MaxCountThreshold

* Refactor mockResourceIndex

* Test setting of indexing threshold configs

* Tweak comments, log

* Fix logging in buildEmptyIndex

* Export and reuse TestDocumentBuilderSupplier

* Reuse MockResourceIndex
2025-06-27 14:00:39 +02:00
79fe8a9902 Library Panels: Modify connection api endpoint to be compatible with unified storage (#107088) 2025-06-25 22:21:56 +00:00
5150ebfba8 unistore: index search references (#106954) 2025-06-24 14:54:07 -05:00
b48337a7c8 feat: introduce ttl cache for bleve indices (#106842) 2025-06-17 16:28:51 +02:00
5135d5c87d Unified storage: Reconstruct index in the background every 24h (#106422) 2025-06-12 14:34:48 -05:00
002f46736a refactor(unified-storage): move generated protos to own pkg (#105356) 2025-05-15 21:36:52 +02:00
e162c69c34 search: fix document missing at startup (#105198)
* fix document missing at startup

* go-lint

* fix tests

* fix tests

* fix integration tests now that we are storing real values
2025-05-12 07:56:25 +02:00
15b3de5893 search: add index batching (#104163)
* add basic search backend integration tests

* add search backend benchmark

* add benchmark indexServer

* fix

* lint

* add more tests

* lint

* do not use the poller

* batch write

* refactor and add tests

* improvements

* improvements

* cleanup

* only observe index success

* add monitorIndexEvents method

* nit use switch instead of if

* make newIndexQueueProcessor private

* simplify runProcessor

* go lint
2025-05-09 15:36:21 +02:00
b09d79b21c K8s/Dashboard: Promote from alpha1 to beta1 (#104009) 2025-04-23 20:54:35 +03:00
0283c98e30 K8s/Folders: Use v1beta1 and app-sdk based spec (#103975) 2025-04-14 23:20:10 +03:00
f5ad1ef69b K8s: Folders: Add v1 api (#103842) 2025-04-11 13:09:52 +01:00
e9ed7223a6 Use authlib repo. Use otel (#103178)
* Use authlib repo. Use otel

* Use interceptors on the provider level

* Create a new wire set with otel

* Lint

* Fix test

* make update-workflow

* make update-workspace

* make update-workspace. Try to add authlib as enterprise imports

* make update-workspace
2025-04-07 15:47:40 +02:00
db1f1c5df9 search: add manager kind to bleve (#103305) 2025-04-03 10:02:02 +03:00
c54496a3f9 Search: Avoid panic with missing title (#103257) 2025-04-02 15:43:08 +03:00
08042ae827 search: add legacy id for all resources in bleve (#103206)
* add legacy id for all resources in bleve
2025-04-02 08:20:23 -04:00
6781612335 Provisioning: Enable search when provisioning is enabled (#103208) 2025-04-02 11:20:28 +03:00
e1e1d3fd9f Fix: Prints should always include new lines (#102795)
* CI: Allow Bench conversion to fail

We shouldn't mark PRs and commits as X if they fail to convert logs with Bench.

* Fix: Prints should always include new lines

* fix: remove unused import
2025-03-27 12:27:53 +01:00
51bbfa2d08 [Search] Fix CodeQL warnings (#101364)
* Fix CodeQL warnings

* Also validate if path is a file above the safe dir

* Lint

* [REVIEW] reduce possibility of exploits

* Comment

* Remove test scenario
2025-03-26 15:38:58 +01:00
7c2890384a K8s: Dashboards: Set v1alpha1 as priority (#102729) 2025-03-25 10:32:49 -06:00
2aae523c3f Search: Fix title filter overmatching (#102547)
* fix issues with over matching
* search wildcard for backward compatibility
2025-03-21 09:57:20 -04:00
31a371e385 fix(unified-storage): remove bleve index metric from global scope (#101825)
* refactor grafana_index_server_index_size to calculate in a goroutine instead of at scrape time and remove grafana_index_server_indexed_docs metric

* use wire to inject bleve index metrics

* remove sprinkles metrics from bleve index metrics

* log error when trying to calculate file index size and bump interval to 1m instead of 5s
2025-03-13 10:09:38 -04:00
5d2ba10113 K8s/Dashboards: Extract Dashboard APIs to an app submodule (#102029)
* Move dashboard k8s APIs to a separate app

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* Copy dashboard code in Dockerfile

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* Fix conversion generation

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

* Update OpenAPI snapshot for dashboard/v0alpha1

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>

---------

Signed-off-by: Igor Suleymanov <igor.suleymanov@grafana.com>
2025-03-13 11:05:01 +02:00
56293d8019 Revert "Revert "Unified Storage: Use match all query instead of wildcard for not-in requirement query"" (#102074)
Revert "Revert "Unified Storage: Use match all query instead of wildcard for …"

This reverts commit 4d9bcc6c440acf82dfdd95ea27948f3c8180a700.
2025-03-13 02:08:56 +02:00
4d9bcc6c44 Revert "Unified Storage: Use match all query instead of wildcard for not-in requirement query" (#102058)
Revert "Unified Storage: Use match all query instead of wildcard for not-in r…"

This reverts commit 59d87fe3f1c0dd59353e6176bf55bd4a3c37c0bf.
2025-03-12 12:28:49 -06:00
59d87fe3f1 Unified Storage: Use match all query instead of wildcard for not-in requirement query (#101953)
use match all query insteaed of wildcard
2025-03-11 10:15:58 -06:00
64f1df69d5 Search: Rename managed object index (#101856) 2025-03-10 19:48:53 +03:00
827da46c51 Unified Storage: Remove wildcard queries (#101441)
* WIP adding custom analyzer so we can do substring search efficiently

* Adding unit tests for title search

* formatting

* adds more title search unit tests

* organize helpers

* fixes issue caused by having two title mappings

* Removes camelcase token filter since it prevents you from searching for a substring of chars and numbers. Adds regression test.

* adds back mapping for title_phrase

* use simple analyzer for input query string so it doesn't filter out english stop words

* ran bleve tests, table snapshots updated

* ignore linter for "unused" test functions. They are very helpful for troubleshooting search. Keeping them.

* only log total hits and query cost if result not nil

* fixes failing test - one more field because there are two title mappings now

* fix test

* fixes test - only take first item when its the title

* Adds separate internal field for title ngram mapping.

When searching with a query, results are sorted by score desc.

When searching without a query, results are sorted by title desc.

Adjusts ngram max to be 10.

Text queries are a disjunction of an exact match, phrase match, and a match. Boosted to have priority in that order.

Adds more unit tests for searching.

* linter

* fix test

* ran tests - generated new test dash json

* sort by title phrase instead of title

* fix test - not relying on /apis/dashboard/search to apply title sorting anymore
2025-03-07 09:51:15 -06:00
dc2defd84f K8s/Annotations: Use manager/source annotations rather than repo (#101313)
Co-authored-by: Stephanie Hingtgen <stephanie.hingtgen@grafana.com>
2025-03-05 08:54:20 +02:00
fa74d1c36d Authn: Sync authlib and update how we construct authn client interceptor (#101124)
* Sync authlib and update how we construct authn client interceptor

* Remove namespace from checker
2025-02-26 09:22:09 +01:00
67be9aeed6 K8s: Search fallback: Support all sort by methods (#100776) 2025-02-18 12:30:11 -06:00
d0394bfa7e Extract NewSearchOptions from unified sql client setup. (#100719)
* Extract NewSearchOptions from unified sql client setup.

Co-authored-by: Georges Chaudy <chaudyg@gmail.com>
2025-02-14 16:39:48 +01:00
b1222be02e unistore: add small buffer of watched events (#100431)
* change log level

* Add a small buffer when watching events
2025-02-14 12:18:59 +02:00
155492c8a5 search: handle "permission" query param in search (#100607)
handle "permission" query param in search
2025-02-13 11:35:53 -05:00
8e9e3b8362 [search] title phrase (#99753)
[search] rename title_sort to title_phrase
2025-01-29 17:31:59 -05:00
f55686a0b4 Unified Storage: Adds some more traces to search and the bleve search impl (#99704)
adds some more traces to search and the bleve search impl
2025-01-28 21:27:01 +02:00
3228ae727e wires up dashboards page to be able to sort by usage stats (sprinkles) (#99479)
* wires up dashboards page to be able to sort by usage stats (sprinkles)

* dont mutate field

* use better type for field

* adds tests. Had to export some types and put the field type back to object.

* frontend asks for sort field in response if needed

* adds some unit tests for getSortOptions

* use Record instead of object

* prettier

* adds ternaries, another unit test
2025-01-28 19:36:26 +02:00
fd85ddf647 Unified Storage: Fix search case sensitivity (#99603)
lowercase search query when doing a text query. Doing this makes the NewWildcardQuery be case-insensitive
2025-01-27 20:39:36 +00:00
629b20700c [search] mimic sql search (#99526) 2025-01-27 08:03:39 -05:00
dd483fc17f Unified Storage: Search permissions put behind feature flag (#99340)
* add feature flag

* puts search permission filtering behind a feature flag

* fixes issue with doc match id. When the match is for an in-memory index, the internal id is a string (this is what we expected). However, when its a file-based index, the internal id is a binary encoded int64 that point to something internally. So to get the id, we need to use ExternalID() instead of relying on the indexInternalID to be the correct format.

* adds debug log

* update comment

* formatting
2025-01-22 05:38:37 -06:00
6f12b8e3a4 Unified Storage: Add more debug logs to permission filtering (#99325)
add more debug logs
2025-01-21 17:34:58 +02:00
d8b6ded101 K8s: use deprecatedInternalID label rather than SQL annotation (#99263) 2025-01-21 12:38:14 +03:00
680e6bc1f8 Authlib: Use types package rather than claims (#99243) 2025-01-21 12:06:55 +03:00
c45aff1251 Unified Storage: Permissions can filter search results (#99042)
* fix bug when parsing results in search handler

* applies permissions filtering to bleve query

* formatting

* wraps in check for access being present, adds some comments

* update go mod

* fix tests

* add dep owner

* fix go mod

* add space after //

* clean up returns

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>

* fixed formatting

* Uses single checker since index is for single resource. Passes folderId using dvReader to checker func. Adds debug logging.

* handles federation with index permission checkers

* formatting

* move import

---------

Co-authored-by: Bruno Abrantes <bruno.abrantes@grafana.com>
2025-01-20 14:30:09 -06:00
52c1a3dccd Search: Delete old indexes once not in use (#99251) 2025-01-20 20:25:26 +03:00
5a930e0ec6 K8s search: add legacy id to dashboard response (#99132) 2025-01-17 08:16:48 +03:00
d00592ffa0 Unified Storage: Make all dashboard fields searchable (#98899)
* wip. adding sprinkles fields.

* some refactoring. Works with sprinkles now.

* exclude top level dashboard hit fields from hit "fields"

* adds unit test for DecodeCell helper

* test can search for specific dashboard fields on bleve index

* adds search handler tests for the fields and tests for fields when transforming the search req to a bleve search req

* fix panic when calling fields.Set() with int32

* adds regression test

* remove unneeded method on test mock client

* fix linter issues

* updates dashboard test data for bleve tests

* remove DASHBOARD_LEGACY_ID from bleve_tests

* dont cast twice

* updates test to sort by dashboard_views_last_1_days

* declare excludedFields outside of function

* fixes sorting by dashboard fields - prepends "fields." to any dashboard fields we try to sort by

* uses map for excludedFields

* expects fields to be array-style url param

* change method name

* fixes failing tests - needed to add column type to mocks
2025-01-15 10:23:05 -06:00
38927f0719 fix(indexer): reduce cardinality of indexer metric (#99018) 2025-01-15 16:01:31 +01:00
98c7861936 Search: Update repository query apis (#98886) 2025-01-13 17:05:04 +02:00