Commit graph

16 commits

Author SHA1 Message Date
Ryan McKinley
0015a819bf
DataSource/Proxy: decouple from DataSourceService from ds_proxy (#125752) 2026-06-08 13:28:30 +03:00
Mihai Turdean
646053df9e
AccessControl: Resolve built-in grafana datasource type without a store lookup (#125780)
The built-in "-- Grafana --" datasource has no row in the datasource table,
so legacyConnectionClientImpl.GetConnectionByUID could never resolve its plugin
type. For RBAC roles carrying the seeded datasources:uid:grafana grant this was
silently unresolved, and for global roles (orgID 0, multi-org) the store lookup
failed with ErrDataSourceIdentifierNotSet, breaking role provisioning.

Its UID and type are fixed and identical across orgs, so resolve it directly in
the legacy connection client. This fixes datasource-type resolution for every
caller that goes through this client (provisioning save and the k8s migration
type resolvers) without a store row.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-02 08:43:09 -06:00
Stephanie Hingtgen
8291111ea1
Datasource Permissions: Allow sending in query param ds_type and add database migration (#121501) 2026-03-31 15:34:11 -05:00
Charandas
50a1952f34
Health API: integrate apiserver readiness into /api/health (#120131)
* Health API: integrate apiserver readiness into /api/health

The /api/health endpoint is used as the Kubernetes readiness probe for
ST Grafana. Previously it only checked database connectivity, so
Kubernetes would route traffic before the apiserver's boot sequence
completed — causing 503s for aggregated API requests during the brief
window where serviceAvailable=false in proxy handlers.

When the apiserver's clientConfigProvider is available, /api/health now
makes an internal call to /readyz via DirectlyServeHTTP. If /readyz
returns non-200 (boot sequence health checks haven't passed), /api/health
returns 503 with "apiserver": "not ready" in the response body.

This eliminates user-facing 503s during pod startup without requiring
changes to deployment manifests (readiness probe stays on /api/health).

Stress test results (mt-tilt, 5 replicas scaling up simultaneously):
- 1240 requests during scale-up, zero 503s

When clientConfigProvider is nil (no apiserver, OSS without aggregation,
or unit tests), the check is skipped — no behavior change.

Companion to grafana-enterprise#11254 which adds the
remote-apiservice-initialization boot sequence health check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Health API: use timeout for apiserver readiness check

DirectlyServeHTTP blocks until the apiserver is ready. Without a
timeout, the health check would hang during startup (or in tests where
the apiserver hasn't started). Use a 2-second context timeout so the
health check returns "not ready" promptly instead of blocking.

Also check for context timeout explicitly — httptest.NewRecorder
defaults to status 200 if no response is written, which would
incorrectly pass the readiness check on timeout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Health API: integrate apiserver readiness into /api/health

The /api/health endpoint is used as the Kubernetes readiness probe for
ST Grafana. Previously it only checked database connectivity, so
Kubernetes would route traffic before the apiserver's boot sequence
completed — causing 503s for aggregated API requests during the brief
window where serviceAvailable=false in proxy handlers.

Add IsReady() to the DirectRestConfigProvider interface. The
eventualRestConfigProvider implements it with a non-blocking select on
the ready channel — returns true immediately once the apiserver has
started, false otherwise.

When the apiserver is not ready, /api/health returns 503 with
"apiserver": "not ready" in the response body. When clientConfigProvider
is nil (no apiserver, or unit tests), the check is skipped.

Stress test results (mt-tilt, 5 replicas scaling up simultaneously):
- 1240 requests during scale-up, zero 503s

Companion to grafana-enterprise#11254 which adds the
remote-apiservice-initialization boot sequence health check.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* make gofmt

* fix

* regenerate health response with apiserver key

* make gen-apps

* fix

* remaining gen-apps

* lint

* gofmt

* trigger build

* fix

* fix

* fix

* lint frontend

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-11 19:38:07 -07:00
Dafydd
8e672d9b96
datasources: create a legacy implementation of connectionsClient (#119109)
Some checks are pending
Integration Tests / Postgres Enterprise (8/16) (push) Blocked by required conditions
Integration Tests / Postgres Enterprise (9/16) (push) Blocked by required conditions
Integration Tests / All backend integration tests complete (push) Blocked by required conditions
publish-technical-documentation-next / sync (push) Waiting to run
Reject GitHub secrets / reject-gh-secrets (push) Waiting to run
Build Release Packages / setup (push) Waiting to run
Build Release Packages / Dispatch grafana-enterprise build (push) Blocked by required conditions
Build Release Packages / / darwin-amd64 (push) Blocked by required conditions
Build Release Packages / / darwin-arm64 (push) Blocked by required conditions
Build Release Packages / / linux-amd64 (push) Blocked by required conditions
Build Release Packages / / linux-armv6 (push) Blocked by required conditions
Build Release Packages / / linux-armv7 (push) Blocked by required conditions
Build Release Packages / / linux-arm64 (push) Blocked by required conditions
Build Release Packages / / linux-s390x (push) Blocked by required conditions
Build Release Packages / / windows-amd64 (push) Blocked by required conditions
Build Release Packages / / windows-arm64 (push) Blocked by required conditions
Build Release Packages / Upload artifacts (push) Blocked by required conditions
Build Release Packages / publish-dockerhub (push) Blocked by required conditions
Build Release Packages / Dispatch publish NPM canaries (push) Blocked by required conditions
Build Release Packages / notify-pr (push) Blocked by required conditions
Run dashboard schema v2 e2e / dashboard-schema-v2-e2e (push) Waiting to run
Shellcheck / Shellcheck scripts (push) Waiting to run
Run Storybook a11y tests / Detect whether code changed (push) Waiting to run
Run Storybook a11y tests / Run Storybook a11y tests (light theme) (push) Blocked by required conditions
Run Storybook a11y tests / Run Storybook a11y tests (dark theme) (push) Blocked by required conditions
Swagger generated code / Detect whether code changed (push) Waiting to run
Swagger generated code / Verify committed API specs match (push) Blocked by required conditions
Dispatch sync to mirror / dispatch-job (push) Waiting to run
trigger-dashboard-search-e2e / trigger-search-e2e (push) Waiting to run
Trivy Scan / trivy-scan (push) Waiting to run
* create a new implementation of connectionsclient which actually just calls the datasource service
2026-02-26 16:08:03 +00:00
Ryan McKinley
c40569ce97
Query: Rename query.grafana.app to datasource.grafana.app (#118267)
Co-authored-by: Dafydd <dafydd.thomas@grafana.com>
2026-02-18 18:36:17 +03:00
Dafydd
d7b5508f28
Reroute GET /api/datasources/uid/:uid to the /apis handlers (#116678)
* add some integration tests for existing datasource crud endpoints

* implement GET by uid redirect handler

* fix apis authorizer

* add unit tests for connections client

* add tests for the k8s datasource handler

* use the correct group, and dont prettify group name in listConnections response
2026-02-12 12:53:04 +00:00
Andreas Christou
3c777399d5
MSSQL: Minor refactor (#113976)
* Moving things around

* Copy parseURL function to where it's used

* Update test

* Remove experimental-strip-types

* Revert "Remove experimental-strip-types"

This reverts commit 70fbc1c0cd.

* Trigger build
2025-11-20 11:09:09 +00:00
Kevin Yu
fd6fd91115
Prometheus: Add support for cloud partners Prometheus data sources (#103482)
* wip

* Add prom flavor support for data source variables and export/import dashboards (#103321)

* add dashboard and data source var selection

* use match plugin id instead

* use updated matchpluginid

* formatting

* cleanup

* regex anchor

* update error msg

* Alerting: Clean up prometheus-flavored types and functions (#103703)

* clean up types and utility functions for dealing with
prometheus-flavored data sources

* Refactor alerting datasource types to use constants as source of truth

* Alerting: Clean up prometheus-flavored types and functions on the bac… (#103716)

Alerting: Clean up prometheus-flavored types and functions on the backend

* add matchPluginId tests

* Update matchPluginId func to bidirectional (#103746)

* update matchpluginid func to bidirectional

* lint

* formatting

* use actual isSupportedExternalRulesSourceType in test

* add tests in datasource_srv

* betterer

* remove type assertion

* remove unnecessary case

* use satisifies to not have to convert tuple to an array of string

* add prometheus_flavor test

---------

Co-authored-by: Andrew Hackmann <5140848+bossinc@users.noreply.github.com>
Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
Co-authored-by: Alexander Akhmetov <me@alx.cx>
2025-04-10 12:49:11 -07:00
Gábor Farkas
5b4da3a7dc
mssql: prepare logs-handling for decouple-datasource changes (#79214)
mssql: refactor logs-handling
2023-12-11 09:14:06 +01:00
Kristin Laemmert
945f015770
backend/datasources: move datasources models into the datasources service package (#51267)
* backend/datasources: move datasources models into the datasources service pkg
2022-06-27 12:23:15 -04:00
Santiago
7ed82ac049
Check for empty URLs when creating/updating a data source (#42837)
* checks for empty URLs added

* check for TimeSeriesTypeNot to fix InfluxDB alerts

* log a warning when a data frame is ignored

* fix: add brittle Prometheus URL input selector

needs a proper aria-label or test-data-id selector

* test: add URL input aria-label

needs to use the grafana/e2e-selectors package

* test: run ci

* add URL validation for specific data sources, e2e tests

* Update pkg/api/datasource/validation.go

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>

* delete duplicated logs

* delete unnecessary leading newline

Co-authored-by: gillesdemey <gilles.de.mey@gmail.com>
Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
2022-01-31 12:39:55 -03:00
Arve Knudsen
4dd7b7a82d
Chore: Remove unused Go code (#28852)
* Chore: Remove more unused Go code

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-11-17 11:51:31 +01:00
Arve Knudsen
4084b53f91
plugins: Don't exit on duplicate plugin (#28390)
* plugins: Don't exit on duplicate plugin

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Add missing files

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Fix test

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-10-21 12:39:41 +02:00
Arve Knudsen
d352c213b3
API: Recognize MSSQL data source URLs (#25629)
* API: Recognize MSSQL URLs

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>

* Move MSSQL URL validation into mssql package

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-06-17 11:17:11 +02:00
Arve Knudsen
164242f5fd
Data sources: Don't fail if URL doesn't specify protocol (#24497) 2020-05-12 13:04:18 +02:00