Skip to content

Commit

Permalink
release v2.0.0
Browse files Browse the repository at this point in the history
* feat: v1 datapoints query

* chore: add grafana to x-cdp-sdk header

* fix: upgraded assets dropdown

* feat: upgrade timeseries dropdown

* feat: upgraded variables request

* feat: upgraded events query

* refactor: minor

* refactor: move request calls to common function

* fix: fix label for timeseries

* refactor: getDataQueryRequestItems

* refactor: messy function in parser

* feat: synthetics (not working, playground)

* refactor: make the code cleaner

* feat: auto-pagination for 10k timeseries (+some fixes)

* fix: fetching timeseries by id (#92)

* fix: template variables and annotations for API v1 (#94)

* fix: rewrite hints for template variables and annotations (#95)

* fix: parse annotation query with variable in it

* feat: playground synthetics from scratch (#97)

* docs(hint): fix sts function syntax

* fix: array server filters

* feat: support grafana advanced variables syntax

* fix: expand description with docs links (#100)

* feat: error handling for STS, annotation and variables (#99)

* docs: missing comma in template variable hint

Co-Authored-By: Maciej Mrowiec <maciej.mrowiec@cognite.com>

* docs(readme): update sts syntax

* chore: 1.1.0 version bump

* Fix/multiple (#103)

* fix: allow boolean/number/null as != filter

* fix: refresh on input field change

* fix: parse escape char (#104)

* fix: explorer page infinite reloading (#107)

* fix: caching requests (#106)

* feat: add unary minus parser support (#108)

* chore: bump version 2.0.0 (#110)

* chore: rename image to CDF

* Update README.md

* docs: dashboard development (#109)

* fix: per datapoint error handling (#112)

* fix: variables list appearance in grafana v7.0

* fix: default values of aggregates in STS (#105)

* fix: point sts to v1 (#114)

* fix: vulnerabilities, upgrade typescript 3.8, jest 26

* fix: add default granularity for sts query with only id filter

* Add release notes for Grafana 2.0.0

* Fix links in release notes.

* Centralise all usage documentation do documentation portal.

Direct users to support portal instead github issues.

* Readme cleanups.

Keep it simple, all installation, upgrade, setup and user documentation are part of our main dos portal.

* docs: links to docs portal

Co-authored-by: Cognite CICD <cognite-cicd@users.noreply.github.com>
Co-authored-by: Roman Vizniak <mr.traser@gmail.com>
Co-authored-by: Maciej Mrowiec <maciej.mrowiec@cognite.com>
  • Loading branch information
4 people authored Jun 29, 2020
1 parent bdeb6ab commit bf6e039
Show file tree
Hide file tree
Showing 61 changed files with 10,256 additions and 9,707 deletions.
105 changes: 88 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,94 @@
#### Changelog
# Releases

##### v1.0.1
This article documents the ongoing improvements we're making to the **Cognite Data Source for Grafana**.

- Renaming Cognite Data Platform to Cognite Data Fusion
- Allowing for templating variables to be used anywhere in custom queries
- This is useful for `Text box` variables, for example: `timeseries{}$Variable` will allow for a user to set `$Variable` to ` * 1000` or `[avg,1d]`
- Allowing for the base url to be modified when adding a new datasource
## 2.0.0 - June 29, 2020

##### v1.0.0
### General improvements

- Fixing templating so that repeated panels/rows work properly
- Changing checkboxes to grafana checkboxes and adding 'Select All' option
- Fixing data source configuration to verify the project name
- Breaking Changes: `function= ` inside of `timeseries{ ... }` no longer works for custom queries
- Instead, functions are now applied outside of `timeseries{}[]` such as:
- `(timeseries{description=~".*TEMP.*"}[avg] - 32) * 5/9`
- `sum(timeseries{name=~".*VALUE"}[count,1d])`
- `max(timeseries{metadata.on="True"}[count,5m]) - min(timeseries{metadata.on="True"}[count,5m])`
- A new query language inspired by PromQL and compatible with synthetic time series in CDF. [Learn more](https://docs.cognite.com/cdf/dashboards/guides/grafana/timeseries.html#custom-queries).
- Support for all filtering capabilities available in [CDF API v1](https://docs.cognite.com/api/v1/) for the respective resource types (assets, events, times series).
- Any future **filtering** capabilities added to CDF API v1 will be **automatically supported** by the data source (filters are passed directly to CDF).
- Query expressions resulting in errors now **displays error messages** in the UI.
- Regular expressions filtering can be used as part of the **Query** expression. The **Filter** field has been removed.
- Supports CDF [API v1](https://docs.cognite.com/dev/API_versioning.html#current-api-versions), with no dependency to older API versions.
- [New documentation section](https://docs.cognite.com/cdf/dashboards/guides/grafana/getting_started.html) for the connector, covering installation and administration, upgrades, feature documentation and getting started information.
- Compatibility with Grafana 7.0. Learn more about the new capabilities [here](https://grafana.com/blog/2020/05/18/grafana-v7.0-released-new-plugin-architecture-visualizations-transformations-native-trace-support-and-more/?isource=hp).

##### v0.0.1 (beta)
### Time series and custom queries

- You can now access time series that don't have the `legacyName` attribute populated with the data source.
- Setting `Root Asset` in the **Custom query** tab is no longer required. This filter has been removed from the UI and is now available as part of a custom query expression. For example: `ts{rootAssetIds=[12335453, 3455566]}`.
- Custom query aggregation requests are less likely to trigger rate limiting in CDF API.
- Functions:
- Support for **string time series** through the new `map` function allows you to convert string values to numeric values which can then be plotted by Grafana. For example: `map(ts{externalId='pump_29'}, ['OPEN', 'CLOSED'], [1, 0], -1)`.
- Use the `on_error` function to gain control over query calculations resolving with errors, such as division by 0. The function allows you to set a default value for individual data points that resolved with errors. Without the `on_error` function, the chart shows empty space in those places. Example: `on_error(1/ts{externalId='canBeZero'}, 0)`.
- Variable length functions: `max(x1, x2, ...)`, `min(...)`, `avg(...)`.
- The `power` function has been renamed to `pow`.
- These functions are no longer supported: `acos`, `asin`, `atan`, `ceil`, `celing`, `cot`, `degrees`, `floor`, `log`, `log2`, `log10`, `radians`, `sign`, `tan`, `atan2`, `mod`, `truncate`, `rand`, `crc32`, `conv`, `div`.
- These aggregates are no longer supported by custom queries: `max`, `min`, `count`, `sum`, `continuousVariance`, `discreteVariance`, `totalVariation`.
- Short names for aggregation functions are no longer supported. Use full names instead: `average`, `interpolation`, `stepInterpolation`.
- The `timeseries{options}` function has been renamed to `ts{options}`.
- Filtering:
- New options:`isString=false`, `externalId='my_id'`, `id=123`, `externalIdPrefix='my_'`
- Relate to asset tree with: `assetSubtreeIds=[{id=754173880412890},{externalId="23-TE-96148"}]`, `assetIds=[123, 234]`, `assetExternalIds=['pump_1', 'pump_2']`, `rootAssetIds=[123, 234]`
- New range filters for create and updated time: `createdTime={min=0, max= 1593018651}`, `lastUpdatedTime={min=1493018651, max= 1593018651}`
- Select time series based on dataSet membership: `dataSetIds=[{externalId='Prediction Model A'},{id=123}]`
- `path` is no longer supported
- See the full list of [supported filters](https://docs.cognite.com/api/v1/#operation/listTimeSeries) for the `ts{}` expression.

### Annotations

- New filters: `assetExternalIds`, `rootAssetIds`, `dataSetIds`, `externalIdPrefix`, `source`.
- Find active events in range with the `activeAtTime` filter. If `endTime` is null, the event is active from `startTime` onwards. The `activeAtTime` filter will match all events that are active at some point from `min` to `max`. Example: `activeAtTime={min=1591018651, max= 1593018651}`.
- `description` supports only regular expression operators `=~`, `!~`, and `!=`.
- `minStartTime`/`maxStartTime` has been replaced by the `startTime={min=0, max= 1593018651}` filter.
- `minEndTime`/`maxEndTime` has been replaced by the `endTime={min=0, max= 1593018651}` filter, enabling you to also filter for events without the `endTime` set: `endTime={isNull=true}`.
- `minCreatedTime`/`maxCreatedTime` has been replaced by the `createdTime={min=0, max= 1593018651}` filter.
- `minLastUpdatedTime`/`maxLastUpdatedTime` has been replaced by the `lastUpdatedTime={min=0, max= 1593018651}` filter.
- `assetSubtrees` has been replaced by the `assetSubtreeIds=[{id=754173880412890},{externalId="23-TE-96148"}]` filter which introduces support for `Id`/`ExternalId` input.
- These filters are no longer supported: `sort`, `dir`, `limit`, `offset`, `sourceId`.
- See the full list of [supported filters](https://docs.cognite.com/api/v1/#operation/advancedListEvents) for the `events{}` expression.

### Templating

- New filters: `parentIds`, `parentExternalIds`, `rootIds`, `dataSetIds`, `externalIdPrefix`, `root`.
- The `description` field supports only regular expression operators `=~`, `!~`, and `!=`.
- Select assets based on **label**: `labels={contains={externalId="pump"}}`, `labels={containsAny=[{externalId="pump_type_A"},{externalId="pump_type_B"}]}`, `labels={containsAll=[{externalId="pump"},{externalId="rust_detected"}]}`
- `assetSubtrees` replaced by the `assetSubtreeIds=[{id=754173880412890},{externalId="23-TE-96148"}]` filter which introduces support for `Id`/`ExternalId` inputs.
- `minCreatedTime`/`maxCreatedTime` has been replaced by the `createdTime={min=0, max= 1593018651}` filter.
- `minLastUpdatedTime`/`maxLastUpdatedTime` has been replaced by the `lastUpdatedTime={min=1592222651, max= 1593018651}` filters.
- These options are no longer supported: `query`, `sort`, `dir`, `offset`, `boostname`, `path`, `depth`, `sourceId`.
- See the full list of [supported filters](https://docs.cognite.com/api/v1/#operation/listAssets) for the `assets{}` expression.

### Other

The **Cognite Data Source for Grafana 2.0.0** is compatible with CDF [API v1](https://docs.cognite.com/dev/API_versioning.html#current-api-versions).

Cognite Data Source for **Grafana 2.0.0 is not backward compatible** with dashboards created using older versions of the connector.
Follow the steps in the [**upgrade guide**](https://docs.cognite.com/cdf/dashboards/guides/grafana/upgrade.html) to upgrade your existing installation.

## 1.0.1 - May 27, 2019

- Rename Cognite Data Platform to Cognite Data Fusion.
- Allowing for templating variables to be used anywhere in custom queries.
- Allowing for the base url to be modified when adding a new data source.

### Other

The **Cognite Data Source for Grafana 1.0.1** is compatible with CDF [API 0.5](https://docs.cognite.com/dev/API_versioning.html#current-api-versions).

## 1.0.0 - March 26, 2019

- Fixing templating so that repeated panels/rows work properly.
- Changing checkboxes to Grafana checkboxes and adding **Select All** option.
- Fixing data source configuration to verify the project name.
- **Breaking change**: `function=` inside of `timeseries{ ... }` no longer works for custom queries. Instead, functions are now applied outside of `timeseries{}[]` such as:
- `(timeseries{description=~".*TEMP.*"}[avg] - 32) * 5/9`
- `sum(timeseries{name=~".*VALUE"}[count,1d])`
- `max(timeseries{metadata.on="True"}[count,5m]) - min(timeseries{metadata.on="True"}[count,5m])`

### Other

The **Cognite Data Source for Grafana 1.0.0** is compatible with CDF [API 0.5](https://docs.cognite.com/dev/API_versioning.html#current-api-versions)

- First version.
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@Library('jenkins-helpers@v0.1.19') _

def label = "cognite-grafana-datasource-${UUID.randomUUID().toString().substring(0, 5)}"
def imageName = "cognite/grafana-cdp"
def devImageName = "cognite/grafana-cdp-dev"
def imageName = "cognite/grafana-cdf"
def devImageName = "cognite/grafana-cdf-dev"

podTemplate(
label: label,
Expand Down Expand Up @@ -53,7 +53,7 @@ podTemplate(
}

stage('Test') {
sh('yarn test')
sh('yarn test --maxWorkers=1')
}
}

Expand Down
117 changes: 16 additions & 101 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,26 @@
- Add event annotations to graphs
- Apply custom functions to timeseries

### Quick Start
![Select Timeseries](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/docs/dashboard-development/images/readme/image2.png)

For a quick start on how to start using the Cognite Data Fusion plugin with Grafana, check out the videos we have published!

[Part 1](https://www.youtube.com/watch?v=wdrJuE1KXUM): Introduction to setting up Grafana with the Cognite Data Source plugin and how to display timeseries.
## Installation

[Part 2](https://www.youtube.com/watch?v=JvpPzAT5wDQ): More advanced guide on custom querying, templating, and using other panels.
The easiest way to install this plugin is to go to [https://grafana.com/plugins/cognitedata-datasource/installation](https://grafana.com/plugins/cognitedata-datasource/installation), and follow the installation instructions there.

## Documentation

## Installation
To learn more about the connector please visit our [documentation](https://docs.cognite.com/cdf/dashboards/guides/grafana/getting_started.html)

#### Via Grafana Plugin Store
## Feedback

The easiest way to install this plugin is to go to [https://grafana.com/plugins/cognitedata-datasource/installation](https://grafana.com/plugins/cognitedata-datasource/installation), and follow the installation instructions there.
If you find any bugs, or have any suggestions, please [visit support portal](https://support.cognite.com/).

#### Docker
---
## Docker

The official image is hosted on Docker Hub as
[cognite/grafana-cdp](https://hub.docker.com/r/cognite/grafana-cdp/)
[cognite/grafana-cdf](https://hub.docker.com/r/cognite/grafana-cdf/)

To run it, first create a Docker volume to store your dashboards
and settings.
Expand All @@ -38,104 +40,17 @@ and settings.

Run the Docker image using this volume:

`docker run -d --name grafana -p 3000:3000 -v grafana-storage:/var/lib/grafana cognite/grafana-cdp`
`docker run -d --name grafana -p 3000:3000 -v grafana-storage:/var/lib/grafana cognite/grafana-cdf`

Now you can access Grafana at http://localhost:3000

Standard username/password for logging in is admin/admin. See
[http://docs.grafana.org/installation/docker/](http://docs.grafana.org/installation/docker/) for configuration details.

For more help with Docker, see the [step-by-step guide](./instructions.md).

## Adding the Data Source

To set up CDF, do the following:

- Go to "Configuration" click Data Sources, then Add data source, and choose Cognite Data Fusion.
- Give the data source a name, provide the name of the project and your API key.
- Hit "Save & Test"

![Configuring Data Source](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img1.png)

You're now ready to start using the datasource!

To make a chart, click on Dashboard, and choose Graph under "Add". Click on "Panel Title" and choose Edit.
Under "Metric", choose your data source

## Usage

There are three ways to get timeseries into Grafana:

##### Select Timeseries

If you only want to see the data from one specific timeseries.

- Simply start typing the name of the desired timeseries and then select it from the dropdown.
- Choose your desired aggregation, and add a granularity if desired (otherwise one will be selected for you based on the time interval displayed).
- You can also set a custom label and use the format `{{property}}` to pull data from the timeseries. E.g. `{{name}} - {{description}}`

![Select Timeseries](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img2.png)

##### Select Timeseries from Asset

If you want to get a few timeseries associated with an asset

- First choose an asset to pull timeseries from - this asset will act as a root asset. Choose 'Include Subassets' to also get timeseries from all subassets.
- Select timeseries from the list
- Set your desired aggregation, as well as a granularity and custom label if desired.

![Select Timeseries from Asset](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img3.png)
For more help with Docker, see the [step-by-step guide](https://github.com/cognitedata/cognite-grafana-datasource/blob/master/instructions.md).

##### Custom Query

If you want more fine-grained control.

- First select an asset (with/without subassets) to pull timeseries from, or use a template variable with `$Variable` or `[[Variable]]`.
- Then filter on these timeseries. Click on the help icon for more details about the syntax.
- If you want to apply custom functions to the timeseries (e.g. for unit conversions), simply add your functions around `timeseries{}[]` -> For example: `(timeseries{name=~"Test.*"}[avg] + 10) / 5`
- Click on the info icon next to the text box to see more examples

![Custom Query](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img4.png)

## Templating / Variables

In order to perform templating, we enable the use of variables via `$Variable` or `[[Variable]]`.

- To add variables, go to your dashboard's settings, and then select "Variables" from the right side.
- Make sure the "Type" is set to "Query", and then set your Cognite Data Source as the Data Source.
- You can then specify the query to pull assets from CDF, and also filter on these assets.

![Variable Query](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img7.png)

![Variable as root asset](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img8.png)

## Annotations / Events

Events from CDF can also be shown in Grafana via annotations.

- To add annotations, go to your dashboard's settings, and then select "Annotations" from the right side.
- Choose your Cognite Data Source as the Data Source.
- You can then specify the query to pull events from CDF, and also filter on these events.

![Annotation Query](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img5.png)

![Annotation Labels](https://raw.githubusercontent.com/cognitedata/cognite-grafana-datasource/master/images/img6.png)

### Feedback

If you find any bugs, or have any suggestions, please [create a new issue](https://github.com/cognitedata/cognite-grafana-datasource/issues/new).

&nbsp;

&nbsp;

&nbsp;

&nbsp;

---

#### Developing
## Developing

The easiest way to work on this datasource is to create a symbolic link
in `data/plugins` that points to this directory.
Expand All @@ -145,8 +60,8 @@ cd /path/to/grafana/data/plugins
ln -s /path/to/cognite-grafana-datasource cognitedata-datasource
```

#### Building
## Building

`yarn` followed by `yarn build` should work on systems with a shell.

For debugging and development, use `yarn dev`, and for testing use `yarn test`.
For debugging and development, use `yarn dev:watch`, and for testing use `yarn test`.
Binary file added images/readme/image1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/readme/image8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ After download, log in to launch Docker.

3. Run Docker using the volume just created

docker run -d --name grafana -p 3000:3000 -v grafana-storage:/var/lib/grafana cognite/grafana-cdp
docker run -d --name grafana -p 3000:3000 -v grafana-storage:/var/lib/grafana cognite/grafana-cdf

The download from cognite/grafana-cdp will start immediately.
The download from cognite/grafana-cdf will start immediately.

![Download Cognite plug-in](./images/image5.png)

Expand Down
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,9 @@ module.exports = {
},
testEnvironment: "node",
testRegex: "(/spec/.*|(\\.|/)(test|spec))\\.tsx?$",
moduleFileExtensions: ["d.ts", "ts", "tsx", "js", "jsx", "json", "node"]
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
moduleNameMapper: {
"grafana/app/core/core": "<rootDir>/src/__mocks__/grafana/app/core/core.ts"
},
collectCoverageFrom: ["src/**/{!(grammar),}.ts"]
};
Loading

0 comments on commit bf6e039

Please sign in to comment.