Skip to content

Commit d1fdf20

Browse files
authored
Merge pull request #96 from scalyr/go-rewrite-v2-jmakar
Minor changes based on Grafana support feedback
2 parents c013588 + 9883e3a commit d1fdf20

File tree

5 files changed

+147
-147
lines changed

5 files changed

+147
-147
lines changed

CHANGELOG.md

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

3+
## 3.0.2
4+
5+
Minor changes based on Grafana support feedback.
6+
37
## 3.0.1
48

59
Minor cleanups/changes.

DEVELOPER_README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Building
2+
3+
1. Clone the [plugin repository](https://github.com/scalyr/scalyr-grafana-datasource-plugin) from GitHub.
4+
5+
```bash
6+
git clone https://github.com/scalyr/scalyr-grafana-datasource-plugin.git
7+
```
8+
9+
2. Build the Golang backend (with the version defined in go.mod, currently 1.16) using Mage.
10+
11+
```bash
12+
mage
13+
```
14+
15+
This will build the executables in `dist/`.
16+
17+
To install Mage (Golang make-like build tool):
18+
19+
```bash
20+
git clone https://github.com/magefile/mage $GOPATH/src/github.com/magefile/mage
21+
cd $GOPATH/src/github.com/magefile/mage
22+
git checkout tags/v1.12.1 # Specified in go.mod
23+
go run bootstrap.go
24+
```
25+
26+
A `mage` executable should now be in `$GOPATH/bin/`.
27+
28+
3. Build the Typescript frontend using LTS Node (>= v14) and Yarn.
29+
30+
```bash
31+
yarn install --pure-lockfile # Install dependencies into node_modules
32+
yarn build
33+
```
34+
35+
This will build and the frontend files in `dist/`.
36+
37+
To install Yarn: `npm install --global yarn`.
38+
39+
40+
5. For development versions, simply copy the files to the Grafana server plugin directory.
41+
42+
```bash
43+
mkdir /var/lib/grafana/plugins/dataset
44+
# copy files from dist/ into /var/lib/grafana/plugins/dataset
45+
```
46+
47+
Note that this is an unsigned plugin, and you must update your `grafana.ini` file to allow it adding the following line:
48+
49+
```bash
50+
allow_loading_unsigned_plugins = sentinelone-dataset-datasource
51+
```
52+
53+
6. Adding plugins requires a restart of your grafana server.
54+
55+
For init.d based services you can use the command:
56+
57+
```bash
58+
sudo service grafana-server restart
59+
```
60+
61+
For systemd based services you can use the following:
62+
63+
```bash
64+
systemctl restart grafana-server
65+
```
66+
67+
# Signing and Packaging
68+
69+
To sign and package the plugin for distribution:
70+
71+
```bash
72+
export GRAFANA_API_KEY=<YOUR_API_KEY>
73+
npx @grafana/toolkit plugin:sign # This creates dist/MANIFEST.txt
74+
75+
cp -r dist sentinelone-dataset-datasource
76+
zip -r sentinelone-dataset-datasource-$(jq -r .info.version sentinelone-dataset-datasource/plugin.json).zip sentinelone-dataset-datasource
77+
rm -rf sentinelone-dataset-datasource # Cleanup
78+
```
79+
80+
References
81+
- https://grafana.com/docs/grafana/latest/developers/plugins/package-a-plugin/
82+
- https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/
83+
84+
Note that updates must be submitted to Grafana support for review, if approved the updated plugin will be hosted by the Grafana API and be accessible via `grafana-cli`.
85+

README.md

Lines changed: 55 additions & 144 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ when you want to monitor many feeds on a single dashboard.
1010

1111
With the Dataset plugin, you will be able to create and visualize your log-based
1212
metrics along side all of your other data sources. It's a great way to have a
13-
single pane of glass for today's complex systems. You can leverage Grafana alerts
14-
based on Dataset data to notify you when there are possible issues. More
13+
single pane of glass for today's complex systems. You can leverage Grafana
14+
alerts based on Dataset data to notify you when there are possible issues. More
1515
importantly, you'll soon be able to jump to Dataset's fast, easy and intuitive
1616
platform to quickly identify the underlying causes of issues that may arise.
1717

@@ -21,140 +21,41 @@ platform to quickly identify the underlying causes of issues that may arise.
2121
assumes that an existing instance of Grafana already exists. If you need help
2222
bringing up a Grafana instance, please refer to the [documentation provided by
2323
Grafana](https://grafana.com/docs/installation/).
24-
* **A Dataset read log API Key**: A Dataset API key is required for Grafana to pull
25-
data from Dataset. You can obtain one by going to your account in the Dataset
26-
product and selecting the “API Keys” from the menu in the top right corner. You
27-
can find documentation on API Keys [here](https://www.scalyr.com/help/api#scalyr-api-keys).
24+
* **A Dataset read log API Key**: A Dataset API key is required for Grafana to
25+
pull data from Dataset. You can obtain one by going to your account in the
26+
Dataset product and selecting the “API Keys” from the menu in the top right
27+
corner. You can find documentation on API Keys
28+
[here](https://www.scalyr.com/help/api#scalyr-api-keys).
2829

29-
## Getting started
30+
## Installation
3031

31-
### Installing the latest / stable version with grafana-cli
32+
Using grafana-cli: `grafana-cli plugins install sentinelone-dataset-datasource`
3233

33-
1. To install the stable version of the plugin using grafana-cli, run the following command:
34+
Alternatively can download it
35+
[here](https://github.com/scalyr/scalyr-grafana-datasource-plugin/releases/latest/)
36+
and unzip it manually into the Grafana plugins directory (eg
37+
`/var/lib/grafana/plugins`). A restart of the Grafana server is required
38+
afterwards.
3439

35-
```bash
36-
grafana-cli --pluginUrl \
37-
https://github.com/scalyr/scalyr-grafana-datasource-plugin/releases/download/3.0.1/sentinelone-dataset-datasource.zip \
38-
plugins install sentinelone-dataset-datasource
39-
```
40+
## Configuration
4041

41-
Older versions can be downloaded from [github releases](https://github.com/scalyr/scalyr-grafana-datasource-plugin/releases).
42-
43-
2. Adding plugins requires a restart of your grafana server.
44-
45-
For init.d based services you can use the command:
46-
47-
```bash
48-
sudo service grafana-server restart
49-
```
50-
51-
For systemd based services you can use the following:
52-
53-
```bash
54-
systemctl restart grafana-server
55-
```
56-
57-
### Building a development version and installing manually
58-
59-
1. To build and install the `development` version of the plugin, clone the
60-
[plugin repository](https://github.com/scalyr/scalyr-grafana-datasource-plugin) from GitHub.
61-
62-
```bash
63-
git clone https://github.com/scalyr/scalyr-grafana-datasource-plugin.git
64-
```
65-
66-
2. Build the Golang backend (with the version defined in go.mod, currently 1.16) using Mage
67-
68-
```bash
69-
mage
70-
```
71-
72-
This will build the executables in `dist/`
73-
74-
To install Mage (Golang make-like build tool):
75-
76-
```bash
77-
git clone https://github.com/magefile/mage $GOPATH/src/github.com/magefile/mage
78-
cd $GOPATH/src/github.com/magefile/mage
79-
git checkout tags/v1.12.1 # Specified in go.mod
80-
go run bootstrap.go
81-
```
82-
83-
A `mage` executable should now be in `$GOPATH/bin/`.
84-
85-
3. Build the Typescript frontend using LTS Node (>= v14) and Yarn
86-
87-
```bash
88-
yarn install --pure-lockfile # Install dependencies into node_modules
89-
yarn build
90-
```
91-
92-
This will build and the frontend files in `dist/`
93-
94-
To install Yarn: `npm install --global yarn`
95-
96-
97-
5. For development versions, simply copy the files to the Grafana server plugin directory
98-
99-
```bash
100-
mkdir /var/lib/grafana/plugins/dataset
101-
# copy files from dist/ into /var/lib/grafana/plugins/dataset
102-
```
103-
104-
Note that this is an unsigned plugin, and you must update your `grafana.ini` file to allow it adding the following line:
105-
106-
```bash
107-
allow_loading_unsigned_plugins = sentinelone-dataset-datasource
108-
```
109-
110-
6. Adding plugins requires a restart of your grafana server.
111-
112-
For init.d based services you can use the command:
113-
114-
```bash
115-
sudo service grafana-server restart
116-
```
117-
118-
For systemd based services you can use the following:
119-
120-
```bash
121-
systemctl restart grafana-server
122-
```
123-
124-
### Package and sign the plugin
125-
126-
To sign and package the plugin for distribution:
127-
128-
```bash
129-
export GRAFANA_API_KEY=<YOUR_API_KEY>
130-
npx @grafana/toolkit plugin:sign # This creates dist/MANIFEST.txt
131-
132-
cp -r dist sentinelone-dataset-datasource
133-
zip -r sentinelone-dataset-datasource-$(jq -r .info.version sentinelone-dataset-datasource/plugin.json).zip sentinelone-dataset-datasource
134-
rm -rf sentinelone-dataset-datasource # Cleanup
135-
```
136-
137-
References
138-
- https://grafana.com/docs/grafana/latest/developers/plugins/package-a-plugin/
139-
- https://grafana.com/docs/grafana/latest/developers/plugins/sign-a-plugin/
140-
141-
### Verify the Plugin was Installed
142-
143-
1. In order to verify proper installation you must log in to your grafana instance
144-
and navigate to **Configuration Settings -> Data Sources**.
42+
1. Log in to your grafana instance and navigate to **Configuration Settings ->
43+
Data sources**.
14544

14645
![ConfigDataSource](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/ConfigDataSource.png)
14746

148-
2. This will take you into the configuration page. If you already have other data
149-
sources installed, you will see them show up here. Click on the **Add data source** button:
47+
2. This will take you into the configuration page. If you already have other
48+
data sources installed, you will see them show up here. Click on the **Add
49+
data source** button:
15050

15151
![DatasetConfig](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/DatasetConfig.png)
15252

153-
3. If you enter "Dataset" in the search bar on the resulting page you should see "Dataset" grafana plugin show up as an option.
53+
3. If you enter "Dataset" in the search bar on the resulting page you should see
54+
"Dataset" grafana plugin show up as an option.
15455

15556
![SearchForPlugin](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/SearchForPlugin.png)
15657

157-
4. Click on ***Select***. This will take you to a configuration page where you
58+
4. Click on **Select**. This will take you to a configuration page where you
15859
insert your API key mentioned in the prerequisite section.
15960

16061
![PluginConfig](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/PluginConfig.png)
@@ -166,49 +67,59 @@ References
16667
|Dataset API Key | Your Scalyr Read Logs API Key|
16768
|Dataset URL | `https://www.scalyr.com` or `https://eu.scalyr.com` for EU users.|
16869

169-
6. Click ***Save & Test*** to verify these settings are correct.
70+
6. Click **Save & Test** to verify these settings are correct.
71+
17072
## Using the Dataset Datasource
17173

172-
Now that you’ve completed installing and configuring the Dataset data source plugin,
173-
lets go through an example of how you can start using it to create a dashboard
174-
using Scalyr data.
74+
Now that you’ve completed installing and configuring the Dataset data source
75+
plugin, lets go through an example of how you can start using it to create a
76+
dashboard using Scalyr data.
17577

176-
1. Create a new dashboard by click Create > dashboard
78+
1. Create a new dashboard by click **Create -> Dashboard**.
17779

17880
![CreateDashboard](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/CreateDashboard.png)
17981

180-
2. In the **New dashboard** box, select the **Add a new panel** icon
82+
2. In the **New dashboard** box, select the **Add a new panel** icon.
18183

182-
3. From the Data source dropdown, select **"Dataset"**.
84+
3. From the Data source dropdown, select **Dataset**.
18385

18486
![DataSetPlugin](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/DatasetPlugin.png)
18587

186-
4. A 'Query Type' field allows to choose the type of query you wanted to search for
88+
4. A **Query Type** field allows to choose the type of query you wanted to
89+
search for.
18790

18891
![QueryType](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/QueryType.png)
18992

190-
5. 'Standard Query' - A standard query allows to search on Graph view,
191-
You can enter Graph Functions into the expression box and visualize the results. You can even enter and visualize Complex Expressions
192-
Dataset [graphFunctions documentation](https://www.scalyr.com/help/dashboards#graphFunctions)
193-
is a good resource to see the list of supported functions.
194-
Enter expression and click the save button. In the image below, we've added a query to graph visualized the
195-
number of log messages that contain the word "error"
93+
5. **Standard Query** - A standard query allows to search on Graph view. You can
94+
enter graph functions into the expression box and visualize the results. You
95+
can even enter and visualize complex expressions.
96+
[This](https://www.scalyr.com/help/dashboards#graphFunctions) is a good
97+
resource to see the list of supported functions.
98+
99+
Enter an expression and click the save button. In the image below, we've
100+
added a query to graph the number of log messages that contain the word
101+
"error".
196102

197103
![StandardQuery](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/StandardQuery.png)
198104

199-
6. 'Power Query' - Works similar to PQ search in Dataset app. You can enter rich set of commands for transforming
200-
and manipulating data. Data can be viewed in Table format
201-
Visit [this documentation](https://app.scalyr.com/help/power-queries) for more information on building Power Queries
105+
6. **Power Query** - Works similar to PQ search in Dataset app. You can enter
106+
rich set of commands for transforming and manipulating data. Data can be
107+
viewed in table format. Visit
108+
[this page](https://app.scalyr.com/help/power-queries) for more information
109+
on building Power Queries.
202110

203111
![PowerQuery](https://raw.githubusercontent.com/scalyr/scalyr-grafana-datasource-plugin/go-rewrite-v2/src/img/PowerQuery.png)
204112

205-
You’ve successfully installed, configured and created a graph in Grafana using Dataset data!
113+
You’ve successfully installed, configured and created a graph in Grafana using
114+
Dataset data!
206115

207-
Note: you can add multiple queries to a visualization to plot multiple series on the same graph.
116+
Note: you can add multiple queries to a visualization to plot multiple series on
117+
the same graph.
208118

209119
## Variables
210120

211-
For general information on Grafana variables see the [Grafana documentation](https://grafana.com/docs/grafana/latest/reference/templating/)
121+
For general information on Grafana variables see the
122+
[Grafana documentation](https://grafana.com/docs/grafana/latest/reference/templating/)
212123

213124
Queries support all Grafana variable substitution syntaxes, for example:
214125

@@ -218,8 +129,8 @@ $varname
218129
${varname:option}
219130
```
220131

221-
For multi-value variables there is a custom default substitution method, the values will be quoted and separated with
222-
commas, for example:
132+
For multi-value variables there is a custom default substitution method, the
133+
values will be quoted and separated with commas, for example:
223134

224135
```bash
225136
"value1","value2","value3"

pkg/plugin/plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ func (d *DataSetDatasource) CheckHealth(_ context.Context, req *backend.CheckHea
295295
if statusCode != 200 {
296296
return &backend.CheckHealthResult{
297297
Status: backend.HealthStatusError,
298-
Message: fmt.Sprintf("DataSet returned response code %d", statusCode),
298+
Message: fmt.Sprintf("Failed to connect to DataSet, please inspect the Grafana server log for details"),
299299
}, nil
300300
}
301301

src/plugin.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@
4343
"path": "img/DatasetConfig.png"
4444
}
4545
],
46-
"version": "3.0.1",
47-
"updated": "2022-05-04"
46+
"version": "3.0.2",
47+
"updated": "2022-05-06"
4848
},
4949
"dependencies": {
5050
"grafanaDependency": ">=7.0.0",

0 commit comments

Comments
 (0)