Skip to content

Commit

Permalink
Merge pull request #29 from oracle/multidimensions
Browse files Browse the repository at this point in the history
dimension template variables with multi-select values
  • Loading branch information
yuliashmeleva authored Nov 25, 2019
2 parents 954aa50 + 49281ef commit 6608581
Show file tree
Hide file tree
Showing 16 changed files with 698 additions and 385 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Process",
"type": "go",
"request": "attach",
"mode": "local",
"processId": 10458
}
]
}
9 changes: 9 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,12 @@ Once you have the data source installed, configure your datasource with your ten

We also have documentation for how to use the newly installed and configured plugin in our [Using Grafana with Oracle Cloud Infrastructure Data Source](https://github.com/oracle/oci-grafana-plugin/blob/master/docs/using.md) walkthrough.

## Development

### Debugging

If you want to debug golang backend plugin code, follow the steps below:
* Install [gops](https://github.com/google/gops) to list running go processes on your machine
* Run `gops` and find processId for `oci-plugin_darwin_amd64` process
* Copy this processId to the `.vscode/launch.json`
* In your VSCode from 'Debug' menu call 'Start Debugging'
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ fi
echo "building go binary"
GOOS=$GOOS go build -o ./dist/oci-plugin$POST

# For debugger
# GOOS=$GOOS go build -o ./dist/oci-plugin$POST -gcflags="all=-N -l"

# GOOS=linux go build -o ./dist/oci-plugin_linux_amd64
# GOOS=windows GOARCH=amd64 go build -o ./dist/oci-plugin_windows_amd64.exe
# tar cvf plugin.tar ./dist
Expand Down
6 changes: 3 additions & 3 deletions datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (o *OCIDatasource) compartmentsResponse(ctx context.Context, tsdbReq *datas
return &datasource.DatasourceResponse{
Results: []*datasource.QueryResult{
&datasource.QueryResult{
RefId: "compartment",
RefId: "compartments",
Tables: []*datasource.Table{&table},
},
},
Expand Down Expand Up @@ -449,7 +449,7 @@ func (o *OCIDatasource) queryResponse(ctx context.Context, tsdbReq *datasource.D
dimensionKeys[i] = key
i++
}

// if there isn't a human readable name fallback to resourceId
if t.Name == *(item).Name {
var preDisplayName string = ""
Expand All @@ -461,7 +461,7 @@ func (o *OCIDatasource) queryResponse(ctx context.Context, tsdbReq *datasource.D
preDisplayName = preDisplayName + ", " + item.Dimensions[dimensionKey]
}
}

t.Name = fmt.Sprintf("%s, {%s}", t.Name, preDisplayName)
}

Expand Down
2 changes: 1 addition & 1 deletion docs/linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ grafana-cli plugins install oci-datasource
The plugin will be installed into your Grafana plugins directory, which by default is located at /var/lib/grafana/plugins. [Here is more information on the CLI tool](http://docs.grafana.org/plugins/installation/).

### Manually installation
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: `cd /usr/local/var/lib/grafana/plugins`. Download the OCI Grafana Plugin: wget `https://github.com/oracle/oci-grafana-plugin/releases/download/V1.0.4/plugin.tar`. Create a directory and install the plugin: `mkdir oci && tar -C oci -xvf plugin.tar` and then remove the tarball: `rm plugin.tar`.
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: `cd /usr/local/var/lib/grafana/plugins`. Download the OCI Grafana Plugin: wget `https://github.com/oracle/oci-grafana-plugin/releases/download/V1.0.5/plugin.tar`. Create a directory and install the plugin: `mkdir oci && tar -C oci -xvf plugin.tar` and then remove the tarball: `rm plugin.tar`.

To start the Grafana server, run: `sudo systemctl start grafana-server`.

Expand Down
2 changes: 1 addition & 1 deletion docs/linuxoci.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ grafana-cli plugins install oci-datasource
The plugin will be installed into your Grafana plugins directory, which by default is located at /var/lib/grafana/plugins. [Here is more information on the CLI tool](http://docs.grafana.org/plugins/installation/).

### Manually installation
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: `cd /usr/local/var/lib/grafana/plugins`. Download the OCI Grafana Plugin: wget `https://github.com/oracle/oci-grafana-plugin/releases/download/V1.0.4/plugin.tar`. Create a directory and install the plugin: `mkdir oci && tar -C oci -xvf plugin.tar` and then remove the tarball: `rm plugin.tar`.
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: `cd /usr/local/var/lib/grafana/plugins`. Download the OCI Grafana Plugin: wget `https://github.com/oracle/oci-grafana-plugin/releases/download/V1.0.5/plugin.tar`. Create a directory and install the plugin: `mkdir oci && tar -C oci -xvf plugin.tar` and then remove the tarball: `rm plugin.tar`.

To start the Grafana server, run: `sudo systemctl start grafana-server`.

Expand Down
2 changes: 1 addition & 1 deletion docs/macos.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ grafana-cli plugins install oci-datasource
The plugin will be installed into your Grafana plugins directory, which by default is located at /var/lib/grafana/plugins. [Here is more information on the CLI tool](http://docs.grafana.org/plugins/installation/).

### Manually installation
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: `cd /usr/local/var/lib/grafana/plugins`. Download the OCI Grafana Plugin: wget `https://github.com/oracle/oci-grafana-plugin/releases/download/V1.0.4/plugin.tar`. Create a directory and install the plugin: `mkdir oci && tar -C oci -xvf plugin.tar` and then remove the tarball: `rm plugin.tar`
Alternatively, you can manually download the .tar file and unpack it into your /grafana/plugins directory. To do so, change to the Grafana plugins directory: `cd /usr/local/var/lib/grafana/plugins`. Download the OCI Grafana Plugin: wget `https://github.com/oracle/oci-grafana-plugin/releases/download/V1.0.5/plugin.tar`. Create a directory and install the plugin: `mkdir oci && tar -C oci -xvf plugin.tar` and then remove the tarball: `rm plugin.tar`

To start the Grafana server, run: `brew services start grafana`

Expand Down
16 changes: 9 additions & 7 deletions docs/using.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ The page will load a preview of valuables available for that variable. Scroll do

Repeat the process for the following OCI variables:

| Name | Query |
| ----------- | ------------------------------------------ |
| region | `regions()` |
| compartment | `compartments()` |
| namespace | `namespaces($region,$compartment)` |
| metric | `metrics($region,$compartment,$namespace)` |
| Name | Query |
| --------------- | ------------------------------------------------------------------------- |
| region | `regions()` |
| compartment | `compartments()` |
| namespace | `namespaces($region,$compartment)` |
| metric | `metrics($region,$compartment,$namespace)` |
| dimensionKey | `dimensions($region,$compartment,$namespace,$metric)` |
| dimensionValue | `dimensionOptions($region,$compartment,$namespace,$metric,$dimensionKey)` |

The final list of variables should look like this:

Expand All @@ -65,7 +67,7 @@ Choose the save icon to save your dashboard.

### Dimensions

Dimensions can be used to add specificity to your graphs. To use dimensions create a new graph or navigate to an existing one and click the **Metrics** tab. After selecting your variables click the **+** next to **Dimensions** and select one of the tag filters from the list. For example, select `availabilityDomain` from the list. Next, click **select tag value** and choose from the newly populated list of tag values. If you chose `availabilityDomain` as your tag filter, you should see tag values corresponding to the availability domains in which you currently have services provisioned, for example `US-ASHBURN-AD-1`.
Dimensions can be used to add specificity to your graphs. To use dimensions create a new graph or navigate to an existing one and click the **Metrics** tab. After selecting your variables click the **+** next to **Dimensions** and select one of the tag filters from the list. For example, select `availabilityDomain` from the list. Next, click **select value** and choose from the newly populated list of dimension values. If you chose `availabilityDomain` as your tag filter, you should see dimension values corresponding to the availability domains in which you currently have services provisioned, for example `US-ASHBURN-AD-1`.



Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "oci-grafana-plugin",
"private": true,
"version": "1.0.3",
"version": "1.0.5",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{"name": "GitHub", "url": "https://github.com/oracle/oci-grafana-plugin"},
{"name": "MIT License", "url": "https://github.com/oracle/oci-grafana-plugin"}
],
"version": "1.0.3",
"version": "1.0.5",
"updated": "2019-09-24"
},

Expand Down
8 changes: 8 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,11 @@ export const namespaces = ['oci_computeagent', 'oci_blockstore', 'oci_lbaas', 'o
export const aggregations = ['count()', 'max()', 'mean()', 'min()', 'rate()', 'sum()', 'percentile(.90)', 'percentile(.95)', 'percentile(.99)']
export const windows = ['1m', '5m', '1h']
export const environments = ['local', 'OCI Instance']


export const compartmentsQueryRegex = /^compartments\(\)/;
export const regionsQueryRegex = /^regions\(\)/;
export const namespacesQueryRegex = /namespaces\((\$?\w+)(,\s*\$\w+)*\)/;
export const metricsQueryRegex = /metrics\((\s*\$?\w+)(\s*,\s*\$\w+)(\s*,\s*\$\w+\s*)*\)/;
export const dimensionKeysQueryRegex = /dimensions\((\s*\$?\w+)(\s*,\s*\$\w+)(\s*,\s*\$\w+)(\s*,\s*\$\w+\s*)*\)/;
export const dimensionValuesQueryRegex = /dimensionOptions\((\s*\$?\w+)(\s*,\s*\$\w+)(\s*,\s*\$\w+)(\s*,\s*\$\w+)(\s*,\s*\$\w+\s*)*\)/;
Loading

0 comments on commit 6608581

Please sign in to comment.