Skip to content
This repository was archived by the owner on Dec 11, 2022. It is now read-only.

Commit 756780e

Browse files
author
Tamir Klein
authored
Merge pull request #289 from doitintl/feature/lior/bqalert
Feature/lior/bqalert
2 parents 860cabe + 3d78da8 commit 756780e

40 files changed

+2205
-2702
lines changed
26.1 MB
Binary file not shown.

.circleci/config.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ jobs:
2929
name: build
3030
command: 'yarn run build:prod'
3131
- codecov/upload:
32-
3332
token: a1127a6b-ce13-4174-9d14-6dbfa7252a54
3433
file: coverage/*.json
3534
- store_artifacts:
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
11
---
22
name: 🐛 Bug Report
33
about: If something isn't working as expected 🤔.
4-
54
---
65

76
## Bug Report
87

98
## Expected Behavior
109

11-
1210
## Actual Behavior
1311

14-
1512
## Steps to Reproduce the Problem
1613

17-
1.
18-
1.
19-
1.
14+
1.
15+
1.
16+
1.
2017

2118
## Specifications
2219

23-
- Version:
24-
- Platform:
25-
- Grafana Version:
20+
- Version:
21+
- Platform:
22+
- Grafana Version:

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
name: 🚀 Feature Request
33
about: I have a suggestion (and may want to implement it 🙂)!
4-
54
---
65

76
## Feature Request

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99
**What this PR does / why we need it**:
1010

1111
**Which issue(s) this PR fixes**:
12+
1213
<!--
1314
*Automatically closes linked issue when PR is merged.
1415
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
1516
-->
17+
1618
Fixes #
1719

1820
**Special notes for your reviewer**:
1921

2022
**Release note**:
23+
2124
<!--
2225
If this is a user facing change and should be mentioned in release note add it below. If no, just write "NONE" below.
2326
-->
27+
2428
```release-note
2529
2630
```

.prettierrc.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
...require('./node_modules/@grafana/toolkit/src/config/prettier.plugin.config.json'),
3+
};

CODE_OF_CONDUCT.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
1414
Examples of behavior that contributes to creating a positive environment
1515
include:
1616

17-
* Using welcoming and inclusive language
18-
* Being respectful of differing viewpoints and experiences
19-
* Gracefully accepting constructive criticism
20-
* Focusing on what is best for the community
21-
* Showing empathy towards other community members
17+
- Using welcoming and inclusive language
18+
- Being respectful of differing viewpoints and experiences
19+
- Gracefully accepting constructive criticism
20+
- Focusing on what is best for the community
21+
- Showing empathy towards other community members
2222

2323
Examples of unacceptable behavior by participants include:
2424

25-
* The use of sexualized language or imagery and unwelcome sexual attention or
26-
advances
27-
* Trolling, insulting/derogatory comments, and personal or political attacks
28-
* Public or private harassment
29-
* Publishing others' private information, such as a physical or electronic
30-
address, without explicit permission
31-
* Other conduct which could reasonably be considered inappropriate in a
32-
professional setting
25+
- The use of sexualized language or imagery and unwelcome sexual attention or
26+
advances
27+
- Trolling, insulting/derogatory comments, and personal or political attacks
28+
- Public or private harassment
29+
- Publishing others' private information, such as a physical or electronic
30+
address, without explicit permission
31+
- Other conduct which could reasonably be considered inappropriate in a
32+
professional setting
3333

3434
## Our Responsibilities
3535

CONTRIBUTING.md

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
1-
21
# Contributing
32

43
Grafana uses GitHub to manage contributions.
54
Contributions take the form of pull requests that will be reviewed by the core team.
65

7-
* If you are a new contributor see: [Steps to Contribute](#steps-to-contribute)
8-
9-
* If you have a trivial fix or improvement, go ahead and create a pull request.
6+
- If you are a new contributor see: [Steps to Contribute](#steps-to-contribute)
107

11-
* If you plan to do something more involved, discuss your idea on the respective [issue](https://github.com/doitintl/bigquery-grafana/issues) or create a [new issue](https://github.com/doitintl/bigquery-grafana/issues/new/choose) if it does not exist. This will avoid unnecessary work and surely give you and us a good deal of inspiration.
8+
- If you have a trivial fix or improvement, go ahead and create a pull request.
129

10+
- If you plan to do something more involved, discuss your idea on the respective [issue](https://github.com/doitintl/bigquery-grafana/issues) or create a [new issue](https://github.com/doitintl/bigquery-grafana/issues/new/choose) if it does not exist. This will avoid unnecessary work and surely give you and us a good deal of inspiration.
1311

1412
## Steps to Contribute
1513

1614
Should you wish to work on a GitHub issue, check first if it is not already assigned to someone. If it is free, you claim it by commenting on the issue that you want to work on it. This is to prevent duplicated efforts from contributors on the same issue.
1715

1816
Please check the [`beginner friendly`](https://github.com/doitintl/bigquery-grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22beginner+friendly%22) and [`help wanted`](https://github.com/doitintl/bigquery-grafana/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) labels to find issues that are good for getting started. If you have questions about one of the issues, with or without the tag, please comment on them and one of the core team or the original poster will clarify it.
1917

20-
21-
2218
## Pull Request Checklist
2319

24-
* Branch from the master branch and, if needed, rebase to the current master branch before submitting your pull request. If it doesn't merge cleanly with master you may be asked to rebase your changes.
20+
- Branch from the master branch and, if needed, rebase to the current master branch before submitting your pull request. If it doesn't merge cleanly with master you may be asked to rebase your changes.
2521

26-
* If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment.
22+
- If your patch is not getting reviewed or you need a specific person to review it, you can @-reply a reviewer asking for a review in the pull request or a comment.
2723

28-
* Add tests relevant to the fixed bug or new feature.
24+
- Add tests relevant to the fixed bug or new feature.
2925

3026
### Pull requests with new features
27+
3128
Commits should be as small as possible, while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests).
3229

3330
Make sure to include `Closes #<issue number>` or `Fixes #<issue number>` in the pull request description.
3431

3532
### Pull requests with bug fixes
33+
3634
Please make all changes in one commit if possible. Include `Closes #<issue number>` in bottom of the commit message.
3735
A commit message for a bug fix should look something like this.
3836

@@ -48,4 +46,3 @@ Closes #12864
4846
```
4947

5048
If the pull request needs changes before its merged the new commits should be rebased into one commit before its merged.
51-

INSTALL.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Install bigquery-grafana
2+
23
There are multiple ways to install bigquery-grafana datasource plugin, please **choose one** below:
34

45
## From grafana.net
6+
57
Install from [grafana.net](https://grafana.net/plugins/doitintl-bigquery-datasource)
68

79
## Grafana-cli

README.md

Lines changed: 48 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
1-
21
[![GitHub stars](https://img.shields.io/github/stars/doitintl/bigquery-grafana.svg?style=svg)](https://github.com/doitintl/bigquery-grafana/stargazers)
32
![GitHub forks](https://img.shields.io/github/forks/doitintl/bigquery-grafana.svg?style=svg)
43
[![Circle CI](https://circleci.com/gh/doitintl/bigquery-grafana.svg?style=svg)](https://circleci.com/gh/doitintl/bigquery-grafana)
54
[![Code Climate](https://codeclimate.com/github/doitintl/bigquery-grafana/badges/gpa.svg)](https://codeclimate.com/github/doitintl/bigquery-grafana/coverage)
65
[![Issue Count](https://codeclimate.com/github/doitintl/bigquery-grafana/badges/issue_count.svg)](https://codeclimate.com/github/doitintl/bigquery-grafana)
76
[![CodeCpv](https://codecov.io/gh/doitintl/bigquery-grafana/branch/master/graph/badge.svg)](https://codecov.io/gh/doitintl/bigquery-grafana/)
87
[![Automated Release Notes by gren](https://img.shields.io/badge/%F0%9F%A4%96-release%20notes-00B2EE.svg)](https://github-tools.github.io/github-release-notes/)
8+
99
## Status: Production Ready
10+
1011
# BigQuery DataSource for Grafana
1112

1213
A BigQuery DataSource plugin provides support for [BigQuery](https://cloud.google.com/bigquery/) as a backend database.
1314

1415
### Quick Start
16+
1517
There are multiple ways to install bigquery-grafana. See [INSTALL](https://doitintl.github.io/bigquery-grafana/INSTALL) for more information.
1618

1719
### Features:
1820

19-
* Query setup
20-
* Raw SQL editor
21-
* Query builder
22-
* Macros support
23-
* Additional functions
24-
* Table view
25-
* Annotations
26-
* BQ queries in variables
27-
* Sharded tables (`tablename_YYYYMMDD`)
28-
* Partitioned Tables
29-
* Granular slot allocation (Running queries in a project with flat-rate pricing)
30-
31-
**Plugin Demo:**
21+
- Query setup
22+
- Raw SQL editor
23+
- Query builder
24+
- Macros support
25+
- Additional functions
26+
- Table view
27+
- Annotations
28+
- BQ queries in variables
29+
- Sharded tables (`tablename_YYYYMMDD`)
30+
- Partitioned Tables
31+
- Granular slot allocation (Running queries in a project with flat-rate pricing)
3232

33-
![plugin demo](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/grafana-bigquery-demo.gif)
33+
**Plugin Demo:**
3434

35+
![plugin demo](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/grafana-bigquery-demo.gif)
3536

3637
## Adding the DataSource to Grafana
3738

@@ -57,6 +58,7 @@ You can now set query priority "INTERACTIVE" or "BATCH" per datasouce
5758
### Example of Provisioning a File
5859

5960
You can manage DataSource via [provisioning system](https://grafana.com/docs/administration/provisioning/#datasources). See the example below of a configuration file.
61+
6062
```
6163
apiVersion: 1
6264
@@ -85,7 +87,7 @@ There are two ways to authenticate the BigQuery plugin - either by uploading a G
8587

8688
### Using a Google Service Account Key File
8789

88-
To authenticate with the BigQuery API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you can give the service account permissions in each project or create one datasource per GCP Project.
90+
To authenticate with the BigQuery API, you need to create a Google Cloud Platform (GCP) Service Account for the Project you want to show data for. A Grafana datasource integrates with one GCP Project. If you want to visualize data from multiple GCP Projects then you can give the service account permissions in each project or create one datasource per GCP Project.
8991

9092
#### Enable APIs
9193

@@ -98,22 +100,24 @@ Go to [BigQuery API](https://console.cloud.google.com/apis/library/bigquery.goog
98100
1. Navigate to the [APIs & Services Credentials page](https://console.cloud.google.com/apis/credentials).
99101
2. Click on `Create credentials` and choose `Service account key`.
100102

101-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/createserviceaccountbutton.png)
103+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/createserviceaccountbutton.png)
104+
102105
3. On the `Create service account key` page, choose key type `JSON`. Then in the `Service Account` dropdown, choose the `New service account` option:
103106

104-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/newserviceaccount.png)
107+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/newserviceaccount.png)
105108

106109
4. Some new fields will appear. Fill in a name for the service account in the `Service account name` field and then choose the `BigQuery Data Viewer` and `BigQuery Job User` roles from the `Role` dropdown:
107110

108-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/bq_service_account_choose_role.png)
111+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/bq_service_account_choose_role.png)
112+
109113
5. Click the `Create` button. A JSON key file will be created and downloaded to your computer. Store this file in a secure place as it allows access to your BigQuery data.
110114
6. Upload it to Grafana on the datasource Configuration page. You can either upload the file or paste in the contents of the file.
111115

112116
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/bq__grafana_upload_key.png)
113117

114118
7. The file contents will be encrypted and saved in the Grafana database. Don't forget to save after uploading the file!
115119

116-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/bq_grafana_key_uploaded.png)
120+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/bq_grafana_key_uploaded.png)
117121

118122
### Using GCE Default Service Account
119123

@@ -126,40 +130,49 @@ If Grafana is running on a Google Compute Engine (GCE) virtual machine, it is po
126130
Read more about creating and enabling service accounts for GCE VM instances [here](https://cloud.google.com/compute/docs/access/create-enable-service-accounts-for-instances).
127131

128132
### Using the Query Builder
133+
129134
The query builder provides a simple yet a user-friendly interface to help you quickly compose a query. The builder enables you to define the basic parts of your query, The common ones are:
135+
130136
1. The table you want to query from
131137
2. The time field and metric field
132138
3. WHERE clause - Either use one of the pre-defined macros, to speed your writing time, or set up your own expression. Existing supported Macros are:
133-
134-
a. Macro $__timeFiler with last 7 days example:
139+
140+
a. Macro $__timeFiler with last 7 days example:
141+
135142
```
136143
WHERE `createDate` BETWEEN TIMESTAMP_MILLIS (1592147699012) AND TIMESTAMP_MILLIS (1592752499012) AND _PARTITIONTIME >= '2020-06-14 18:14:59' AND _PARTITIONTIME < '2020-06-21 18:14:59'
137-
```
138-
b. Macro $__timeFrom with last 7 days example:
144+
```
145+
146+
b. Macro $__timeFrom with last 7 days example:
147+
139148
```
140149
WHERE `createDate` > TIMESTAMP_MILLIS (1592223758609) AND _PARTITIONTIME >= '2020-06-15 15:22:38' AND _PARTITIONTIME < '2020-06-22 15:22:38'
141150
```
142-
c. Macro $__timeTo with last 7 days example:
151+
152+
c. Macro $__timeTo with last 7 days example:
153+
143154
```
144155
WHERE `createDate` < TIMESTAMP_MILLIS (1592828659681) AND _PARTITIONTIME >= '2020-06-15 15:24:19' AND _PARTITIONTIME < '2020-06-22 15:24:19'
145156
```
146157

147158
You can now use timeFilter macro in raw sql mode
148159

149160
4. GROUP BY option - You can use a pre-defined macro or use one of the fields from your query
150-
a. time ($__interval,none)
161+
a. time ($__interval,none)
151162
5. ORDER BY option
152163

153164
Note: If your processing location is not the Default US one set your location from the processing Location drop-down at the top right bottom of the query builder
154165

155166
### Troubleshooting
156-
Viewing your Query
157-
1. Use The Query Inspector located at the top of the query builder
158-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/QueryInspector.png)
159-
2. The query Inspector enables you to see the clean query and troubleshoot SQL errors
160-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/InspectPanel.png)
161-
The Query builder comes with a set of defaults which are control from the top of the Query Builder
162-
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/QueryBuilder.png)
167+
168+
Viewing your Query
169+
170+
1. Use The Query Inspector located at the top of the query builder
171+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/QueryInspector.png)
172+
2. The query Inspector enables you to see the clean query and troubleshoot SQL errors
173+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/InspectPanel.png)
174+
The Query builder comes with a set of defaults which are control from the top of the Query Builder
175+
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/QueryBuilder.png)
163176

164177
![](https://raw.githubusercontent.com/doitintl/bigquery-grafana/master/img/QueryOptions.png)
165178

@@ -168,11 +181,13 @@ Note: If your processing location is not the Default US one set your location fr
168181
The build works with Yarn:
169182

170183
#### Development Build
184+
171185
```
172186
yarn run build:dev
173187
```
174188

175189
#### Production Build
190+
176191
```
177192
yarn run build:prod
178193
```
@@ -190,4 +205,3 @@ See the [Contribution Guide](https://doitintl.github.io/bigquery-grafana/CONTRIB
190205
## License
191206

192207
See the [License File](https://doitintl.github.io/bigquery-grafana/LICENSE).
193-

0 commit comments

Comments
 (0)