Skip to content

Commit a71b981

Browse files
committed
Merge branch 'main' into gio/feat/create-correlation-api
2 parents 1619f2a + 0768513 commit a71b981

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1654
-581
lines changed

docs/sources/alerting/migrating-alerts/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ weight: 101
1313

1414
Grafana Alerting is enabled by default for new installations or existing installations whether or not legacy alerting is configured.
1515

16-
> **Note**: We recommend that Grafana Enterprise customers with more than a dozen Grafana dashboard alert rules do not upgrade and remain on legacy alerting for now by [opting out]({{< relref "opt-out/" >}}). If you do want to upgrade to Grafana Alerting, contact customer support.
16+
> **Note**: When upgrading, your dashboard alerts are migrated to a new format. This migration can be rolled back easily by [opting out]({{< relref "opt-out/" >}}). If you have any questions regarding this migration, please contact us.
1717
1818
Existing installations that do not use legacy alerting will have Grafana Alerting enabled by default unless alerting is disabled in the configuration.
1919

docs/sources/developers/http_api/admin.md

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -718,11 +718,7 @@ Content-Type: application/json
718718

719719
`POST /api/admin/encryption/rotate-data-keys`
720720

721-
Rotates data encryption keys, so all the active keys are disabled
722-
and no longer used for encryption but kept for decryption operations.
723-
724-
Secrets encrypted with one of the deactivated keys need to be re-encrypted
725-
to actually stop using those keys for both encryption and decryption.
721+
[Rotates]({{< relref "../../setup-grafana/configure-security/configure-database-encryption/#rotate-data-keys" >}}) data encryption keys.
726722

727723
**Example Request**:
728724

@@ -738,3 +734,66 @@ Content-Type: application/json
738734
HTTP/1.1 204
739735
Content-Type: application/json
740736
```
737+
738+
## Re-encrypt data encryption keys
739+
740+
`POST /api/admin/encryption/reencrypt-data-keys`
741+
742+
[Re-encrypts]({{< relref "../../setup-grafana/configure-security/configure-database-encryption/#re-encrypt-data-keys" >}}) data encryption keys.
743+
744+
**Example Request**:
745+
746+
```http
747+
POST /api/admin/encryption/reencrypt-data-keys HTTP/1.1
748+
Accept: application/json
749+
Content-Type: application/json
750+
```
751+
752+
**Example Response**:
753+
754+
```http
755+
HTTP/1.1 204
756+
Content-Type: application/json
757+
```
758+
759+
## Re-encrypt secrets
760+
761+
`POST /api/admin/encryption/reencrypt-secrets`
762+
763+
[Re-encrypts]({{< relref "../../setup-grafana/configure-security/configure-database-encryption/#re-encrypt-secrets" >}}) secrets.
764+
765+
**Example Request**:
766+
767+
```http
768+
POST /api/admin/encryption/reencrypt-secrets HTTP/1.1
769+
Accept: application/json
770+
Content-Type: application/json
771+
```
772+
773+
**Example Response**:
774+
775+
```http
776+
HTTP/1.1 204
777+
Content-Type: application/json
778+
```
779+
780+
## Roll back secrets
781+
782+
`POST /api/admin/encryption/rollback-secrets`
783+
784+
[Rolls back]({{< relref "../../setup-grafana/configure-security/configure-database-encryption/#roll-back-secrets" >}}) secrets.
785+
786+
**Example Request**:
787+
788+
```http
789+
POST /api/admin/encryption/rollback-secrets HTTP/1.1
790+
Accept: application/json
791+
Content-Type: application/json
792+
```
793+
794+
**Example Response**:
795+
796+
```http
797+
HTTP/1.1 204
798+
Content-Type: application/json
799+
```

docs/sources/setup-grafana/configure-security/configure-database-encryption/_index.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Grafana encrypts these secrets before they are written to the database, by using
1818
Since Grafana v9.0, it uses [envelope encryption](#envelope-encryption) by default, which adds a layer of indirection to the
1919
encryption process that represents an [**implicit breaking change**](#implicit-breaking-change) for older versions of Grafana.
2020

21-
For further details about how to operate a Grafana instance with envelope encryption, see the [Operational work]({{< relref "/#operational-work" >}}) section below.
21+
For further details about how to operate a Grafana instance with envelope encryption, see the [Operational work](#operational-work) section below.
2222

2323
> **Note:** In Grafana Enterprise, you can also choose to [encrypt secrets in AES-GCM mode]({{< relref "#changing-your-encryption-mode-to-aes-gcm" >}}) instead of AES-CFB.
2424
@@ -31,7 +31,7 @@ Instead of encrypting all secrets with a single key, Grafana uses a set of keys
3131
encrypt them. These data encryption keys are themselves encrypted with a single key encryption key (KEK), configured
3232
through the `secret_key` attribute in your
3333
[Grafana configuration]({{< relref "../../configure-grafana/#secret_key" >}}) or with a
34-
[KMS integration](#kms-integration).
34+
[KMS integration](#encrypting-your-database-with-a-key-from-a-key-management-system-kms).
3535

3636
## Implicit breaking change
3737

@@ -67,24 +67,27 @@ Secrets re-encryption can be performed when a Grafana administrator wants to eit
6767
- Re-encrypt secrets after a [data keys rotation](#rotate-data-keys).
6868

6969
> **Note:** This operation is available through Grafana CLI by running `grafana-cli admin secrets-migration re-encrypt`
70-
> command. It's safe to run more than once. Recommended to run under maintenance mode.
70+
> command and through Grafana [Admin API]({{< relref "../../../developers/http_api/admin/#re-encrypt-secrets" >}}).
71+
> It's safe to run more than once. Recommended to run under maintenance mode.
7172
7273
## Roll back secrets
7374

7475
Used to roll back secrets encrypted with envelope encryption to legacy encryption. It can be used to downgrade to
7576
a Grafana version earlier than Grafana v9.0 after an unsuccessful upgrade.
7677

7778
> **Note:** This operation is available through Grafana CLI by running `grafana-cli admin secrets-migration rollback`
78-
> command. It's safe to run more than once. Recommended to run under maintenance mode.
79+
> command and through Grafana [Admin API]({{< relref "../../../developers/http_api/admin/#roll-back-secrets" >}}).
80+
> It's safe to run more than once. Recommended to run under maintenance mode.
7981
8082
## Re-encrypt data keys
8183

8284
Used to re-encrypt data keys encrypted with a specific key encryption key (KEK). It can be used to either re-encrypt
83-
existing data keys with a new key encryption key version (see [KMS integration](#kms-integration) rotation) or to
85+
existing data keys with a new key encryption key version (see [KMS integration](#encrypting-your-database-with-a-key-from-a-key-management-system-kms) rotation) or to
8486
re-encrypt them with a completely different key encryption key.
8587

8688
> **Note:** This operation is available through Grafana CLI by running `grafana-cli admin secrets-migration re-encrypt-data-keys`
87-
> command. It's safe to run more than once. Recommended to run under maintenance mode.
89+
> command and through Grafana [Admin API]({{< relref "../../../developers/http_api/admin/#re-encrypt-data-encryption-keys" >}}).
90+
> It's safe to run more than once. Recommended to run under maintenance mode.
8891
8992
## Rotate data keys
9093

pkg/api/admin_encryption.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,42 @@ import (
99

1010
func (hs *HTTPServer) AdminRotateDataEncryptionKeys(c *models.ReqContext) response.Response {
1111
if err := hs.SecretsService.RotateDataKeys(c.Req.Context()); err != nil {
12-
return response.Error(http.StatusInternalServerError, "Failed to rotate data key", err)
12+
return response.Error(http.StatusInternalServerError, "Failed to rotate data keys", err)
1313
}
1414

1515
return response.Respond(http.StatusNoContent, "")
1616
}
17+
18+
func (hs *HTTPServer) AdminReEncryptEncryptionKeys(c *models.ReqContext) response.Response {
19+
if err := hs.SecretsService.ReEncryptDataKeys(c.Req.Context()); err != nil {
20+
return response.Error(http.StatusInternalServerError, "Failed to re-encrypt data keys", err)
21+
}
22+
23+
return response.Respond(http.StatusOK, "Data encryption keys re-encrypted successfully")
24+
}
25+
26+
func (hs *HTTPServer) AdminReEncryptSecrets(c *models.ReqContext) response.Response {
27+
success, err := hs.secretsMigrator.ReEncryptSecrets(c.Req.Context())
28+
if err != nil {
29+
return response.Error(http.StatusInternalServerError, "Failed to re-encrypt secrets", err)
30+
}
31+
32+
if !success {
33+
return response.Error(http.StatusPartialContent, "Something unexpected happened, refer to the server logs for more details", err)
34+
}
35+
36+
return response.Respond(http.StatusOK, "Secrets re-encrypted successfully")
37+
}
38+
39+
func (hs *HTTPServer) AdminRollbackSecrets(c *models.ReqContext) response.Response {
40+
success, err := hs.secretsMigrator.RollBackSecrets(c.Req.Context())
41+
if err != nil {
42+
return response.Error(http.StatusInternalServerError, "Failed to rollback secrets", err)
43+
}
44+
45+
if !success {
46+
return response.Error(http.StatusPartialContent, "Something unexpected happened, refer to the server logs for more details", err)
47+
}
48+
49+
return response.Respond(http.StatusOK, "Secrets rolled back successfully")
50+
}

pkg/api/api.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,9 @@ func (hs *HTTPServer) registerRoutes() {
575575
}
576576

577577
adminRoute.Post("/encryption/rotate-data-keys", reqGrafanaAdmin, routing.Wrap(hs.AdminRotateDataEncryptionKeys))
578+
adminRoute.Post("/encryption/reencrypt-data-keys", reqGrafanaAdmin, routing.Wrap(hs.AdminReEncryptEncryptionKeys))
579+
adminRoute.Post("/encryption/reencrypt-secrets", reqGrafanaAdmin, routing.Wrap(hs.AdminReEncryptSecrets))
580+
adminRoute.Post("/encryption/rollback-secrets", reqGrafanaAdmin, routing.Wrap(hs.AdminRollbackSecrets))
578581

579582
adminRoute.Post("/provisioning/dashboards/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ActionProvisioningReload, ScopeProvisionersDashboards)), routing.Wrap(hs.AdminProvisioningReloadDashboards))
580583
adminRoute.Post("/provisioning/plugins/reload", authorize(reqGrafanaAdmin, ac.EvalPermission(ActionProvisioningReload, ScopeProvisionersPlugins)), routing.Wrap(hs.AdminProvisioningReloadPlugins))

pkg/api/docs/definitions/playlists.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package definitions
22

33
import (
44
"github.com/grafana/grafana/pkg/api/dtos"
5-
"github.com/grafana/grafana/pkg/models"
5+
"github.com/grafana/grafana/pkg/services/playlist"
66
)
77

88
// swagger:route GET /playlists playlists searchPlaylists
@@ -121,7 +121,7 @@ type DeletePlaylistParams struct {
121121
type UpdatePlaylistParams struct {
122122
// in:body
123123
// required:true
124-
Body models.UpdatePlaylistCommand
124+
Body playlist.UpdatePlaylistCommand
125125
// in:path
126126
// required:true
127127
UID string `json:"uid"`
@@ -131,28 +131,28 @@ type UpdatePlaylistParams struct {
131131
type CreatePlaylistParams struct {
132132
// in:body
133133
// required:true
134-
Body models.CreatePlaylistCommand
134+
Body playlist.CreatePlaylistCommand
135135
}
136136

137137
// swagger:response searchPlaylistsResponse
138138
type SearchPlaylistsResponse struct {
139139
// The response message
140140
// in: body
141-
Body models.Playlists `json:"body"`
141+
Body playlist.Playlists `json:"body"`
142142
}
143143

144144
// swagger:response getPlaylistResponse
145145
type GetPlaylistResponse struct {
146146
// The response message
147147
// in: body
148-
Body *models.PlaylistDTO `json:"body"`
148+
Body *playlist.PlaylistDTO `json:"body"`
149149
}
150150

151151
// swagger:response getPlaylistItemsResponse
152152
type GetPlaylistItemsResponse struct {
153153
// The response message
154154
// in: body
155-
Body []models.PlaylistItemDTO `json:"body"`
155+
Body []playlist.PlaylistItemDTO `json:"body"`
156156
}
157157

158158
// swagger:response getPlaylistDashboardsResponse
@@ -166,12 +166,12 @@ type GetPlaylistDashboardsResponse struct {
166166
type UpdatePlaylistResponseResponse struct {
167167
// The response message
168168
// in: body
169-
Body *models.PlaylistDTO `json:"body"`
169+
Body *playlist.PlaylistDTO `json:"body"`
170170
}
171171

172172
// swagger:response createPlaylistResponse
173173
type CreatePlaylistResponse struct {
174174
// The response message
175175
// in: body
176-
Body *models.Playlist `json:"body"`
176+
Body *playlist.Playlist `json:"body"`
177177
}

pkg/api/http_server.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import (
5858
"github.com/grafana/grafana/pkg/services/login"
5959
"github.com/grafana/grafana/pkg/services/ngalert"
6060
"github.com/grafana/grafana/pkg/services/notifications"
61+
"github.com/grafana/grafana/pkg/services/playlist"
6162
"github.com/grafana/grafana/pkg/services/plugindashboards"
6263
pluginSettings "github.com/grafana/grafana/pkg/services/pluginsettings/service"
6364
pref "github.com/grafana/grafana/pkg/services/preference"
@@ -170,6 +171,7 @@ type HTTPServer struct {
170171
dashboardVersionService dashver.Service
171172
PublicDashboardsApi *publicdashboardsApi.Api
172173
starService star.Service
174+
playlistService playlist.Service
173175
CoremodelRegistry *registry.Generic
174176
CoremodelStaticRegistry *registry.Static
175177
kvStore kvstore.KVStore
@@ -208,7 +210,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
208210
avatarCacheServer *avatar.AvatarCacheServer, preferenceService pref.Service, entityEventsService store.EntityEventsService,
209211
teamsPermissionsService accesscontrol.TeamPermissionsService, folderPermissionsService accesscontrol.FolderPermissionsService,
210212
dashboardPermissionsService accesscontrol.DashboardPermissionsService, dashboardVersionService dashver.Service,
211-
starService star.Service, csrfService csrf.Service, coremodelRegistry *registry.Generic, coremodelStaticRegistry *registry.Static,
213+
starService star.Service, playlistService playlist.Service, csrfService csrf.Service, coremodelRegistry *registry.Generic, coremodelStaticRegistry *registry.Static,
212214
kvStore kvstore.KVStore, secretsMigrator secrets.Migrator, remoteSecretsCheck secretsKV.UseRemoteSecretsPluginCheck,
213215
publicDashboardsApi *publicdashboardsApi.Api, userService user.Service) (*HTTPServer, error) {
214216
web.Env = cfg.Env
@@ -292,6 +294,7 @@ func ProvideHTTPServer(opts ServerOptions, cfg *setting.Cfg, routeRegister routi
292294
dashboardPermissionsService: dashboardPermissionsService,
293295
dashboardVersionService: dashboardVersionService,
294296
starService: starService,
297+
playlistService: playlistService,
295298
CoremodelRegistry: coremodelRegistry,
296299
CoremodelStaticRegistry: coremodelStaticRegistry,
297300
kvStore: kvStore,

0 commit comments

Comments
 (0)