From 341c124f4625e7b8b1b7cded19b6703a6c4e8cd8 Mon Sep 17 00:00:00 2001 From: Michael Harpe Date: Wed, 24 Apr 2024 10:05:38 -0400 Subject: [PATCH] Update dev with provisioning configs. --- CHANGELOG.md | 4 + README.md | 22 ++- docker-compose.yaml | 4 + package.json | 2 +- provisioning/dashboards/default.yml | 10 ++ provisioning/datasources/default.yml | 17 ++ src/README.md | 38 +++-- .../runreveal-provision-dashboard.json | 145 ++++++++++++++++++ 8 files changed, 231 insertions(+), 11 deletions(-) create mode 100644 provisioning/dashboards/default.yml create mode 100644 provisioning/datasources/default.yml create mode 100644 testing-dashboards/runreveal-provision-dashboard.json diff --git a/CHANGELOG.md b/CHANGELOG.md index ad91bbc..574bee1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 8b167ae..e0068cb 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 `:` where key is preceded by a colon. + +### Running the Provisioning File + +Run the following commands replacing `` and `` with their respective values. + +```bash +export RRDS_WORKSPACE_ID= +export RRDS_SESSION_TOKEN= +docker-compose up +``` + +This will set the environment variables needed to correctly spin up the docker instance and auto provision the datasource. \ No newline at end of file diff --git a/docker-compose.yaml b/docker-compose.yaml index 6775921..5e6ea4c 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -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 diff --git a/package.json b/package.json index e3e8478..6f1806a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/provisioning/dashboards/default.yml b/provisioning/dashboards/default.yml new file mode 100644 index 0000000..a5252e5 --- /dev/null +++ b/provisioning/dashboards/default.yml @@ -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 \ No newline at end of file diff --git a/provisioning/datasources/default.yml b/provisioning/datasources/default.yml new file mode 100644 index 0000000..ac1a856 --- /dev/null +++ b/provisioning/datasources/default.yml @@ -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} \ No newline at end of file diff --git a/src/README.md b/src/README.md index 0e7b756..5eb92a5 100644 --- a/src/README.md +++ b/src/README.md @@ -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 `:` 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. diff --git a/testing-dashboards/runreveal-provision-dashboard.json b/testing-dashboards/runreveal-provision-dashboard.json new file mode 100644 index 0000000..b0ff577 --- /dev/null +++ b/testing-dashboards/runreveal-provision-dashboard.json @@ -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": "" +} \ No newline at end of file