# Grafana

## Grafana

### Using kube-prometheus-stack

#### Values

[Grafana Helm Chart Base Values](https://github.com/grafana/helm-charts/blob/main/charts/grafana/values.yaml)

Values on the Grafana helm chart can be overridden from the parent `kube-prometheus-stack` chart

#### Datasources

**Useful Datasources**

**GitHub Datasource**

<https://github.com/grafana/github-datasource>

This datasource can help provide insight into GitHub within Grafana! This is super handy for pull requests and releases !\[\[Pasted image 20220228121552.png]]

**Adding New Datasources**

The chart can be tweaked so that the Grafana instance is preloaded with the desired datasources [CloudWatch Example](https://github.com/grafana/grafana/blob/main/docs/sources/datasources/aws-cloudwatch/provision-cloudwatch.md)

**Example**

```yaml
      additionalDataSources:
        - name: Loki
          type: loki
          uid: loki
          access: proxy
          orgId: 1
          url: http://loki-distributed-gateway.loki-distributed
          basicAuth: false
          isDefault: false
          version: 1
          editable: false
          jsonData:
            derivedFields:
            - datasourceUid: my-tempo
              matcherRegex: 'trace_id\":\"(\w+)\"'
              url: '$${__value.raw}'
              name: TraceID
        - name: Tempo
          type: tempo
          uid: my-tempo
          access: proxy
          url: http://tempo-distributed-query-frontend.tempo:3100
          isDefault: false
          version: 1
          editable: false
          basicAuth: false
```

### Dashboards

#### Transforming

To remove certain columns, use `Transform` and select `Filter by name` to remove columns that aren't desired

#### Variables

**Query**

**CloudWatch**

To query for specific resource ARNs run the following

```
resource_arns(default, rds:db, {"environment": ["$environment"]})
```

A regex can be performed as well to tidy up the ARN and extract just the resource itself

```
/.*db:([^$]*)/
```

A list of some available resources

* `rds:db`
* `elasticache:cluster`

[**Prometheus**](https://grafana.com/docs/grafana/latest/datasources/prometheus/#query-variable)

To get the label values for all deployments, run the following

```
label_values(kube_deployment_labels{namespace="portal"}, deployment)
```


---

# 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.harrison.kim/notes/grafana.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.
