The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/api
Jack Westbrook 7d6e08a6d5
Frontend: Rewrite SRI checks feature flag to support frontend-service (#123491)
2 weeks ago
..
apierrors Folders: Move folder specific errors to the folder service (#122050) 1 month ago
avatar Users: Use SHA-256 for Gravatar email identifier (#122319) 4 weeks ago
datasource Datasource Permissions: Allow sending in query param `ds_type` and add database migration (#121501) 1 month ago
dtos Frontend: Rewrite SRI checks feature flag to support frontend-service (#123491) 2 weeks ago
frontendlogging
pluginproxy
response
routing [chore] Update go to v1.26.0, and the golangci-lint action to v9 (#118436) 3 months ago
static
webassets React 19: Build assets with React 19 (#118457) 3 months ago
README.md
accesscontrol.go Snapshots: Move back to dashboards for now (#122067) 1 month ago
admin.go
admin_encryption.go
admin_provisioning.go
admin_provisioning_test.go
admin_test.go
admin_users.go
admin_users_test.go
alerting.go Alerting: Allow restricting contact point integration types (#118858) 3 weeks ago
annotations.go Dashboards: Refactor to keep perms separated (#122041) 1 month ago
annotations_test.go Dashboards: Refactor to keep perms separated (#122041) 1 month ago
api.go Storage: Remove storage http bindings and feature toggle (#123484) 2 weeks ago
api_test.go
basic_auth.go
basic_auth_test.go
common_test.go
dashboard.go Homepage: Support v2 dashboards if defined by a file (#122994) 3 weeks ago
dashboard_permission.go Dashboards: Deprecate the dashboard and folder apis in swagger (#121222) 2 months ago
dashboard_permission_test.go
dashboard_snapshot.go Snapshots: Move back to dashboards for now (#122067) 1 month ago
dashboard_snapshot_test.go Dashboards: Refactor to keep perms separated (#122041) 1 month ago
dashboard_test.go Homepage: Support v2 dashboards if defined by a file (#122994) 3 weeks ago
dataproxy.go Datasources: Disable deprecated numeric id using APIs by default (#119930) 2 months ago
datasources.go Datasources: Disable deprecated numeric id using APIs by default (#119930) 2 months ago
datasources_k8s.go Add new feature flag for rollout of datasource CRUD APIs (#122618) 3 weeks ago
datasources_k8s_test.go Add new feature flag for rollout of datasource CRUD APIs (#122618) 3 weeks ago
datasources_test.go add redirect for resource endpoints (#120269) 2 months ago
ds_query.go Query: Rename query.grafana.app to datasource.grafana.app (#118267) 3 months ago
ds_query_test.go datasources: refactor the request validator api (#116619) 4 months ago
fakes.go
folder.go unified-storage: fix case permission on folder list query (#122334) 1 month ago
folder_bench_test.go User: Expose team UIDs as Groups (#123228) 3 weeks ago
folder_permission.go Dashboards: Deprecate the dashboard and folder apis in swagger (#121222) 2 months ago
folder_permission_test.go Dashboards: Refactor to keep perms separated (#122041) 1 month ago
folder_test.go Folders: Move folder specific errors to the folder service (#122050) 1 month ago
frontend_logging.go
frontend_logging_test.go
frontend_metrics.go
frontendsettings.go Security: Fix CVE-2026-27876, CVE-2026-27877, CVE-2026-28375, CVE-2026-27879, CVE-2026-27880 (#121514) 1 month ago
frontendsettings_test.go Security: Fix CVE-2026-27876, CVE-2026-27877, CVE-2026-28375, CVE-2026-27879, CVE-2026-27880 (#121514) 1 month ago
grafana_com_proxy.go
health.go
health_test.go
http_server.go Storage: Remove storage http bindings and feature toggle (#123484) 2 weeks ago
http_server_test.go Server: Support simultaneous TCP and Unix domain socket serving (#118627) 2 months ago
index.go Frontend: Rewrite SRI checks feature flag to support frontend-service (#123491) 2 weeks ago
live_test.go Live: Add RBAC for pushing to live (#120547) 2 months ago
login.go Auth: Remove passwordless (magic link) authentication backend implementation (#118881) 1 month ago
login_oauth.go Auth: URL-encode redirectTo cookie value in OAuth login flow (#121953) 4 weeks ago
login_oauth_test.go Auth: URL-encode redirectTo cookie value in OAuth login flow (#121953) 4 weeks ago
login_test.go
org.go
org_invite.go
org_invite_test.go
org_test.go
org_users.go
org_users_test.go IAM: Add support for kubernetes APIs in user service (#120502) 2 months ago
password.go IAM: Add GetByLoginWithPassword to the User service interface (#121838) 1 month ago
playlist.go Chore: Add K8s client provider (#122900) 3 weeks ago
plugin_checks.go
plugin_checks_test.go
plugin_dashboards.go
plugin_dashboards_test.go
plugin_metrics.go
plugin_metrics_test.go
plugin_proxy.go
plugin_proxy_test.go
plugin_resource.go datasources: refactor the request validator api (#116619) 4 months ago
plugin_resource_test.go Elasticsearch: Remove core datasource (#119956) 1 month ago
plugins.go Plugins: Add include-datasource param to show nested datasources in catalog (#122957) 2 weeks ago
plugins_test.go Plugins: Add include-datasource param to show nested datasources in catalog (#122957) 2 weeks ago
preferences.go Chore: Remove experimental feature individualCookiePreferences (#116374) 4 months ago
preferences_test.go
quota.go
quota_test.go
render.go Rendering: Remove support for unimplemented render session (#119962) 2 months ago
search.go [chore] Update go to v1.26.0, and the golangci-lint action to v9 (#118436) 3 months ago
short_url.go Chore: Add K8s client provider (#122900) 3 weeks ago
short_url_test.go
signup.go
swagger.go CSP: Add configurable form-action directive via $FORM_ACTION_ADDITIONAL_HOSTS (#121473) 1 month ago
swagger_responses.go
swagger_tags.json
user.go
user_test.go IAM: Add support for kubernetes APIs in user service (#120502) 2 months ago
user_token.go Redirect logic update (#118663) 3 months ago
user_token_test.go
utils.go Redirect logic update (#118663) 3 months ago

README.md

OpenAPI specifications

Since version 8.4, HTTP API details are specified using OpenAPI v2. Starting from version 9.1, there is also an OpenAPI v3 specification (generated by the v2 one using this script).

OpenAPI annotations

The OpenAPI v2 specification is generated automatically from the annotated Go code using go-swagger which scans the source code for annotation rules. Refer to this getting started guide for getting familiar with the toolkit.

Developers modifying the HTTP API endpoints need to make sure to add the necessary annotations so that their changes are reflected into the generated specifications.

Example of endpoint annotation

The following route defines a PATCH endpoint under the /serviceaccounts/{serviceAccountId} path with tag service_accounts (used for grouping together several routes) and operation ID updateServiceAccount (used for uniquely identifying routes and associate parameters and response with them).

For enterprise endpoints make sure you add the enterprise tag as well.


// swagger:route PATCH /serviceaccounts/{serviceAccountId} service_accounts updateServiceAccount
//
// # Update service account
//
// Required permissions (See note in the [introduction](https://grafana.com/docs/grafana/latest/developers/http_api/serviceaccount/#service-account-api) for an explanation):
// action: `serviceaccounts:write` scope: `serviceaccounts:id:1` (single service account)
//
// Responses:
// 200: updateServiceAccountResponse
// 400: badRequestError
// 401: unauthorisedError
// 403: forbiddenError
// 404: notFoundError
// 500: internalServerError

The go-swagger can discover such annotations by scanning any code imported by pkg/server but by convention we place the endpoint annotations above the endpoint definition.

Example of endpoint parameters

The following struct defines the route parameters for the updateServiceAccount endpoint. The route expects:

  • a path parameter denoting the service account identifier and
  • a body parameter with the new values for the specific service account

// swagger:parameters updateServiceAccount
type UpdateServiceAccountParams struct {
	// in:path
	ServiceAccountId int64 `json:"serviceAccountId"`
	// in:body
	Body serviceaccounts.UpdateServiceAccountForm
}

Example of endpoint response

The following struct defines the response for the updateServiceAccount endpoint in case of a successful 200 response.


// swagger:response updateServiceAccountResponse
type UpdateServiceAccountResponse struct {
	// in:body
	Body struct {
		Message        string                                    `json:"message"`
		ID             int64                                     `json:"id"`
		Name           string                                    `json:"name"`
		ServiceAccount *serviceaccounts.ServiceAccountProfileDTO `json:"serviceaccount"`
	}
}

OpenAPI generation

Developers can re-create the OpenAPI v2 and v3 specifications using the following command:

make swagger-clean && make openapi3-gen

They can observe its output into the public/api-merged.json and public/openapi3.json files.

Finally, they can browser and try out both the OpenAPI v2 and v3 via the Swagger UI editor (served by the grafana server) by navigating to /swagger.

If there are any issues generating the specifications (e.g., diff containing unrelated changes to your PR or unusually large diff), please run the following command to ensure your Swagger version is up to date, then re-run the make commands.

  • go tool github.com/go-swagger/go-swagger/cmd/swagger@v0.30.6