> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keephq.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Grafana Incident Provider

> Grafana Incident Provider alows you to query all incidents from Grafana Incident.

## Authentication

This provider requires authentication.

* **host\_url**: Grafana Host URL (required: True, sensitive: False)
* **service\_account\_token**: Service Account Token (required: True, sensitive: True)

Certain scopes may be required to perform specific actions or queries via the provider. Below is a summary of relevant scopes and their use cases:

* **authenticated**: User is Authenticated

## In workflows

This provider can be used in workflows.

As "action" to make changes or update data, example:

```yaml theme={null}
actions:
    - name: Query grafana_incident
      provider: grafana_incident
      config: "{{ provider.my_provider_name }}"
      with:
        operationType: {value}  
        updateType: {value}  
```

Check the following workflow examples:

* [create-new-incident-grafana-incident.yaml](https://github.com/keephq/keep/blob/main/examples/workflows/create-new-incident-grafana-incident.yaml)
* [update-incident-grafana-incident.yaml](https://github.com/keephq/keep/blob/main/examples/workflows/update-incident-grafana-incident.yaml)

## Getting started

1. In your Grafana Cloud stack, click Alerts & IRM in the left-side menu.
2. Click the Incident tile to enable the app for your Grafana Cloud instance.
3. Once Grafana Incident is enabled it is accessible to users in your organization.

## Connecting with the Provider

1. After enabling the Grafana Incident app, navigate Adminstration > Users and access > Service Accounts.
2. Create a new service account by clicking the Add Service Account button.
3. Give the service account a name and assign role as Viewer.
4. Click on Add service account token and click on Generate token.
5. Copy the generated token.
6. This will be used as the `service_account_token` parameter in the provider configuration.

## Creating and updating Grafana Incidents

Grafana Incident provider supports creating and updating incidents in Grafana.

* `operationType` - The operation type can be `create` or `update`.
* `updateType` - The update type is used to update the various fields of the incident.

### Create Incident

* `operationType` - `create`
* `title` (str) - The title of the incident.
* `severity` (str) - The severity of the incident.
* `labels` (list) - The labels of the incident.
* `roomPrefix` (str) - The room prefix of the incident.
* `isDrill` (bool) - The drill status of the incident.
* `status` (str) - The status of the incident.
* `attachCaption` (str) - The attachment caption of the incident.
* `attachURL` (str) - The attachment URL of the incident.

### Update Incident

* `operationType` - `update`
* `updateType` - The updatable fields are `removeLabel`, `unassignLabel`, `unassignLabelByUUID`, `unassignRole`, `updateIncidentEventTime`, `updateIncidentIsDrill`, `updateIncidentSeverity`, `updateIncidentStatus`, `updateIncidentTitle`.

#### Remove Label

* `incident_id` (str) - The incident ID.
* `label` (str) - The label to remove.

#### Unassign Label

* `incident_id` (str) - The incident ID.
* `label` (str) - The label to unassign.
* `key` (str) - The key of the label to unassign.

#### Unassign Label By UUID

* `incident_id` (str) - The incident ID.
* `key_uuid` (str) - The key UUID of the label to unassign.
* `value_uuid` (str) - The value UUID of the label to unassign.

#### Unassign Role

* `incident_id` (str) - The incident ID.
* `role` (str) - The role to unassign.
* `user_id` (str) - The user ID to unassign.

#### Update Incident Event Time

* `incident_id` (str) - The incident ID.
* `event_time` (str) - The event time to update.
* `event_name` (str) - The event name to update.

#### Update Incident Is Drill

* `incident_id` (str) - The incident ID.
* `isDrill` (bool) - The drill status to update.

#### Update Incident Severity

* `incident_id` (str) - The incident ID.
* `severity` (str) - The severity to update.

#### Update Incident Status

* `incident_id` (str) - The incident ID.
* `status` (str) - The status to update.

#### Update Incident Title

* `incident_id` (str) - The incident ID.
* `title` (str) - The title to update.

## Usefull Links

* [Grafana Incident](https://grafana.com/docs/grafana-cloud/alerting-and-irm/incident/)
