Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dev with provisioning configs #23

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.3

* Supply necessary information to setup and use Grafana provisioning files.

## 0.3.0

* Update auth flow to work with new RunReveal token format
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ To trigger the workflow we need to push a version tag to github. This can be ach
2. Update any files needed.
3. Bump version number in the `package.json` file.
4. Add a new section to the `CHANGELOG.md` file. This file is published with the plugin and is visible by people viewing our plugin.
5. Once the PR is merged, the CI pipeline will auto tag the repo and a release will be started.
5. Once the PR is merged, add a tag to the repo with the same name as the version `v#.#.#`.
6. Upload the new release to grafana.com to get published.

## Learn more
Expand All @@ -104,3 +104,23 @@ Below you can find source code for existing app plugins and other related docume
- [Basic data source plugin example](https://github.com/grafana/grafana-plugin-examples/tree/master/examples/datasource-basic#readme)
- [Plugin.json documentation](https://grafana.com/docs/grafana/latest/developers/plugins/metadata/)
- [How to sign a plugin?](https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/)

## Provisioning

### PreSetup

Get a testing workspace ID and generate an api key with the `analyst` role.

Base64 encode the key (if not already done so) in the format `:<key>` where key is preceded by a colon.

### Running the Provisioning File

Run the following commands replacing `<workspace_id>` and `<session>` with their respective values.

```bash
export RRDS_WORKSPACE_ID=<workspace_id>
export RRDS_SESSION_TOKEN=<session>
docker-compose up
```

This will set the environment variables needed to correctly spin up the docker instance and auto provision the datasource.
4 changes: 4 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ services:
container_name: 'runreveal-runreveal-datasource'
build:
context: ./.config
environment:
- RRDS_WORKSPACE_ID=${RRDS_WORKSPACE_ID}
- RRDS_SESSION_TOKEN=${RRDS_SESSION_TOKEN}
ports:
- 3000:3000/tcp
volumes:
- ./dist:/var/lib/grafana/plugins/runreveal-runreveal-datasource
- ./provisioning:/etc/grafana/provisioning
- ./testing-dashboards:/var/lib/grafana/dashboards
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "run-reveal",
"version": "0.3.2",
"version": "0.3.3",
"description": "A grafana data source plugin that allows you to access you RunReveal logs and write queries for keeping track of specific metrics",
"scripts": {
"build": "webpack -c ./.config/webpack/webpack.config.ts --env production",
Expand Down
10 changes: 10 additions & 0 deletions provisioning/dashboards/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: 1

providers:
- name: Default # A uniquely identifiable name for the provider
type: file
options:
path:
/var/lib/grafana/dashboards
# Default path for Windows: C:/Program Files/GrafanaLabs/grafana/public/dashboards
# Default path for Linux is: /var/lib/grafana/dashboards
17 changes: 17 additions & 0 deletions provisioning/datasources/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: 1
deleteDatasources:
- name: RunReveal
orgId: 1
datasources:
- orgId: 1
name: RunReveal
uid: 1
type: runreveal-runreveal-datasource
access: proxy
basicAuth: false
withCredentials: false
isDefault: true
jsonData:
workspaceId: ${RRDS_WORKSPACE_ID}
secureJsonData:
sessionToken: ${RRDS_SESSION_TOKEN}
38 changes: 29 additions & 9 deletions src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,37 @@ locally, please checkout the [Plugin installation docs](https://grafana.com/docs

## Configuration

In order to use this data source you must have an account with *[RunReveal](https://runreveal.com)* that has a valid workspace.
To setup an account and get authenticated follow the [getting started](https://docs.runreveal.com/getting-started/guides/quickstart) guide in the docs.

Once you have created your *RunReveal* account and installed the plugin you can configure the data source. You will need your session token and the workspace id of the workspace that you want to run queries against. To acquire this info you can use the *RunReveal* cli and run the following command:

```bash
runreveal config show --grafana
In order to use this data source you must have an account with *[RunReveal](https://runreveal.com)* that has a valid workspace. Navigate to create an account and get started.

Once you have created your *RunReveal* account and installed the plugin you can configure the data source. You will need an api token and the workspace ID of the workspace that you want to run queries against. To acquire this info navigate to your RunReveal [settings page](https://runreveal.com/dash/settings).

### Provisioning

If you are using Grafana's new provsioning files to configure the data source, the api key must be base64 encoded (if not already done so) in the format `:<key>` where key is preceded by a colon.

Use the following example to set your provisioning file.
To configure the data source, use the environment variables `RRDS_WORKSPACE_ID` and `RRDS_SESSION_TOKEN` to set your workspace ID and the base64 encoded api key respectively.

```yml
apiVersion: 1
deleteDatasources:
- name: RunReveal
orgId: 1
datasources:
- orgId: 1
name: RunReveal
uid: 1
type: runreveal-runreveal-datasource
access: proxy
basicAuth: false
withCredentials: false
isDefault: true
jsonData:
workspaceId: ${RRDS_WORKSPACE_ID}
secureJsonData:
sessionToken: ${RRDS_SESSION_TOKEN}
```

Use the printed values to fill in the configuration fields for the data source.

## Quick Start

The plugin includes a built in dashboard that can be imported to your Grafana environment.
Expand Down
145 changes: 145 additions & 0 deletions testing-dashboards/runreveal-provision-dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"description": "A dashboard to get you setup with the RunReveal Grafana Plugin.",
"editable": true,
"fiscalYearStartMonth": 0,
"gnetId": 19069,
"graphTooltip": 1,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "runreveal-runreveal-datasource",
"uid": "1"
},
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": []
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 1,
"options": {
"displayLabels": [],
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true,
"values": [
"percent"
]
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"targets": [
{
"datasource": {
"type": "runreveal-runreveal-datasource",
"uid": "1"
},
"rawQuery": "select sourceType, count(*) log_count from runreveal_logs\nwhere eventTime between $__fromTime and $__toTime\ngroup by sourceType",
"refId": "A"
}
],
"title": "Log Count by Source",
"transformations": [
{
"id": "partitionByValues",
"options": {
"fields": [
"sourceType"
],
"keepFields": false,
"naming": {
"asLabels": true
}
}
}
],
"type": "piechart"
}
],
"refresh": "10s",
"schemaVersion": 39,
"tags": [],
"templating": {
"list": [
{
"current": {
"selected": true,
"text": [
"RunReveal"
],
"value": [
"1"
]
},
"hide": 0,
"includeAll": true,
"label": "Data Source",
"multi": true,
"name": "runreveal_source",
"options": [],
"query": "runreveal-runreveal-datasource",
"queryValue": "",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
}
]
},
"time": {
"from": "now-6h",
"to": "now"
},
"timepicker": {},
"timezone": "utc",
"title": "RunReveal Default Dashboard",
"uid": "e6618ab9-a6f0-44c7-8320-82259df4bb0a",
"version": 1,
"weekStart": ""
}
Loading