Skip to content

Commit e5d196a

Browse files
[Release] 2022-08-16 (#94)
1 parent cc32c3b commit e5d196a

File tree

10 files changed

+4833
-57
lines changed

10 files changed

+4833
-57
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,9 @@ dist/
88
dist-image/
99
out/
1010
sysdig/
11+
12+
# Local data
13+
grafana-data-*/
14+
15+
# IDE settings
16+
.idea/

README.md

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@ This README discusses the installation and configuration instructions for the Sy
66
<img alt="Sysdig datasource" src="https://user-images.githubusercontent.com/5033993/39788129-bd3963fe-52dd-11e8-86b0-10e127660e68.gif" width="1200" />
77
</p>
88

9+
---
10+
11+
## Support and Known Limitations
12+
13+
The Sysdig datasource plugin is currently in BETA and tested with Grafana version up to [8.5.5](https://github.com/grafana/grafana/releases/tag/v8.5.5).
14+
15+
**NOTE: this plugin is not supported with later versions of Grafana. Instead, use the official Prometheus data source plugin to query the Sysdig API. For more info: [Sysdig Docs](https://docs.sysdig.com/en/docs/sysdig-monitor/integrations-for-sysdig-monitor/collect-prometheus-metrics/configure-sysdig-with-grafana/).**
16+
17+
Known limitations of the Sysdig datasource plugin are listed below:
18+
* [Annotations](http://docs.grafana.org/reference/annotations/) are leveraged to show Sysdig events, but not broadly supported.
19+
* With Grafana you can enter any arbitrary [time range](https://grafana.com/docs/grafana/v8.5/dashboards/time-range-controls/), but data will be fetched according to retention and granularity restrictions as explained in [Sysdig Docs](https://docs.sysdig.com/en/docs/sysdig-monitor/explore/time-windows/#time-window-limitations).
20+
21+
---
922

1023
## Getting Started
1124

@@ -15,15 +28,26 @@ There are several installation approaches available for the Sysdig datasource pl
1528

1629
> **Note:** The Sysdig datasource plugin is currently not included in the [official & community built plugin page](https://grafana.com/plugins), and needs to be installed manually.
1730
31+
#### Compatibility
32+
33+
| Grafana Version | Plugin Version |
34+
|-----------------|----------------|
35+
| <= 7.3.10 | <= 0.10 |
36+
| 7.4.0 - 8.5.5 | 0.11 |
37+
38+
> **Note:** Starting from version 8, Grafana will not load unsigned plugins.
39+
> To load the sysdig plugin you must set the [allow_loading_unsigned_plugins](https://grafana.com/docs/grafana/v8.5/administration/configuration/#allow_loading_unsigned_plugins) property. (E.g. `allow_loading_unsigned_plugins=sysdig`)
40+
> For more information about the configuration files, refer to the [Grafana docs](https://grafana.com/docs/grafana/v8.5/administration/configuration/#configuration-file-location).
41+
1842
#### Using a Grafana Docker Container
1943

2044
We offer a Docker container image based on Grafana that comes with the plugin pre-installed:
2145

2246
```
23-
docker run -d -p 3000:3000 --name grafana sysdiglabs/grafana:latest
47+
docker run -d -p 3000:3000 -e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=sysdig --name grafana sysdiglabs/grafana:latest
2448
```
2549

26-
> For more information, refer to the [Docker Hub repository page](https://hub.docker.com/r/sysdiglabs/grafana) for more information about the
50+
> For more information, refer to the [Docker Hub repository page](https://hub.docker.com/r/sysdiglabs/grafana).
2751
2852
---
2953

@@ -33,13 +57,13 @@ Alternatively, the default Grafana container image can be used as is, and the pl
3357
```
3458
mkdir grafana-data
3559
mkdir grafana-data/plugins
36-
curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.tgz -o sysdig.tgz
60+
curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.tgz -o sysdig.tgz
3761
tar zxf sysdig.tgz -C grafana-data/plugins
3862
```
3963
2. Start the container with the current user, to give read/write permissions to the data directory:
4064
```
4165
ID=$(id -u)
42-
docker run -d --user $ID --volume "$PWD/grafana-data:/var/lib/grafana" -p 3000:3000 grafana/grafana:latest
66+
docker run -d --user $ID --volume "$PWD/grafana-data:/var/lib/grafana" -p 3000:3000 -e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=sysdig grafana/grafana:latest
4367
```
4468

4569
> For more information, refer to the [Grafana installation documentation](http://docs.grafana.org/installation/docker/#grafana-container-using-bind-mounts) and the [Docker documentation](https://docs.docker.com/storage/bind-mounts/).
@@ -59,7 +83,7 @@ The plugin can be installed on any host where Grafana is installed. To install t
5983
1. Open a shell terminal.
6084
2. Run the series of commands below:
6185
```
62-
curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.tgz -o sysdig.tgz
86+
curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.tgz -o sysdig.tgz
6387
tar zxf sysdig.tgz
6488
sudo cp -R sysdig /var/lib/grafana/plugins
6589
sudo service grafana-server restart
@@ -74,7 +98,7 @@ sudo service grafana-server restart
7498
1. Open a shell terminal.
7599
2. Run the series of commands below:
76100
```
77-
curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.tgz -o sysdig.tgz
101+
curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.tgz -o sysdig.tgz
78102
tar zxf sysdig.tgz
79103
cp -R sysdig /usr/local/var/lib/grafana/plugins
80104
brew services restart grafana
@@ -85,7 +109,7 @@ brew services restart grafana
85109

86110
##### Windows
87111

88-
1. Download the plugin from: https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.zip
112+
1. Download the plugin from: https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.zip
89113
2. Install the plugin in the Grafana plugins folder.
90114
3. Restart Grafana.
91115

@@ -122,6 +146,12 @@ In Sysdig, number panels, bar charts and histograms display aggregated data (i.e
122146

123147
> **Note:** To maintain the same aggregation mechanism and precision offered by the Sysdig API, create panels with the "Fetch single data point" flag turned on. This will instruct the datasource to make an aggregated data request to the API.
124148
149+
### Table panels
150+
151+
Starting from Grafana 7.4, and Sysdig plugin 0.11, the table panel must be created with the "Fetch as table" flag turned on.
152+
This flag can be used also with other Grafana panel types that requires data in a table format, like `Bar chart` and `Bar gauge`.
153+
154+
> **Note**: no migration is required for the existing panels.
125155
126156
### Filters
127157

@@ -262,18 +292,6 @@ The complete example below contains dynamic rows and panels:
262292

263293
---
264294

265-
266-
## Current limitations
267-
268-
The Sysdig datasource is currently in Beta. Sysdig will continue to release iterations to make the datasource more complete and robust; however, some issues may be encountered. A list of known limitations is provided below:
269-
270-
* The datasource is being tested with latest version of Grafana. If you're using older versions of Grafana and you find any issues, please report the issue and we'll make sure to support your version of Grafana!
271-
* We leverage [annotations](http://docs.grafana.org/reference/annotations/) to show Sysdig events, but we don't support it just yet.
272-
* With Grafana you can enter any arbitrary [time range](http://docs.grafana.org/reference/timerange/), but data will be fetched according to retention and granularity restrictions as explained in this [Sysdig Support page](https://support.sysdig.com/hc/en-us/articles/204889655).
273-
274-
275295
## Support / Community
276296

277-
The Sysdig Datasource Plugin for Grafana is currently in beta. We'd love to hear from you and help you with it!
278-
279-
Join our [Public Slack](https://slack.sysdig.com) channel ([#grafana](https://sysdig.slack.com/messages/CA7RSQXK9)) for announcements and discussions.
297+
We'd love to hear from you! Join our [Public Slack](https://slack.sysdig.com) channel ([#grafana](https://sysdig.slack.com/messages/CA7RSQXK9)) for announcements and discussions.

VERSION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
0.10
1+
0.11
2+

VERSION_GRAFANA

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7.0.0
1+
8.5.5

build/start.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
3+
setup_env() {
4+
echo "Prepare environment..."
5+
6+
GRAFANA_VERSION=`cat VERSION_GRAFANA`
7+
8+
DIST_PATH="dist"
9+
10+
PLUGIN_DIR="grafana-data-${GRAFANA_VERSION}/plugins"
11+
12+
USER_ID=$(id -u)
13+
14+
# Disabling interactive progress bar, and spinners gains 2x performances
15+
# as stated on https://twitter.com/gavinjoyce/status/691773956144119808
16+
npm config set progress false
17+
npm config set spin false
18+
}
19+
20+
start() {
21+
echo "Cleaning up..."
22+
23+
rm -rf ${PLUGIN_DIR}
24+
docker stop grafana-dev > /dev/null || true
25+
docker rm grafana-dev > /dev/null || true
26+
27+
echo "Building..."
28+
29+
npm run build
30+
31+
mkdir -p ${PLUGIN_DIR}/sysdig
32+
33+
cp -R ${DIST_PATH}/. ${PLUGIN_DIR}/sysdig
34+
rm -rf ${PLUGIN_DIR}/sysdig/test
35+
36+
echo "Build complete."
37+
38+
echo "Starting Grafana ${GRAFANA_VERSION} docker container with Sysdig plugin..."
39+
40+
mkdir -p grafana-data-${GRAFANA_VERSION}
41+
42+
docker run -p 3000:3000 --user $USER_ID -v "${PWD}/grafana-data-${GRAFANA_VERSION}:/var/lib/grafana" \
43+
-e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=sysdig \
44+
--rm grafana/grafana:${GRAFANA_VERSION}
45+
46+
}
47+
48+
set -ex
49+
setup_env
50+
start

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"scripts": {
66
"build": "./node_modules/grunt-cli/bin/grunt",
77
"test": "./node_modules/grunt-cli/bin/grunt mochaTest",
8-
"clean": "rm -rf dist"
8+
"clean": "rm -rf dist",
9+
"start": "./build/start.sh"
910
},
1011
"repository": {
1112
"type": "git",

src/data_service.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,18 +215,19 @@ function getBatchId(userTime) {
215215
}
216216

217217
function getRequests(options, requestTime) {
218-
return options.targets.map((target) => getRequest(target, requestTime));
218+
const isTabularFormat = options.targets[0].isTabularFormat;
219+
return options.targets.map((target) => getRequest(target, requestTime, isTabularFormat));
219220
}
220221

221-
function getRequest(target, requestTime) {
222+
function getRequest(target, requestTime, isTabularFormat) {
222223
if (requestTime) {
223224
return {
224225
format: {
225226
type: 'data'
226227
},
227228
time: getTime(),
228229
metrics: getMetrics(),
229-
sort: getSort(),
230+
sort: getSort(isTabularFormat),
230231
paging: getPaging(),
231232
scope: target.filter,
232233
group: {
@@ -281,12 +282,12 @@ function getRequest(target, requestTime) {
281282
}
282283
}
283284

284-
function getSort() {
285+
function getSort(isTabularFormat) {
285286
const sortDirection = target.sortDirection || 'desc';
286287

287288
let sort;
288289

289-
if (target.isTabularFormat === false) {
290+
if (isTabularFormat === false) {
290291
sort = [{ v0: sortDirection }, { k0: sortDirection }];
291292

292293
if (target.segmentBy.length > 0) {

src/partials/query.editor.html

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
</div>
5454

5555
<!-- Segmentation -->
56-
<div class="gf-form gf-form-inline" ng-repeat="item in ctrl.segmentByItems">
56+
<div class="gf-form gf-form-inline" ng-repeat="item in ctrl.segmentByItems" ng-if="!ctrl.isTabularFormat() || ctrl.isFirstTarget()">
5757
<div class="gf-form gf-form--grow">
5858
<label class="gf-form-label width-12" ng-if="item.isFirst === true">
5959
Segment by
@@ -68,17 +68,17 @@
6868

6969
<div style="min-width: 80px;">
7070
<button class="btn btn-inverse" ng-click="ctrl.removeSegmentBy(item)">
71-
<i class="fa fa-trash" />
71+
<i class="fa fa-trash" ></i>
7272
</button>
7373
<button class="btn btn-inverse" ng-click="ctrl.addSegmentBy(item)">
74-
<i class="fa fa-plus" />
74+
<i class="fa fa-plus" ></i>
7575
</button>
7676
</div>
7777
</div>
7878
</div>
7979

8080
<!-- Filter -->
81-
<div class="gf-form-inline" ng-if="ctrl.panel.type !== 'table' || ctrl.isFirstTarget()">
81+
<div class="gf-form-inline" ng-if="!ctrl.isTabularFormat() || ctrl.isFirstTarget()">
8282
<div class="gf-form gf-form--grow">
8383
<label class="gf-form-label width-12">
8484
Filter
@@ -107,13 +107,18 @@
107107
<div class="gf-form gf-form--grow"></div>
108108
<div class="gf-form">
109109
<gf-form-switch class="gf-form" label="Fetch single data point" label-class="width-12" checked="ctrl.target.isSingleDataPoint"
110-
on-change="ctrl.refresh()">
110+
ng-disabled="ctrl.isTabularFormat()"
111+
on-change="ctrl.refresh()"/>
112+
</div>
113+
<div class="gf-form">
114+
<gf-form-switch class="gf-form" label="Fetch as table" label-class="width-12" checked="ctrl.target.isTabularFormat"
115+
on-change="ctrl.onChangeTabularFormat()"/>
111116
</div>
112117
</div>
113118
</div>
114119

115120
<!-- Alias -->
116-
<div class="gf-form-inline" ng-if="ctrl.panel.type !== 'table' || ctrl.isFirstTarget()">
121+
<div class="gf-form-inline" ng-if="!ctrl.isTabularFormat() || ctrl.isFirstTarget()">
117122
<div class="gf-form gf-form--grow">
118123
<label class="gf-form-label width-12">
119124
Alias
@@ -127,4 +132,4 @@
127132
<!-- Time series vs data point -->
128133
<div class="gf-form gf-form-inline" ng-if="ctrl.target.isTabularFormat === false && ctrl.isFirstTarget()">
129134
</div>
130-
</query-editor-row>
135+
</query-editor-row>

src/query_ctrl.js

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ export class SysdigDatasourceQueryCtrl extends QueryCtrl {
6565
}
6666

6767
this.target.sortDirection = this.target.sortDirection || 'desc';
68-
69-
// enforce tabular format to be applied when the panel type is a table
70-
this.target.isTabularFormat = this.panel.type === 'table';
68+
this.target.isSingleDataPoint = this.target.isTabularFormat;
7169

7270
this.segmentByItems = this.calculateSegmentByItems();
7371
}
@@ -76,6 +74,10 @@ export class SysdigDatasourceQueryCtrl extends QueryCtrl {
7674
return this.panel.targets.indexOf(this.target) === 0;
7775
}
7876

77+
isTabularFormat() {
78+
return this.panel.targets[0].isTabularFormat;
79+
}
80+
7981
getLimitPlaceholder() {
8082
return `${DEFAULT_PAGE_LIMIT} (element count)`;
8183
}
@@ -90,11 +92,11 @@ export class SysdigDatasourceQueryCtrl extends QueryCtrl {
9092
getMetricOptions(query) {
9193
let parseMetric;
9294
let options = {
93-
areLabelsIncluded: this.panel.type === 'table',
95+
areLabelsIncluded: this.isTabularFormat(),
9496
match: query
9597
};
9698

97-
if (this.panel.type !== 'table') {
99+
if (!this.isTabularFormat()) {
98100
parseMetric = (m) => ({ text: m.id, value: m.id });
99101
} else {
100102
parseMetric = (m) => {
@@ -211,30 +213,31 @@ export class SysdigDatasourceQueryCtrl extends QueryCtrl {
211213
}
212214

213215
calculateSegmentByItems() {
214-
if (this.panel.type !== 'table' || this.isFirstTarget()) {
215-
if (this.target.segmentBy.length === 0) {
216-
return [
217-
{
218-
isFirst: true,
219-
canAdd: false,
220-
segmentBy: null
221-
}
222-
];
223-
} else {
224-
return this.target.segmentBy.map((segmentBy, i) => ({
225-
isFirst: i === 0,
226-
canAdd: i === this.target.segmentBy.length - 1,
227-
segmentBy
228-
}));
229-
}
216+
if (this.target.segmentBy.length === 0) {
217+
return [
218+
{
219+
isFirst: true,
220+
canAdd: false,
221+
segmentBy: null
222+
}
223+
];
230224
} else {
231-
return [];
225+
return this.target.segmentBy.map((segmentBy, i) => ({
226+
isFirst: i === 0,
227+
canAdd: i === this.target.segmentBy.length - 1,
228+
segmentBy
229+
}));
232230
}
233231
}
234232

235233
toggleEditorMode() {
236234
// noop
237235
}
236+
237+
onChangeTabularFormat() {
238+
this.target.isSingleDataPoint = this.target.isTabularFormat;
239+
this.refresh();
240+
}
238241
}
239242

240243
SysdigDatasourceQueryCtrl.templateUrl = 'partials/query.editor.html';

0 commit comments

Comments
 (0)