* Move data source management to administration * Move RBAC to administration * Move team management up a docs org level * Combine and rename admin preferences docs * Move plugin management to administration * Combine plugin management docs * Combine API key docs * Combine service account docs * Combine server user management docs * Move datasource management to administration * Move enterprise licenses to administration * Move CLI out of admin, update links to admin * Merge org user management docs * Restructure to Torkel's plan * Fix typo * Weigh admin topics for navigation * Weigh administration topics and align to Torkel's plan * Move server user management from server admin to admin/user management * Move configure docker image to setup guide * Move the remaining server admin docs to the root admin directory * Reweight docker config
4.4 KiB
aliases | description | title | weight | ||
---|---|---|---|---|---|
|
Learn how to use Google Cloud KMS to encrypt secrets in the Grafana database. | Encrypt database secrets using Google Cloud KMS | 100 |
Encrypt database secrets using Google Cloud KMS
You can use an encryption key from Google Cloud Key Management Service to encrypt secrets in the Grafana database.
Prerequisites:
- A Google Cloud account with permission to list and create KMS keys and service accounts to access those keys
- Access to the Grafana [configuration]({{< relref "../../configure-grafana/#config-file-locations" >}}) file
-
Create a key ring in Google Cloud KMS.
-
Create a symmetric encryption key in the key ring.
-
Create a service account and assign it a role: it can be a predefined role or custom role with permissions to encrypt and decrypt secrets with Key Management Service.
-
Create a service account key and save its JSON file to you computer, for example, as
~/.config/gcloud/sample-project-credentials.json
. -
From within Grafana, turn on [envelope encryption]({{< relref "/#envelope-encryption" >}}).
-
Add your Google Cloud KMS details to the Grafana configuration file; depending on your operating system, is usually named
grafana.ini
:
a. Add a new section to the configuration file, with a name in the format of[security.encryption.azurekv.<KEY-NAME>]
, where<KEY-NAME>
is any name that uniquely identifies this key among other provider keys.
b. Fill in the section with the following values:key_id
: encryption key ID, refer to Getting the ID for a Key.credentials_file
: full path to service account key JSON file on your computer.
An example of a Google Cloud KMS provider section in the
grafana.ini
file is as follows:# Example of Google Cloud KMS provider setup ;[security.encryption.googlekms.example-encryption-key] # Google Cloud KMS key ID key_id = 1234abcd-12ab-34cd-56ef-1234567890ab # Full path to a JSON file with a service account key credentials_file = ~/.config/gcloud/sample-project-credentials.json
-
Update the
[security]
section of thegrafana.ini
configuration file with the new Encryption Provider key that you created:[security] # previous encryption key, used for legacy alerts, decrypting existing secrets or used as default provider when external providers are not configured secret_key = AaaaAaaa # encryption provider key in the format <PROVIDER>.<KEY-NAME> encryption_provider = googlekms.example-encryption-key # list of configured key providers, space separated available_encryption_providers = googlekms.example-encryption-key
> Note: The encryption key stored in the
secret_key
field is still used by Grafana’s legacy alerting system to encrypt secrets. Do not change or remove that value. -
(Optional) From the command line and the root directory of Grafana Enterprise, re-encrypt all of the secrets within the Grafana database with the new key using the following command:
grafana-cli admin secrets-migration re-encrypt
If you do not re-encrypt existing secrets, then they will remain encrypted by the previous encryption key. Users will still be able to access them.
> Note: This process could take a few minutes to complete, depending on the number of secrets (such as data sources or alert notification channels) in your database. Users might experience errors while this process is running, and alert notifications might not be sent.
> Note: If you are updating this encryption key during the initial setup of Grafana before any data sources, alert notification channels, or dashboards have been created, then this step is not necessary because there are no secrets in Grafana to migrate.