diff --git a/.gitignore b/.gitignore index b19ed68..4f4b798 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,9 @@ dist/ dist-image/ out/ sysdig/ + +# Local data +grafana-data-*/ + +# IDE settings +.idea/ diff --git a/README.md b/README.md index e4c150d..a7aa347 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,19 @@ This README discusses the installation and configuration instructions for the Sy Sysdig datasource

+--- + +## Support and Known Limitations + +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). + +**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/).** + +Known limitations of the Sysdig datasource plugin are listed below: +* [Annotations](http://docs.grafana.org/reference/annotations/) are leveraged to show Sysdig events, but not broadly supported. +* 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). + +--- ## Getting Started @@ -15,15 +28,26 @@ There are several installation approaches available for the Sysdig datasource pl > **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. +#### Compatibility + +| Grafana Version | Plugin Version | +|-----------------|----------------| +| <= 7.3.10 | <= 0.10 | +| 7.4.0 - 8.5.5 | 0.11 | + +> **Note:** Starting from version 8, Grafana will not load unsigned plugins. +> 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`) +> For more information about the configuration files, refer to the [Grafana docs](https://grafana.com/docs/grafana/v8.5/administration/configuration/#configuration-file-location). + #### Using a Grafana Docker Container We offer a Docker container image based on Grafana that comes with the plugin pre-installed: ``` -docker run -d -p 3000:3000 --name grafana sysdiglabs/grafana:latest +docker run -d -p 3000:3000 -e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=sysdig --name grafana sysdiglabs/grafana:latest ``` -> For more information, refer to the [Docker Hub repository page](https://hub.docker.com/r/sysdiglabs/grafana) for more information about the +> For more information, refer to the [Docker Hub repository page](https://hub.docker.com/r/sysdiglabs/grafana). --- @@ -33,13 +57,13 @@ Alternatively, the default Grafana container image can be used as is, and the pl ``` mkdir grafana-data mkdir grafana-data/plugins -curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.tgz -o sysdig.tgz +curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.tgz -o sysdig.tgz tar zxf sysdig.tgz -C grafana-data/plugins ``` 2. Start the container with the current user, to give read/write permissions to the data directory: ``` ID=$(id -u) -docker run -d --user $ID --volume "$PWD/grafana-data:/var/lib/grafana" -p 3000:3000 grafana/grafana:latest +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 ``` > 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 1. Open a shell terminal. 2. Run the series of commands below: ``` -curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.tgz -o sysdig.tgz +curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.tgz -o sysdig.tgz tar zxf sysdig.tgz sudo cp -R sysdig /var/lib/grafana/plugins sudo service grafana-server restart @@ -74,7 +98,7 @@ sudo service grafana-server restart 1. Open a shell terminal. 2. Run the series of commands below: ``` -curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.tgz -o sysdig.tgz +curl https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.tgz -o sysdig.tgz tar zxf sysdig.tgz cp -R sysdig /usr/local/var/lib/grafana/plugins brew services restart grafana @@ -85,7 +109,7 @@ brew services restart grafana ##### Windows -1. Download the plugin from: https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.7.zip +1. Download the plugin from: https://download.sysdig.com/stable/grafana-sysdig-datasource/grafana-sysdig-datasource-v0.11.zip 2. Install the plugin in the Grafana plugins folder. 3. Restart Grafana. @@ -122,6 +146,12 @@ In Sysdig, number panels, bar charts and histograms display aggregated data (i.e > **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. +### Table panels + +Starting from Grafana 7.4, and Sysdig plugin 0.11, the table panel must be created with the "Fetch as table" flag turned on. +This flag can be used also with other Grafana panel types that requires data in a table format, like `Bar chart` and `Bar gauge`. + +> **Note**: no migration is required for the existing panels. ### Filters @@ -262,18 +292,6 @@ The complete example below contains dynamic rows and panels: --- - -## Current limitations - -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: - -* 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! -* We leverage [annotations](http://docs.grafana.org/reference/annotations/) to show Sysdig events, but we don't support it just yet. -* 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). - - ## Support / Community -The Sysdig Datasource Plugin for Grafana is currently in beta. We'd love to hear from you and help you with it! - -Join our [Public Slack](https://slack.sysdig.com) channel ([#grafana](https://sysdig.slack.com/messages/CA7RSQXK9)) for announcements and discussions. +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. diff --git a/VERSION b/VERSION index 68c123c..28f3328 100644 --- a/VERSION +++ b/VERSION @@ -1 +1,2 @@ -0.10 +0.11 + diff --git a/VERSION_GRAFANA b/VERSION_GRAFANA index 66ce77b..c2c170e 100644 --- a/VERSION_GRAFANA +++ b/VERSION_GRAFANA @@ -1 +1 @@ -7.0.0 +8.5.5 diff --git a/build/start.sh b/build/start.sh new file mode 100755 index 0000000..7882fe8 --- /dev/null +++ b/build/start.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +setup_env() { + echo "Prepare environment..." + + GRAFANA_VERSION=`cat VERSION_GRAFANA` + + DIST_PATH="dist" + + PLUGIN_DIR="grafana-data-${GRAFANA_VERSION}/plugins" + + USER_ID=$(id -u) + + # Disabling interactive progress bar, and spinners gains 2x performances + # as stated on https://twitter.com/gavinjoyce/status/691773956144119808 + npm config set progress false + npm config set spin false +} + +start() { + echo "Cleaning up..." + + rm -rf ${PLUGIN_DIR} + docker stop grafana-dev > /dev/null || true + docker rm grafana-dev > /dev/null || true + + echo "Building..." + + npm run build + + mkdir -p ${PLUGIN_DIR}/sysdig + + cp -R ${DIST_PATH}/. ${PLUGIN_DIR}/sysdig + rm -rf ${PLUGIN_DIR}/sysdig/test + + echo "Build complete." + + echo "Starting Grafana ${GRAFANA_VERSION} docker container with Sysdig plugin..." + + mkdir -p grafana-data-${GRAFANA_VERSION} + + docker run -p 3000:3000 --user $USER_ID -v "${PWD}/grafana-data-${GRAFANA_VERSION}:/var/lib/grafana" \ + -e GF_PLUGINS_ALLOW_LOADING_UNSIGNED_PLUGINS=sysdig \ + --rm grafana/grafana:${GRAFANA_VERSION} + +} + +set -ex +setup_env +start diff --git a/package.json b/package.json index f162013..ac7f86d 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "build": "./node_modules/grunt-cli/bin/grunt", "test": "./node_modules/grunt-cli/bin/grunt mochaTest", - "clean": "rm -rf dist" + "clean": "rm -rf dist", + "start": "./build/start.sh" }, "repository": { "type": "git", diff --git a/src/data_service.js b/src/data_service.js index 06177a9..f75be94 100644 --- a/src/data_service.js +++ b/src/data_service.js @@ -215,10 +215,11 @@ function getBatchId(userTime) { } function getRequests(options, requestTime) { - return options.targets.map((target) => getRequest(target, requestTime)); + const isTabularFormat = options.targets[0].isTabularFormat; + return options.targets.map((target) => getRequest(target, requestTime, isTabularFormat)); } -function getRequest(target, requestTime) { +function getRequest(target, requestTime, isTabularFormat) { if (requestTime) { return { format: { @@ -226,7 +227,7 @@ function getRequest(target, requestTime) { }, time: getTime(), metrics: getMetrics(), - sort: getSort(), + sort: getSort(isTabularFormat), paging: getPaging(), scope: target.filter, group: { @@ -281,12 +282,12 @@ function getRequest(target, requestTime) { } } - function getSort() { + function getSort(isTabularFormat) { const sortDirection = target.sortDirection || 'desc'; let sort; - if (target.isTabularFormat === false) { + if (isTabularFormat === false) { sort = [{ v0: sortDirection }, { k0: sortDirection }]; if (target.segmentBy.length > 0) { diff --git a/src/partials/query.editor.html b/src/partials/query.editor.html index c00abe2..8be8775 100644 --- a/src/partials/query.editor.html +++ b/src/partials/query.editor.html @@ -53,7 +53,7 @@ -
+
-
+
-
+