Skip to content

Commit a537615

Browse files
committed
init
1 parent fab767a commit a537615

34 files changed

+15286
-4
lines changed

.github/workflows/ci.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- 'master'
10+
workflow_dispatch:
11+
inputs:
12+
BRANCH:
13+
required: true
14+
default: 'master'
15+
DEPLOY:
16+
required: true
17+
default: 'false'
18+
type: choice
19+
options:
20+
- 'true'
21+
- 'false'
22+
ENV:
23+
required: true
24+
default: 'testing'
25+
type: choice
26+
options:
27+
- testing
28+
- staging
29+
- production
30+
31+
env:
32+
BRANCH: ${{ github.head_ref || github.ref_name || github.event.inputs.BRANCH }}
33+
DEPLOY: ${{ github.event.inputs.DEPLOY || 'false' }}
34+
ENV: ${{ github.event.inputs.ENV || 'testing' }}
35+
36+
jobs:
37+
build:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v2
41+
with:
42+
ref: ${{ env.BRANCH }}
43+
44+
- name: Setup Node.js environment
45+
uses: actions/[email protected]
46+
with:
47+
node-version: "14.x"
48+
49+
- name: Get yarn cache directory path
50+
id: yarn-cache-dir-path
51+
run: echo "::set-output name=dir::$(yarn cache dir)"
52+
53+
- name: Cache yarn cache
54+
uses: actions/cache@v2
55+
id: cache-yarn-cache
56+
with:
57+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
58+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
59+
restore-keys: |
60+
${{ runner.os }}-yarn-
61+
62+
- name: Cache node_modules
63+
id: cache-node-modules
64+
uses: actions/cache@v2
65+
with:
66+
path: node_modules
67+
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
68+
restore-keys: |
69+
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
70+
71+
- name: Install dependencies
72+
run: yarn install --frozen-lockfile
73+
74+
- name: Build and test frontend
75+
run: yarn build
76+
77+
- name: Setup build environment
78+
id: build_environment
79+
run: echo "::set-output name=BUILD_VERSION::$(jq -r .version package.json)"
80+
81+
- name: Package plugin
82+
run: |
83+
mv dist netdata-datasource
84+
zip "netdata-datasource-${{ steps.build_environment.outputs.BUILD_VERSION }}.zip" netdata-datasource -r
85+
86+
- name: Upload artifacts
87+
uses: actions/upload-artifact@v2
88+
with:
89+
name: netdata-datasource-${{ steps.build_environment.outputs.BUILD_VERSION }}.zip
90+
path: ./netdata-datasource-${{ steps.build_environment.outputs.BUILD_VERSION }}.zip
91+
92+
outputs:
93+
artifact_name: netdata-datasource-${{ steps.build_environment.outputs.BUILD_VERSION }}.zip
94+
95+
internal-deploy:
96+
needs: build
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Setup deploy environment
100+
id: deploy_environment
101+
run: |
102+
case $GITHUB_EVENT_NAME in
103+
workflow_dispatch)
104+
echo "::set-output name=ENV::${{ env.ENV }}"
105+
echo "::set-output name=DEPLOY::${{ env.DEPLOY }}"
106+
;;
107+
pull_request)
108+
echo "::set-output name=ENV::staging"
109+
echo "::set-output name=DEPLOY::false"
110+
;;
111+
push)
112+
echo "::set-output name=ENV::staging"
113+
echo "::set-output name=DEPLOY::true"
114+
;;
115+
*)
116+
echo "::set-output name=ENV::staging"
117+
echo "::set-output name=DEPLOY::false"
118+
;;
119+
esac
120+
121+
- name: Update Netdata Infra
122+
if: ${{ steps.deploy_environment.outputs.DEPLOY == 'true' }}
123+
uses: benc-uk/workflow-dispatch@v1
124+
with:
125+
token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
126+
repo: ${{ secrets.NETDATA_INFRA_REPO }}
127+
workflow: Netdata Grafana Plugin Deploy
128+
ref: master
129+
inputs: '{"artifact_name": "${{ needs.build.outputs.artifact_name }}", "env": "${{ steps.deploy_environment.outputs.ENV }}", "workflow_run_id": "${{ github.run_id }}"}'
130+
continue-on-error: true

.github/workflows/release.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Setup Node.js environment
16+
uses: actions/[email protected]
17+
with:
18+
node-version: "14.x"
19+
20+
- name: Get yarn cache directory path
21+
id: yarn-cache-dir-path
22+
run: echo "::set-output name=dir::$(yarn cache dir)"
23+
24+
- name: Cache yarn cache
25+
uses: actions/cache@v2
26+
id: cache-yarn-cache
27+
with:
28+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
29+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
30+
restore-keys: |
31+
${{ runner.os }}-yarn-
32+
33+
- name: Cache node_modules
34+
id: cache-node-modules
35+
uses: actions/cache@v2
36+
with:
37+
path: node_modules
38+
key: ${{ runner.os }}-${{ matrix.node-version }}-nodemodules-${{ hashFiles('**/yarn.lock') }}
39+
restore-keys: |
40+
${{ runner.os }}-${{ matrix.node-version }}-nodemodules-
41+
42+
- name: Install dependencies
43+
run: yarn install --frozen-lockfile;
44+
if: |
45+
steps.cache-yarn-cache.outputs.cache-hit != 'true' ||
46+
steps.cache-node-modules.outputs.cache-hit != 'true'
47+
48+
- name: Build and test frontend
49+
run: yarn build
50+
51+
- name: Get plugin metadata
52+
id: metadata
53+
run: |
54+
sudo apt-get install jq
55+
56+
export GRAFANA_PLUGIN_ID=$(cat dist/plugin.json | jq -r .id)
57+
export GRAFANA_PLUGIN_VERSION=$(cat dist/plugin.json | jq -r .info.version)
58+
export GRAFANA_PLUGIN_TYPE=$(cat dist/plugin.json | jq -r .type)
59+
export GRAFANA_PLUGIN_ARTIFACT=${GRAFANA_PLUGIN_ID}-${GRAFANA_PLUGIN_VERSION}.zip
60+
export GRAFANA_PLUGIN_ARTIFACT_CHECKSUM=${GRAFANA_PLUGIN_ARTIFACT}.md5
61+
62+
echo "::set-output name=plugin-id::${GRAFANA_PLUGIN_ID}"
63+
echo "::set-output name=plugin-version::${GRAFANA_PLUGIN_VERSION}"
64+
echo "::set-output name=plugin-type::${GRAFANA_PLUGIN_TYPE}"
65+
echo "::set-output name=archive::${GRAFANA_PLUGIN_ARTIFACT}"
66+
echo "::set-output name=archive-checksum::${GRAFANA_PLUGIN_ARTIFACT_CHECKSUM}"
67+
68+
echo ::set-output name=github-tag::${GITHUB_REF#refs/*/}
69+
70+
- name: Read changelog
71+
id: changelog
72+
run: |
73+
awk '/^## / {s++} s == 1 {print}' CHANGELOG.md > release_notes.md
74+
echo "::set-output name=path::release_notes.md"
75+
76+
- name: Check package version
77+
run: if [ "v${{ steps.metadata.outputs.plugin-version }}" != "${{ steps.metadata.outputs.github-tag }}" ]; then printf "\033[0;31mPlugin version doesn't match tag name\033[0m\n"; exit 1; fi
78+
79+
- name: Package plugin
80+
id: package-plugin
81+
run: |
82+
mv dist "${{ steps.metadata.outputs.plugin-id }}"
83+
zip "${{ steps.metadata.outputs.archive }}" "${{ steps.metadata.outputs.plugin-id }}" -r
84+
md5sum "${{ steps.metadata.outputs.archive }}" > "${{ steps.metadata.outputs.archive-checksum }}"
85+
echo "::set-output name=checksum::$(cat \"./${{ steps.metadata.outputs.archive-checksum }}\" | cut -d' ' -f1)"
86+
87+
- name: Upload artifacts
88+
uses: actions/upload-artifact@v2
89+
with:
90+
name: ${{ steps.metadata.outputs.archive }}
91+
path: ./${{ steps.metadata.outputs.archive }}
92+
93+
- name: Create release
94+
id: create_release
95+
uses: actions/create-release@v1
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
with:
99+
tag_name: ${{ github.ref }}
100+
release_name: Release ${{ github.ref }}
101+
body_path: ${{ steps.changelog.outputs.path }}
102+
103+
- name: Add plugin to release
104+
id: upload-plugin-asset
105+
uses: actions/upload-release-asset@v1
106+
env:
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108+
with:
109+
upload_url: ${{ steps.create_release.outputs.upload_url }}
110+
asset_path: ./${{ steps.metadata.outputs.archive }}
111+
asset_name: ${{ steps.metadata.outputs.archive }}
112+
asset_content_type: application/zip
113+
114+
- name: Add checksum to release
115+
id: upload-checksum-asset
116+
uses: actions/upload-release-asset@v1
117+
env:
118+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119+
with:
120+
upload_url: ${{ steps.create_release.outputs.upload_url }}
121+
asset_path: ./${{ steps.metadata.outputs.archive-checksum }}
122+
asset_name: ${{ steps.metadata.outputs.archive-checksum }}
123+
asset_content_type: text/plain
124+
125+
outputs:
126+
artifact_name: ${{ steps.metadata.outputs.archive }}
127+
128+
internal-deploy:
129+
needs: release
130+
runs-on: ubuntu-latest
131+
steps:
132+
- name: Update Netdata Infra
133+
uses: benc-uk/workflow-dispatch@v1
134+
with:
135+
token: ${{ secrets.NETDATABOT_GITHUB_TOKEN }}
136+
repo: ${{ secrets.NETDATA_INFRA_REPO }}
137+
workflow: Netdata Grafana Plugin Deploy
138+
ref: master
139+
inputs: '{"artifact_name": "${{ needs.release.outputs.artifact_name }}", "env": "production", "workflow_run_id": "${{ github.run_id }}"}'
140+
continue-on-error: true

.gitignore

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
node_modules/
9+
10+
# Runtime data
11+
pids
12+
*.pid
13+
*.seed
14+
*.pid.lock
15+
16+
# Directory for instrumented libs generated by jscoverage/JSCover
17+
lib-cov
18+
19+
# Coverage directory used by tools like istanbul
20+
coverage
21+
22+
# Compiled binary addons (https://nodejs.org/api/addons.html)
23+
dist/
24+
artifacts/
25+
work/
26+
ci/
27+
e2e-results/
28+
29+
# Editor
30+
.idea

.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+
};

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Changelog
2+
3+
## 1.0.0 (Unreleased)
4+
5+
Initial release.

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@
178178
APPENDIX: How to apply the Apache License to your work.
179179

180180
To apply the Apache License to your work, attach the following
181-
boilerplate notice, with the fields enclosed by brackets "[]"
181+
boilerplate notice, with the fields enclosed by brackets "{}"
182182
replaced with your own identifying information. (Don't include
183183
the brackets!) The text should be enclosed in the appropriate
184184
comment syntax for the file format. We also recommend that a
185185
file or class name and description of purpose be included on the
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright [yyyy] [name of copyright owner]
189+
Copyright {yyyy} {name of copyright owner}
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
1-
# netdata-grafana-datasource-plugin
2-
Netdata Grafana Datasource Plugin
1+
# Netdata data source for Grafana
2+
3+
[![Build](https://github.com/grafana/grafana-starter-datasource/workflows/CI/badge.svg)](https://github.com/grafana/grafana-starter-datasource/actions?query=workflow%3A%22CI%22)
4+
5+
_Enhanced high-fidelity troubleshooting data source for the Open Source community!_
6+
7+
![chrome_czu5FR4B9k](https://user-images.githubusercontent.com/82235632/189611641-c1f9e4a9-0a86-41e2-b96e-9944d6b29339.png)
8+
9+
## What is Netdata data source plugin for Grafana?
10+
11+
We are huge fans of Open Source culture and it is rooted deeply into our DNA, so we thought that the Open Source community would hugely benefit from Netdata providing a Grafana data source plugin that would expose its powerful data collection engine.
12+
13+
With this data source plugin we expose the troubleshooting capabilities of Netdata in Grafana, making them available more widely. Some of the key capabilities:
14+
- Real-time monitoring with single-second granularity.
15+
- Installation and out-of-the-box integrations available in seconds from one line of code.
16+
- 2,000+ metrics from across your whole Infrastructure, with insightful metadata associated with them.
17+
- Access to our fresh ML metrics (anomaly rates) - exposing our ML capabilities at the edge!
18+
19+
20+
## Getting started
21+
22+
### 1. Connect your Nodes to Netdata Cloud
23+
24+
Netdata’s data source plugin connects directly to our Netdata Cloud API’s, meaning that you’ll need to have your nodes (hosts) connected to [Netdata Cloud](https://app.netdata.cloud/?utm_source=grafana&utm_content=data_source_plugin) in order to be able to have them exposed on our plugin. For security purposes you will also need an API token for authentication (which you can get from within your Netdata profile).
25+
26+
Note: If you don't have an account [sign-up](https://app.netdata.cloud/?utm_source=grafana&utm_content=data_source_plugin) for free to get one!
27+
28+
> Netdata Agent will need to be installed and running on your server, VM and/or cluster, so that it can start collecting all the relevant metrics you have from the server
29+
and applications running on it. More info at https://learn.netdata.cloud/docs/get-started.
30+
31+
### 2. Ensure you have an API Token for authentication purposes.
32+
33+
Once you have all your nodes connected to Netdata Hub you must proceed with creating an API token, which will be linked to your Netdata Cloud account. The API token provides a means to authenticate external calls to our APIs, allowing the same access as you to the Spaces and Rooms you can see on Netdata Hub.
34+
35+
![image](https://user-images.githubusercontent.com/82235632/189399116-2df5da8a-49d2-42b2-bdec-64b7f7d9bd83.png)
36+
37+
### 3. Install Netdata data source plugin on Grafana Cloud or locally
38+
39+
For detailed instructions on how to install the plugin on Grafana Cloud or locally, please checkout the Plugin installation docs.
40+
41+
### 4. Add your API token to the Netdata data source plugin configuration
42+
43+
Once you have added your API token to Netdata data source plugin you’re ready to start taking advantage of Netdata’s troubleshooting capabilities in Grafana by starting creating your charts and dashboards!
44+
45+
![image](https://user-images.githubusercontent.com/82235632/189398814-1efbf1c7-1a62-4d5f-abe8-6a9297a3f008.png)
46+
47+
## Learn more
48+
49+
- What is Netdata? - https://learn.netdata.cloud/docs/overview/what-is-netdata
50+
- Netdata Cloud - https://learn.netdata.cloud/docs/cloud
51+
- Netdata Agent - https://learn.netdata.cloud/docs/get-started

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// This file is needed because it is used by vscode and other tools that
2+
// call `jest` directly. However, unless you are doing anything special
3+
// do not edit this file
4+
5+
const standard = require('@grafana/toolkit/src/config/jest.plugin.config');
6+
7+
// This process will use the same config that `yarn test` is using
8+
module.exports = standard.jestConfig();

0 commit comments

Comments
 (0)