Commit Graph

496 Commits

Author SHA1 Message Date
Todd Treece
85759da360
Tracing: Add Start helper (#93052) 2024-09-06 13:02:17 -04:00
Gábor Farkas
abca0380a8
use count_bytes_reader from plugin-sdk-go (#92553)
* use count_bytes_reader from plugin-sdk-go

* run `make update-workspace`

* update postgres tests

* update mysql tests

* time back to utc

* make update-workspace done

---------

Co-authored-by: Kyle Brandt <kyle@grafana.com>
2024-08-28 16:44:13 +02:00
Dave Henderson
df3d8915ba
Chore: Bump Go to 1.23.0 (#92105)
* chore: Bump Go to 1.23.0

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* update swagger files

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* chore: update .bingo/README.md formatting to satisfy prettier

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* chore(lint): Fix new lint errors found by golangci-lint 1.60.1 and Go 1.23

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* keep golden file

* update openapi

* add name to expected output

* chore(lint): rearrange imports to a sensible order

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
Co-authored-by: Ryan McKinley <ryantxu@gmail.com>
2024-08-21 11:40:42 -04:00
Dan Cech
9020eb4b17
Auth: Update oauthtoken service to use remote cache and server lock (#90572)
* update oauthtoken service to use remote cache and server lock

* remove token cache

* retry is lock is held by an in-flight refresh

* refactor token renewal to avoid race condition

* re-add refresh token expiry cache, but in SyncOauthTokenHook

* Add delta to the cache ttl

* Fix merge

* Change lockTimeConfig

* Always set the token from within the server lock

* Improvements

* early return when user is not authed by OAuth or refresh is disabled

* Allow more time for token refresh, tracing

* Retry on Mysql Deadlock error 1213

* Update pkg/services/authn/authnimpl/sync/oauth_token_sync.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* Update pkg/services/authn/authnimpl/sync/oauth_token_sync.go

Co-authored-by: Dan Cech <dcech@grafana.com>

* Add settings for configuring min wait time between retries

* Add docs for the new setting

* Clean up

* Update docs/sources/setup-grafana/configure-grafana/_index.md

Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>

---------

Co-authored-by: Mihaly Gyongyosi <mgyongyosi@users.noreply.github.com>
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2024-08-19 18:57:37 +02:00
Kristin Laemmert
299c142f6a
QuotaService: refactor to use ReplDB for Get queries (#91333)
* Feature (quota service): Use ReplDB for quota service Gets

This adds the replDB to the quota service, as well as some more test helper functions to simplify updating tests. My intent is that the helper functions can be removed when this is fully rolled out (or not) and we're consistently using the ReplDB interface (or not!)

* test updates
2024-08-08 13:41:33 -04:00
Karl Persson
d93f5bab83
RemoteCache: remove count method (#91581)
* remove count method

* remove count from remote cache

---------

Co-authored-by: jguer <me@jguer.space>
2024-08-06 19:21:00 +02:00
Ryan McKinley
be7b1ce2df
Chore: Replace appcontext.User(ctx) with identity.GetRequester(ctx) (#91030) 2024-07-26 16:39:23 +03:00
Kristin Laemmert
27b52b1507
ReplStore: Add support for round robin load balancing between multiple read replicas (#90530)
* ReplStore: Add support for multiple replicas and round-robin load balancing

* add check for zero-length repls list
2024-07-18 08:20:28 -04:00
Serge Zaitsev
f5da9edbba
Chore: Remove unused method in db.DB (#90433)
* remove unused method

* clean up tests
2024-07-17 08:17:23 +02:00
Kristin Laemmert
8a6107cd35
DashboardStore: Use ReplDB and get dashboard quotas from the ReadReplica (#90235)
* Use ReplDB in dashboard store and update all fixtures - no other changes

* just moving dashboard counts for now

* find the missing test fixture
2024-07-12 10:47:49 -04:00
Alexander Zobnin
87d86e81ce
Zanzana: Evaluate permissions alongside with RBAC engine (#90064)
* Zanzana: Evaluate permissions if feature flag enabled

* Fix tests

* adjust logs

* fix spelling

* remove unused

* only evaluate implemented resources

* refactor
2024-07-05 11:31:23 +02:00
Marcus Efraimsson
06e67bc573
API Server: Fix stack overflow panic when tracing is disabled (#90075) 2024-07-04 19:11:59 +03:00
Isabella Siu
3ac109e759
AWS: Update deprecated aws-sdk functions from env variable versions (#89643) 2024-06-26 11:56:39 -04:00
Ryan McKinley
27e800768e
K8s: Improve identity mapping setup (#89450) 2024-06-20 17:53:07 +03:00
Kristin Laemmert
50244ed4a1
Experimental Feature Toggle: databaseReadReplica (#89232)
This adds a version of the SQLStore that includes a ReadReplica. The primary DB can be accessed directly - from the caller's standpoint, there is no difference between the SQLStore and ReplStore unless they wish to explicitly call the ReadReplica() and use that for the DB sessions.

Currently only the stats service GetSystemStats and GetAdminStats are using the ReadReplica(); if it's misconfigured or if the databaseReadReplica feature flag is not turned on, it will fall back to the usual (SQLStore) behavior.

Testing requires a database and read replica - the replication should already be configured. I have been testing this locally with a docker mysql setup (https://medium.com/@vbabak/docker-mysql-master-slave-replication-setup-2ff553fceef2) and the following config:

[feature_toggles]
databaseReadReplica = true

[database]
type = mysql
name = grafana
user = grafana
password = password
host = 127.0.0.1:3306

[database_replica]
type = mysql
name = grafana
user = grafana
password = password
host = 127.0.0.1:3307
2024-06-18 11:07:15 -04:00
Dave Henderson
6262c56132
chore(perf): Pre-allocate where possible (enable prealloc linter) (#88952)
* chore(perf): Pre-allocate where possible (enable prealloc linter)

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* fix TestAlertManagers_buildRedactedAMs

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

* prealloc a slice that appeared after rebase

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>

---------

Signed-off-by: Dave Henderson <dave.henderson@grafana.com>
2024-06-14 14:16:36 -04:00
Ryan McKinley
57b760824f
Chore: Remove pkg/infra/x/persistentcollection (#89139) 2024-06-13 21:46:52 +03:00
Ryan McKinley
99d8025829
Chore: Move identity and errutil to apimachinery module (#89116) 2024-06-13 07:11:35 +03:00
Marcus Efraimsson
1abaa825c6
Tracing: Only enable traces to profiles for api servers for now (#89126) 2024-06-12 19:36:31 +03:00
Diego Augusto Molina
7ca3ec7518
Infra: fix data race in usagestats service (#88881)
fix data race
2024-06-07 17:52:21 -03:00
Marcus Efraimsson
40931b6da6
Tracing: Enable traces to profiles (#88896) 2024-06-07 16:58:24 +02:00
Dave Henderson
e21d357d67
chore: Updating linter, fixing some new warnings (#88863) 2024-06-06 13:01:27 -04:00
Marcus Efraimsson
0b1aec6767
Tracing: Various improvements (#88308) 2024-05-27 14:21:40 +02:00
Marcus Efraimsson
961272a76d
Datasources: Enable native histograms for datasource response size metric (#87962) 2024-05-16 13:48:51 +02:00
Ieva
167151b211
Chore: Remove use of deprecated method in AC code (#87541)
* switch from using cfg to using featuremgmt for checking a feature toggle in AC code

* merge test fixes
2024-05-10 11:56:52 +01:00
Serge Zaitsev
6ddb8aeae3
Chore: Moving to slog (folders) (#87000)
* moving folders to slog

* trying to fix the tests

* fix per-logger filters in slog

* allow using slog.Default()

* bring cfg back to keep the pr small

* fix tests

* back to the roots
2024-05-02 09:14:12 +02:00
Isabella Siu
7b392d40a0
Auth: Sign sigV4 request after adding headers (#87063) 2024-04-29 13:07:45 -04:00
Serge Zaitsev
522a98c126
Chore: Make Cfg field private in SQLStore (#85593)
* make cfg private in sqlstore

* fix db init in tests

* fix case

* fix folder test init

* fix imports

* make another Cfg private

* remove another Cfg

* remove unused variable

* use store cfg, it has side-effects

* fix mutated cfg in tests
2024-04-24 10:38:40 +02:00
Marcus Efraimsson
78f460c4de
Tracing: Allow otel service name and attributes to be overridden from env (#85937)
Co-authored-by: Christopher Moyer <35463610+chri2547@users.noreply.github.com>
2024-04-11 15:18:46 +02:00
Todd Treece
796b15d9e0
Metrics: Prevent duplicates in MultiRegistry (#85880) 2024-04-10 10:55:24 -04:00
Todd Treece
72472e5eb7
K8s: Add slog wrapper (#84680) 2024-04-09 18:39:25 +03:00
Karl Persson
504870f10a
Auth: Decouple client and hook registration (#85084) 2024-04-04 09:33:00 +02:00
Sofia Papagiannaki
369cb5b6eb
Usage stats: Fix concurrency issue (#84993)
* Usage stats: Fix concurrency issue
2024-03-22 15:52:59 +02:00
Marcus Efraimsson
6c1de260a2
API Server: Standalone observability (#84789)
Adds support for logs (specify level), metrics (enable metrics and Prometheus /metrics endpoint 
and traces (jaeger or otlp) for standalone API server. This will allow any grafana core service 
part of standalone apiserver to use logging, metrics and traces as normal.
2024-03-21 17:06:32 +01:00
Xavi Lacasa
a813046f3d
Better tracing during extSvcAcc registration (#84719) 2024-03-21 16:41:10 +01:00
Charandas
2d1cd82a98
K8s: standalone: use Grafana's logger to stream all logs (#84530)
---
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2024-03-18 19:25:30 +02:00
Andres Martinez Gotor
6204f1e847
Chore: Use SigV4 middleware from aws-sdk (#84462) 2024-03-18 09:33:22 +01:00
Andres Martinez Gotor
c061cc33cc
Chore: Use response limit middleware from SDK (#83915) 2024-03-13 10:14:16 +01:00
Jo
108202f96c
UsageStats: Separate context and threads for usage stats (#83963)
* separate context and threads for usage stats

* use constants

* ignore original context

* fix runMetricsFunc

* fix collector registration

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>

* change background ctx

* fix test randomness

* Add traces to support bundle collector

* Remove unecessay span

* Add trace to usagestats api

* Close spans

* Mv trace to bundle

* Change span name

* use parent context

* fix runtime declare of stats

* Fix pointer dereference problem on usage stat func

Co-authored-by: Karl Persson <kalle.persson@grafana.com>
Co-authored-by: jguer <joao.guerreiro@grafana.com>

* fix broken support bundle tests by tracer

---------

Co-authored-by: Gabriel MABILLE <gamab@users.noreply.github.com>
Co-authored-by: gamab <gabriel.mabille@grafana.com>
Co-authored-by: Karl Persson <kalle.persson@grafana.com>
2024-03-11 15:18:42 +01:00
Ieva
2c5b72e844
AuthZ: add headers for IP range AC checks for data source proxy requests (#81662)
* add a middleware that appens headers for IP range AC to data source proxy requests

* update code

* add tests

* fix a mistake

* add logging

* refactor to reuse code

* small cleanup

* skip the plugins middleware if the header is already set

* skip the plugins middleware if the header is already set
2024-03-06 12:40:48 +00:00
Jo
36a19bfa83
AuthProxy: Allow disabling Auth Proxy cache (#83755)
* extract auth proxy settings

* simplify auth proxy methods

* add doc mentions
2024-03-01 11:31:06 +01:00
Dan Cech
790e1feb93
Chore: Update test database initialization (#81673)
* streamline initialization of test databases, support on-disk sqlite test db

* clean up test databases

* introduce testsuite helper

* use testsuite everywhere we use a test db

* update documentation

* improve error handling

* disable entity integration test until we can figure out locking error
2024-02-09 09:35:39 -05:00
Isabella Siu
3b852bb582
CloudWatch: Remove references to pkg/infra/metrics (#81744)
CloudWatch: remove references to pkg/infra/metrics
2024-02-06 21:21:55 +02:00
Bruno
89fb56bc11
Add secureSocksDSProxyEnabled label to grafana_datasource_request_duration_seconds (#80910)
* Add secureSocksDSProxyEnabled label to grafana_datasource_request_duration_seconds

* rename label from secureSocksDSProxyEnabled to secure_socks_ds_proxy_enabled

* DataSourceMetricsMiddleware: add secure_socks_ds_proxy_enabled label to every metric
2024-02-01 11:42:43 -03:00
Gabriel MABILLE
08f305797f
RBAC: Add metric to count search user permissions cache hits (#81451) 2024-01-30 10:37:47 +01:00
idafurjes
fb2b9f33d2
Fix method to service in metric label for FolderID (#81283) 2024-01-25 18:26:24 +02:00
idafurjes
0880a239f8
Add leftover metrics for FolderID (#81246) 2024-01-25 12:14:18 +01:00
idafurjes
7e5544ab21
Add MFolderIDsServiceCount to count folderIDs in services pkg (#81237) 2024-01-25 11:10:35 +01:00
idafurjes
6b4eaa0d18
Add MFolderIDsAPICount metric to count FolderIDs in api package (#80866)
* Add MFolderIDsAPICount metric to cound FolderIDs in api package

* Change counter to counter vector with method names as string values
2024-01-24 12:39:11 +01:00
Ryan McKinley
2b355ff280
K8s: Remove grafanaAPIServer feature toggle (#81030) 2024-01-23 08:27:28 -08:00