Skip to content
This repository was archived by the owner on Apr 27, 2023. It is now read-only.

Commit cbe396c

Browse files
committed
feat: support template variables (#9)
Also move code back from the main repo to this one.
1 parent 3824ac5 commit cbe396c

20 files changed

+2060
-87
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: 'setup-node'
2+
description: 'Sets up nodejs'
3+
runs:
4+
using: "composite"
5+
steps:
6+
- name: Setup Node.js environment
7+
uses: actions/setup-node@v2
8+
with:
9+
node-version: "14.17"
10+
11+
- name: Get yarn cache directory path
12+
id: yarn-cache-dir-path
13+
run: echo "::set-output name=dir::$(yarn cache dir)"
14+
shell: bash
15+
16+
- name: Cache yarn cache
17+
uses: actions/cache@v2
18+
id: cache-yarn-cache
19+
with:
20+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
21+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22+
restore-keys: |
23+
${{ runner.os }}-yarn-
24+
25+
- name: Cache node_modules
26+
id: cache-node-modules
27+
uses: actions/cache@v2
28+
with:
29+
path: node_modules
30+
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
31+
restore-keys: |
32+
${{ runner.os }}-${{ matrix.node-version }}-node-modules-

.github/workflows/ci.yml

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,58 +9,25 @@ env:
99
CYPRESS_CACHE_FOLDER: cypress/cache
1010

1111
jobs:
12-
build:
12+
cypress:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- uses: actions/checkout@v2
16-
17-
- name: Setup Node.js environment
18-
uses: actions/setup-node@v2
19-
with:
20-
node-version: "14.17"
21-
22-
- name: Get yarn cache directory path
23-
id: yarn-cache-dir-path
24-
run: echo "::set-output name=dir::$(yarn cache dir)"
25-
26-
- name: Cache yarn cache
27-
uses: actions/cache@v2
28-
id: cache-yarn-cache
29-
with:
30-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
31-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
32-
restore-keys: |
33-
${{ runner.os }}-yarn-
34-
35-
- name: Cache node_modules
36-
id: cache-node-modules
37-
uses: actions/cache@v2
38-
with:
39-
path: node_modules
40-
key: ${{ runner.os }}-${{ matrix.node-version }}-node-modules-${{ hashFiles('**/yarn.lock') }}
41-
restore-keys: |
42-
${{ runner.os }}-${{ matrix.node-version }}-node-modules-
43-
15+
- uses: actions/checkout@v3
16+
- uses: ./.github/actions/setup-node/
4417
- name: Cache Cypress Binary
4518
id: cache-cypress-binary
4619
uses: actions/cache@v2
4720
with:
4821
path: cypress/cache
4922
key: cypress-binary-${{ hashFiles('yarn.lock') }}
50-
5123
- name: Pull dependencies
5224
run: yarn
53-
54-
- name: Sign plugin
55-
run: yarn sign
56-
env:
57-
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
58-
59-
60-
# Smoke test
61-
# We already tested it extensively in the other repository
25+
- name: Build
26+
run: yarn build
6227
- name: Run grafana server
63-
run: docker-compose -f docker-compose.yml up -d
28+
run: |
29+
docker-compose pull
30+
docker-compose up -d
6431
- name: Run tests
6532
run: yarn cy:ci
6633
env:
@@ -69,19 +36,26 @@ jobs:
6936
if: always()
7037
with:
7138
name: cypress-screenshots
72-
path: pyroscope/cypress/screenshots
39+
path: cypress/screenshots
7340
- uses: actions/upload-artifact@v2
7441
if: always()
7542
with:
7643
name: cypress-videos
77-
path: pyroscope/cypress/videos
78-
# Setup the go environment, since the grafana plugin linter isn't distributed as a binary
79-
- name: Setup Go environment
80-
if: steps.check-for-backend.outputs.has-backend == 'true'
81-
uses: actions/setup-go@v2
82-
with:
83-
go-version: "1.16"
44+
path: cypress/videos
8445

46+
build-and-lint:
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v3
50+
- uses: ./.github/actions/setup-node
51+
- name: Pull dependencies
52+
run: yarn
53+
- name: Build
54+
run: yarn build
55+
- name: Sign plugin
56+
run: yarn sign
57+
env:
58+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
8559
- name: Get plugin metadata
8660
id: metadata
8761
run: |
@@ -109,12 +83,39 @@ jobs:
10983
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
11084
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
11185
86+
#
87+
# analyzers:
88+
# screenshots:
89+
# rules:
90+
# screenshots:
91+
# # TODO publish screenshots?
92+
# enabled: false
93+
#
94+
#analyzers:
95+
# version:
96+
# enabled: false
97+
98+
99+
# A PR created by pyroscopebot (aka Release Please)
100+
# bumps package.json and CHANGELOG, which we then want to validate
101+
# If it's a user PR, don't check the version
102+
- uses: haya14busa/action-cond@v1
103+
id: ENABLE_VERSION_ANALYZER
104+
name: 'Enable linting version?'
105+
with:
106+
cond: ${{ github.event.pull_request.user.login }} == 'pyroscopebot'
107+
if_true: true
108+
if_false: false
109+
112110
- name: Lint plugin
113111
run: |
114112
export PATH="$(go env GOPATH)/bin/:$PATH"
115-
113+
envsubst < lint.config.yaml > lint.config.yaml
116114
git clone https://github.com/grafana/plugin-validator
117115
pushd ./plugin-validator/pkg/cmd/plugincheck2
118116
go install
119117
popd
120-
plugincheck2 -config lint.config.yaml ${{ steps.metadata.outputs.archive }}
118+
plugincheck2 -config lint.config.yaml -sourceCodeUri=. ${{ steps.metadata.outputs.archive }}
119+
env:
120+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
121+
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: conventional-pr
2+
on:
3+
pull_request:
4+
branches:
5+
- main
6+
types:
7+
- opened
8+
- edited
9+
- synchronize
10+
jobs:
11+
lint-pr:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- uses: CondeNast/[email protected]
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
with:
19+
commitTitleMatch: "false"
20+
ignoreCommits: "true"
21+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
name: release-please
6+
jobs:
7+
release-please:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: google-github-actions/release-please-action@v3
11+
with:
12+
release-type: go
13+
package-name: release-please-action
14+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}

.github/workflows/release.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
name: Release
22

33
on:
4-
push:
5-
branches:
6-
- main
4+
release:
5+
# https://stackoverflow.com/a/61066906
6+
types: [published]
7+
78

89
jobs:
910
release:
@@ -81,15 +82,26 @@ jobs:
8182
md5sum ${{ steps.metadata.outputs.archive }} > ${{ steps.metadata.outputs.archive-checksum }}
8283
echo "::set-output name=checksum::$(cat ./${{ steps.metadata.outputs.archive-checksum }} | cut -d' ' -f1)"
8384
85+
# A PR created by pyroscopebot (aka Release Please)
86+
# bumps package.json and CHANGELOG, which we then want to validate
87+
# If it's a user PR, don't check the version
88+
- uses: haya14busa/action-cond@v1
89+
id: ENABLE_VERSION_ANALYZER
90+
name: 'Enable linting version?'
91+
with:
92+
cond: ${{ github.event.pull_request.user.login }} == 'pyroscopebot'
93+
if_true: true
94+
if_false: false
95+
8496
- name: Lint plugin
8597
run: |
8698
export PATH="$(go env GOPATH)/bin/:$PATH"
87-
99+
envsubst < lint.config.yaml > lint.config.yaml
88100
git clone https://github.com/grafana/plugin-validator
89101
pushd ./plugin-validator/pkg/cmd/plugincheck2
90102
go install
91103
popd
92-
plugincheck2 -config lint.config.yaml ${{ steps.metadata.outputs.archive }}
104+
plugincheck2 -config lint.config.yaml -sourceCodeUri=. ${{ steps.metadata.outputs.archive }}
93105
# until here it's pretty much the same as ci.yml
94106
# TODO: share the code somehow
95107

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ e2e-results/
3232
.idea
3333

3434
pyroscope
35+
36+
cypress/videos/*.mp4

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Changelog
2+
3+
## [1.1.3](https://github.com/pyroscope-io/pyroscope/compare/@pyroscope/[email protected]...@pyroscope/[email protected]) (2022-07-11)
4+
Add a CHANGELOG.md
5+
6+
7+
## 1.1.2 (2022-02-24)
8+
Add support for [authenticated requests](https://github.com/pyroscope-io/pyroscope/pull/844).
9+

CONTRIBUTING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Contributing
2+
3+
## Releasing new versions
4+
1. Merge the PR created by `Release Please`
5+
2. Open [https://grafana.com/orgs/pyroscope/plugin-submissions/pyroscope-datasource](https://grafana.com/orgs/pyroscope/plugin-submissions/pyroscope-datasource) and submit the plugin, copying the links from this repository's releases.

README.md

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,51 @@
11
# Pyroscope Grafana Datasource Plugin
22

3-
For more info see [pyroscope-datasource plugin for Grafana | Grafana Labs](https://grafana.com/grafana/plugins/pyroscope-datasource/)
3+
**Important: Grafana version 7.2 or later required**
44

5+
## Getting started
56

6-
# Releasing new versions
7-
1. Update the `@pyroscope/datasource-plugin` dependency
8-
2. Update the version in `package.json` to match the same version from the `@pyroscope/datasource-plugin` dependency
9-
4. Open a Pull Request
10-
5. Wait for all the checks to have run successfully
11-
6. Merge the pull request
12-
7. Open [https://grafana.com/orgs/pyroscope/plugin-submissions/pyroscope-datasource](https://grafana.com/orgs/pyroscope/plugin-submissions/pyroscope-datasource) and submit the plugin, copying the links from this repository's releases.
7+
1. Install the plugin (Installation tab)
8+
2. Install [panel plugin](https://grafana.com/grafana/plugins/pyroscope-panel/)
9+
3. Open Grafana and go to **Configuration -> Plugins**
10+
4. Check that plugins are available
11+
5. Set up data source plugin:
12+
- **Configuration -> Data Sources -> Add data source**
13+
- click on `pyroscope-datasource`
14+
- Specify Pyroscope host in `Endpoint` field:
15+
![endpoint](https://raw.githubusercontent.com/pyroscope-io/grafana-panel-plugin/main/docs/assets/endpoint.jpg)
16+
6. Set up panel plugin:
17+
- Add an empty panel on your dashboard
18+
- Select `pyroscope-panel` from Visualization list
19+
- Under panel view in Query tab select `pyroscope-datasource`
20+
- In `Application name` input specify app name
21+
- Click `Apply`
22+
![settings](https://raw.githubusercontent.com/pyroscope-io/grafana-panel-plugin/main/docs/assets/settings.jpg)
1323

14-
# Contributing
15-
The code is available in the [main repo](https://github.com/pyroscope-io/pyroscope/tree/main/grafana-plugin/datasource)
24+
Congratulations! Now you can monitor application flamegraph on your Grafana dashboard!
25+
![dashboard](https://raw.githubusercontent.com/pyroscope-io/grafana-panel-plugin/main/docs/assets/dashboard.jpg)
26+
27+
### Datasource template variables
28+
29+
You can use variables of the type **Query** to query Pyroscope for a list of applications, labels, or label values.
30+
Variable query functions supported by Pyroscope data source:
31+
32+
| Name | Description |
33+
| ------------------------------------- | -------------------------------------------------------- |
34+
| apps() | Returns a list of application names |
35+
| label_names(_app_name_) | Returns a list of label names for the application |
36+
| label_values(_app_name_,_label_name_) | Returns a list of label values for the application label |
37+
38+
#### Example
39+
40+
Create a new variable in the dashboard settings:
41+
42+
- Name: `appName`
43+
- Type: **Query**
44+
- Data source: **select your Pyroscope data source**
45+
- Query: `apps()`
46+
47+
Now you should see the list of applications returned from the Pyroscope data source, and use the variable in the panel **Query** field:
48+
49+
```
50+
$appName{}
51+
```

lint.config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ global:
22
enabled: true
33
severity: error
44
jsonOutput: false
5+
6+
analyzers:
7+
version:
8+
enabled: ${ENABLE_VERSION_ANALYZER}

0 commit comments

Comments
 (0)