Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pmenglund committed Jan 31, 2024
1 parent b65a1a3 commit 95491c1
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 33 deletions.
69 changes: 41 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ The Rockset plugin lets you write queries against your Rockset collections and v

Detailed setup instructions can be found in the [Rockset documentation](https://docs.rockset.com/documentation/docs/grafana).

## Installation

For a detailed guide on how to install and configure the plugin,
see the [Grafana plugin installation documentation](https://grafana.com/docs/grafana/latest/administration/plugin-management/).

The quckstart is to use the `grafana cli` to install the plugin from the Rockset public S3 bucket:
```
grafana cli \
--pluginUrl https://rockset-public.s3-us-west-2.amazonaws.com/rockset-backend-datasource-0.3.0.zip \
plugins install rockset-backend-datasource
```

⚠️ This requires setting the `GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS` environment variable to `rockset-backend-datasource`.

## Query Types

Expand Down Expand Up @@ -39,6 +52,17 @@ ORDER BY

![events](src/img/events.png)

Instead of a fixed interval, it is possible to use `:interval` which is SQL query parameter that the plugin injects into the request,
and is based on the Grafana variable `$__interval`, which is set to the time range divided by the max number of datapoints.

![events](src/img/query-options.png)

The `:interval` is in milliseconds, so the bucket should use `MILLISECONDS()`, e.g.
```SQL
SELECT
TIME_BUCKET(MILLISECONDS(:interval), _events._event_time) AS _event_time,
```

### Labeling Data

You can use one column of the result to label the data, e.g. in the below query the type is the label column
Expand Down Expand Up @@ -137,34 +161,9 @@ You can include an `ALL` option using the SQL wildcard character `%`

![all option](src/img/all-option.png)

# Installation

Install the plugin using the grafana-cli. Note that the plugin require Grafana 10!

```bash
grafana-cli \
--pluginUrl https://rockset-public.s3-us-west-2.amazonaws.com/rockset-backend-datasource-0.3.0.zip \
plugins install rockset-backend-datasource
```

## Test-driving the plugin

```bash
docker run -d \
-p 3000:3000 \
-e "GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=rockset-backend-datasource" \
--name=grafana \
grafana/grafana:10.0.3
docker exec grafana \
grafana cli \
--pluginUrl https://rockset-public.s3-us-west-2.amazonaws.com/rockset-backend-datasource-0.3.0.zip \
plugins install rockset-backend-datasource
docker restart grafana
```

## Plugin Development
# Plugin Development

### Backend
## Backend

1. Update [Grafana plugin SDK for Go](https://grafana.com/developers/plugin-tools/introduction/grafana-plugin-sdk-for-go) dependency to the latest minor version:

Expand All @@ -185,7 +184,7 @@ docker restart grafana
mage -l
```

### Frontend
## Frontend

1. Install dependencies

Expand Down Expand Up @@ -240,3 +239,17 @@ docker restart grafana

npm run lint:fix
```
## Test-driving the plugin

```bash
docker run -d \
-p 3000:3000 \
-e "GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=rockset-backend-datasource" \
--name=grafana \
grafana/grafana:10.0.3
docker exec grafana \
grafana cli \
--pluginUrl https://rockset-public.s3-us-west-2.amazonaws.com/rockset-backend-datasource-0.3.0.zip \
plugins install rockset-backend-datasource
docker restart grafana
```
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:
context: ./.config
args:
grafana_image: ${GRAFANA_IMAGE:-grafana-enterprise}
grafana_version: ${GRAFANA_VERSION:-10.0.3}
grafana_version: ${GRAFANA_VERSION:-10.3.1}
ports:
- 3000:3000/tcp
volumes:
Expand Down
9 changes: 5 additions & 4 deletions pkg/plugin/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"runtime/debug"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -270,10 +271,10 @@ func buildQueryOptions[T queryModel](qm T, from, to time.Time, vi string) []opti
"to", to,
"duration", to.Sub(from).String())

// if qm.GetIntervalMs() > 0 {
// opts = append(opts, "interval", qm.GetIntervalMs())
// options = append(options, option.WithParameter(":interval", "int", strconv.FormatUint(qm.GetIntervalMs(), 10)))
// }
if qm.GetIntervalMs() > 0 {
opts = append(opts, ":interval", qm.GetIntervalMs())
options = append(options, option.WithParameter("interval", "int", strconv.FormatUint(qm.GetIntervalMs(), 10)))
}

// set defaults and trim ":" from the start/stop
start := strings.TrimPrefix(qm.GetQueryParamStart(), ":")
Expand Down
Binary file added src/img/query-options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 95491c1

Please sign in to comment.