Skip to content

Commit d1eff85

Browse files
authored
Merge pull request #25 from netdata/feat/prepare-plugin-sign
Feat/prepare plugin sign
2 parents 1b9a493 + fe98326 commit d1eff85

File tree

12 files changed

+136
-112
lines changed

12 files changed

+136
-112
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
jobs:
99
release:
1010
runs-on: ubuntu-latest
11+
env:
12+
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }}
1113

1214
steps:
1315
- uses: actions/checkout@v2
@@ -48,6 +50,10 @@ jobs:
4850
- name: Build and test frontend
4951
run: yarn build
5052

53+
- name: Sign plugin
54+
run: yarn sign
55+
if: ${{ env.GRAFANA_API_KEY != '' }}
56+
5157
- name: Get plugin metadata
5258
id: metadata
5359
run: |
@@ -82,7 +88,7 @@ jobs:
8288
mv dist "${{ steps.metadata.outputs.plugin-id }}"
8389
zip "${{ steps.metadata.outputs.archive }}" "${{ steps.metadata.outputs.plugin-id }}" -r
8490
md5sum "${{ steps.metadata.outputs.archive }}" > "${{ steps.metadata.outputs.archive-checksum }}"
85-
echo "checksum=$(cat \"./${{ steps.metadata.outputs.archive-checksum }}\" | cut -d' ' -f1)" >> $GITHUB_OUTPUT
91+
echo "checksum=$(cat './${{ steps.metadata.outputs.archive-checksum }}' | cut -d' ' -f1)" >> $GITHUB_OUTPUT
8692
8793
- name: Upload artifacts
8894
uses: actions/upload-artifact@v2

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3-
## 1.0.0 (Unreleased)
3+
## 2.0.0
4+
5+
The plugin is compliant with Grafana Signing Requirements.
6+
7+
## 1.0.12
48

59
Initial release.

README.md

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,25 @@
11
# Netdata data source for Grafana
22

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-
53
_Enhanced high-fidelity troubleshooting data source for the Open Source community!_
64

75
![Image](https://user-images.githubusercontent.com/82235632/193311991-a6d167ab-b845-49b7-817c-976b780e427e.png)
86

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 OSS or Enterprise (local)
38-
39-
For detailed instructions on how to install the plugin on Grafana OSS or Enterprise check the section [How to install the plugin?](#how-to-install-the-plugin).
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-
477
## How to install the plugin?
488

49-
To start using the Netdata data source plugin on your Grafana environment, local or Cloud, you need to install the plugin manually - it currently isn't signed. Here are some tips to get through this depending on your setup:
9+
To start using the Netdata data source plugin on your Grafana environment, local or Cloud. Here are some tips to get through this depending on your setup:
10+
* Directly through the Grafana UI
5011
* Docker
5112
* Linux (local)
5213
* Windows (local - powershell)
5314
* Building the plugin locally
5415

5516
The installations below will use different tools like: curl, docker, jq, wget, unzip and xcopy.
5617

18+
### Directly through the Grafana UI
19+
20+
Netdata is available in the Grafana Plugin catalog that can be accessed from the Grafana UI.
21+
For details on how to: use the Plugin catalog, manage the plugins (install, update, uninstall), and other information, please check [this documentation](https://grafana.com/docs/grafana/latest/administration/plugin-management/#plugin-catalog).
22+
5723
### Docker
5824

5925
#### Pre-buit script - setup-demo-environment
@@ -76,10 +42,10 @@ This script will:
7642

7743
#### Manual step-by-step
7844

79-
1. Setup your grafana docker container with the the permissions to load netdata plugin as unsinged
45+
1. Setup your grafana docker container with the the permissions to load netdata plugin
8046

8147
```
82-
docker run -d --env GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=netdata-datasource --name=grafana grafana/grafana
48+
docker run -d --name=grafana grafana/grafana
8349
```
8450

8551
2. Ensure you have the desired version of the plugin you want to install, get it from github releases
@@ -116,19 +82,7 @@ This script will:
11682
cp -rf netdata-datasource /var/lib/grafana/plugins
11783
```
11884

119-
4. Ensure that Netdata plugin which currently isn’t signed can be registered
120-
121-
```
122-
vi /etc/grafana/grafana.ini
123-
```
124-
125-
On `allow_loading_unsigned_plugins` entry add **netdata-datasource**
126-
127-
```
128-
allow_loading_unsigned_plugins = netdata-datasource
129-
```
130-
131-
5. After adding the plugin a restart of grafana server is needed
85+
3. After adding the plugin a restart of grafana server is needed
13286

13387
For init.d based services you can use the command:
13488
```
@@ -153,19 +107,7 @@ This script will:
153107
xcopy .\netdata-datasource\ "C:\Program Files\GrafanaLabs\grafana\data\plugins\netdata-datasource\" /E
154108
```
155109

156-
3. Ensure that Netdata plugin which currently isn’t signed can be registered
157-
158-
```
159-
notepad ‘C:\Program Files\GrafanaLabs\grafana\conf\default.ini’
160-
```
161-
162-
On `allow_loading_unsigned_plugins` entry add **netdata-datasource**
163-
164-
```
165-
allow_loading_unsigned_plugins = netdata-datasource
166-
```
167-
168-
4. After adding the plugin a restart of grafana server is needed
110+
3. After adding the plugin a restart of grafana server is needed
169111

170112
```
171113
net stop Grafana
@@ -188,4 +130,3 @@ For any of the above steps if you prefer to build this plugin locally instead of
188130
```
189131

190132
3. Place the contents of the `/dist` folder under the netdata folder in Grafana plugins directory.
191-

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "netdata-datasource",
3-
"version": "1.0.12",
2+
"name": "netdatacloud-netdata-datasource",
3+
"version": "2.0.0",
44
"description": "netdata datasource plugin",
55
"scripts": {
66
"build": "grafana-toolkit plugin:build",
@@ -13,9 +13,9 @@
1313
"author": "netdata",
1414
"license": "Apache-2.0",
1515
"devDependencies": {
16-
"@grafana/data": "latest",
17-
"@grafana/toolkit": "latest",
18-
"@grafana/ui": "latest",
16+
"@grafana/data": "8.5.5",
17+
"@grafana/toolkit": "8.5.5",
18+
"@grafana/ui": "8.5.5",
1919
"@testing-library/jest-dom": "5.4.0",
2020
"@testing-library/react": "^10.0.2",
2121
"@testing-library/react-hooks": "^8.0.1",

setup-demo-environment.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e -o pipefail
55

66
readonly CONTAINER_NAME="grafana-netdata-plugin-demo"
77
readonly CONTAINER_PORT=3000
8-
readonly GRAFANA_DOCKER_IMAGE="grafana/grafana:9.1.6"
8+
readonly GRAFANA_DOCKER_IMAGE="grafana/grafana:10.2.2"
99
readonly NETDATA_PLUGIN_REPO="netdata/netdata-grafana-datasource-plugin"
1010
readonly PROGNAME=$(basename $0)
1111
readonly ARG=$1
@@ -30,7 +30,7 @@ function run() {
3030
declare plugin_url
3131
plugin_url="$(get_latest_plugin)"
3232
set -x
33-
docker run -d -p 127.0.0.1::$CONTAINER_PORT -e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=netdata-datasource \
33+
docker run -d -p 127.0.0.1::$CONTAINER_PORT \
3434
--name $CONTAINER_NAME --entrypoint /bin/sleep $GRAFANA_DOCKER_IMAGE inf
3535
docker exec -it $CONTAINER_NAME \
3636
bash -c "cd /var/lib/grafana/plugins && wget $plugin_url && unzip *.zip"

src/QueryEditor.tsx

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
3333
value: query.contextId,
3434
});
3535
const [selectedDimensions, setSelectedDimensions] = React.useState<Dropdown[]>();
36-
const [selectedGroupBy, setSelectedGroupBy] = React.useState<Dropdown>();
36+
const [selectedGroupBy, setSelectedGroupBy] = React.useState<Dropdown>(GroupByList[0]);
3737
const [selectedMethod, setSelectedMethod] = React.useState<Dropdown>(Methods[0]);
38-
const [selectedAggreagations, setSelectedAggreagations] = React.useState<Dropdown>(Aggreagations[0]);
38+
const [selectedAggregations, setSelectedAggregations] = React.useState<Dropdown>(Aggreagations[0]);
3939
const [filterByValues, setFilterByValues] = React.useState<Dropdown[]>([]);
4040

4141
const { spaces } = useFetchSpaces(baseUrl);
@@ -54,7 +54,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
5454
setTotalInstances(data.data.nodes.reduce((acc: number, node: any) => acc + node.chartIDs.length, 0));
5555
};
5656

57-
const IsGroupFunctionAvailable = React.useCallback(() => {
57+
const isGroupFunctionAvailable = React.useCallback(() => {
5858
if (groupBy === 'instance' || selectedGroupBy?.value === 'instance') {
5959
return false;
6060
}
@@ -148,13 +148,13 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
148148
setSelectedContext({});
149149
setSelectedDimensions([]);
150150
setSelectedGroupBy(GroupByList[0]);
151-
setSelectedFilter({ label: 'No filter', value: 'No filter' });
151+
setSelectedFilter({});
152152
setSelectedFilterValue({});
153153
setSelectedMethod(Methods[0]);
154-
setSelectedAggreagations(Aggreagations[0]);
154+
setSelectedAggregations(Aggreagations[0]);
155155

156156
fetchRooms(v.value || '');
157-
onChange({ spaceId: v.value } as MyQuery);
157+
onChange({ ...query, spaceId: v.value });
158158
onRunQuery();
159159
};
160160

@@ -166,14 +166,14 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
166166
setSelectedContext({});
167167
setSelectedDimensions([]);
168168
setSelectedGroupBy(GroupByList[0]);
169-
setSelectedFilter({ label: 'No filter', value: 'No filter' });
169+
setSelectedFilter({});
170170
setSelectedFilterValue({});
171171
setSelectedMethod(Methods[0]);
172-
setSelectedAggreagations(Aggreagations[0]);
172+
setSelectedAggregations(Aggreagations[0]);
173173

174174
fetchContexts(selectedSpace?.value || '', v.value || '');
175175
fetchNodes(selectedSpace?.value || '', v.value || '');
176-
onChange({ spaceId: spaceId, roomId: v.value } as MyQuery);
176+
onChange({ ...query, spaceId: spaceId, roomId: v.value });
177177
onRunQuery();
178178
};
179179

@@ -183,14 +183,13 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
183183
// reset the rest of inputs
184184
setSelectedDimensions([]);
185185
setSelectedGroupBy(GroupByList[0]);
186-
setSelectedFilter({ label: 'No filter', value: 'No filter' });
186+
setSelectedFilter({});
187187
setSelectedFilterValue({});
188188
setSelectedMethod(Methods[0]);
189-
setSelectedAggreagations(Aggreagations[0]);
189+
setSelectedAggregations(Aggreagations[0]);
190190

191191
fetchDimensions({ spaceId, roomId, contextId: v.value, nodeIDs: selectedNodes?.map((n: any) => n.value) || [] });
192192
onChange({ ...query, contextId: v.value });
193-
onChange({ spaceId, roomId, contextId: v.value } as MyQuery);
194193
onRunQuery();
195194
};
196195

@@ -200,14 +199,14 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
200199
// reset the rest of inputs
201200
setSelectedDimensions([]);
202201
setSelectedGroupBy(GroupByList[0]);
203-
setSelectedFilter({ label: 'No filter', value: 'No filter' });
202+
setSelectedFilter({});
204203
setSelectedFilterValue({});
205204
setSelectedMethod(Methods[0]);
206-
setSelectedAggreagations(Aggreagations[0]);
205+
setSelectedAggregations(Aggreagations[0]);
207206

208207
fetchDimensions({ spaceId, roomId, contextId, nodeIDs: data });
209208
setSelectedNodes(data);
210-
onChange({ spaceId, roomId, contextId, nodes: data } as MyQuery);
209+
onChange({ ...query, spaceId, roomId, contextId, nodes: data } as MyQuery);
211210
onRunQuery();
212211
};
213212

@@ -249,7 +248,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
249248
};
250249

251250
const onAggreagationChange = (v: SelectableValue<string>) => {
252-
setSelectedAggreagations(v);
251+
setSelectedAggregations(v);
253252
onChange({ ...query, group: v.value });
254253
onRunQuery();
255254
};
@@ -336,7 +335,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
336335
labelWidth={10}
337336
inputEl={
338337
<Select
339-
disabled={!IsGroupFunctionAvailable()}
338+
disabled={!isGroupFunctionAvailable()}
340339
options={Methods}
341340
value={selectedMethod}
342341
onChange={onMethodChange}
@@ -352,7 +351,7 @@ const QueryEditor: React.FC<Props> = ({ datasource, query, onChange, onRunQuery
352351
inputEl={
353352
<Select
354353
options={Aggreagations}
355-
value={selectedAggreagations}
354+
value={selectedAggregations}
356355
onChange={onAggreagationChange}
357356
allowCustomValue
358357
isSearchable

src/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Netdata data source for Grafana
2+
3+
_Enhanced high-fidelity troubleshooting data source for the Open Source community!_
4+
5+
![Image](https://user-images.githubusercontent.com/82235632/193311991-a6d167ab-b845-49b7-817c-976b780e427e.png)
6+
7+
## What is Netdata data source plugin for Grafana?
8+
9+
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.
10+
11+
With this data source plugin we expose the troubleshooting capabilities of Netdata in Grafana, making them available more widely. Some of the key capabilities:
12+
- Real-time monitoring with single-second granularity.
13+
- Installation and out-of-the-box integrations available in seconds from one line of code.
14+
- 2,000+ metrics from across your whole Infrastructure, with insightful metadata associated with them.
15+
- Access to our fresh ML metrics (anomaly rates) - exposing our ML capabilities at the edge!
16+
17+
18+
## Getting started
19+
20+
### 1. Connect your Nodes to Netdata Cloud
21+
22+
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).
23+
24+
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!
25+
26+
> 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
27+
and applications running on it. More info at https://learn.netdata.cloud/docs/get-started.
28+
29+
### 2. Ensure you have an API Token for authentication purposes.
30+
31+
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.
32+
33+
![image](https://user-images.githubusercontent.com/82235632/189399116-2df5da8a-49d2-42b2-bdec-64b7f7d9bd83.png)
34+
35+
### 3. Install Netdata data source plugin
36+
37+
### 4. Add your API token to the Netdata data source plugin configuration
38+
39+
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!
40+
41+
![image](https://user-images.githubusercontent.com/82235632/189398814-1efbf1c7-1a62-4d5f-abe8-6a9297a3f008.png)

0 commit comments

Comments
 (0)