# Grafana Service Account Token

## Step 1 - generate Grafana Service Account Token

* Make sure you have [groundcover cli installed](/getting-started/installation-and-updating/connect-kubernetes-cluster.md#installing-groundcover-cli)

```bash
groundcover version
```

* Generate service account token

```bash
groundcover auth generate-service-account-token
```

{% hint style="warning" %}
Service Account Token are only accessible once, so make sure you keep them somewhere safe, running the command again will generate a new service account token
{% endhint %}

{% hint style="warning" %}
Only groundcover tenant admins can generate Service Account Tokens
{% endhint %}

## Step 2 - Use Grafana Terraform provider

* make sure you have [Terraform installed](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/install-cli)
* Use the [official Grafana Terraform provider](https://registry.terraform.io/providers/grafana/grafana/latest/docs) with the following attributes

```hcl
terraform {
  required_providers {
    grafana = {
      source = "grafana/grafana"
    }
  }
}

provider "grafana" {
  url  = "https://app.groundcover.com/grafana"
  auth = "{service account token}"
}
```

Continue to create Alerts and Dashboards in Grafana, see: [Build alerts & dashboards with Grafana Terraform provider](/use-groundcover/embedded-grafana/embedded-grafana-dashboards/build-alerts-and-dashboards-with-grafana-terraform-provider.md).

You can read more about what you can achieve with the Grafana Terraform provider in the [official docs](https://registry.terraform.io/providers/grafana/grafana/latest/docs)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.groundcover.com/use-groundcover/remote-access-and-apis/build-alerts-and-dashboards-with-grafana-terraform-provider.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
