Skip to content

Commit

Permalink
Fix dealing with no segmentations
Browse files Browse the repository at this point in the history
  • Loading branch information
davideschiera committed Apr 11, 2019
1 parent 86fdaf3 commit 5118823
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 10 additions & 8 deletions src/datasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class SysdigDatasource {
isSingleDataPoint: isTabularFormat || targets[0].isSingleDataPoint
};

if (Array.isArray(targetOptions.segmentBy) === false) {
if (targetOptions.segmentBy && Array.isArray(targetOptions.segmentBy) === false) {
// backwards compatibility: up to v0.3 one segmentation was supported only
targetOptions.segmentBy = [targetOptions.segmentBy];
}
Expand All @@ -113,13 +113,15 @@ export class SysdigDatasource {
target.target,
options.scopedVars
),
segmentBy: targetOptions.segmentBy.map((segmentBy) =>
TemplatingService.replaceSingleMatch(
this.templateSrv,
segmentBy,
options.scopedVars
)
),
segmentBy: targetOptions.segmentBy
? targetOptions.segmentBy.map((segmentBy) =>
TemplatingService.replaceSingleMatch(
this.templateSrv,
segmentBy,
options.scopedVars
)
)
: null,
filter: TemplatingService.replace(
this.templateSrv,
targetOptions.filter,
Expand Down
4 changes: 2 additions & 2 deletions src/sysdig_dashboard_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ class TimeSeriesBuilder extends BaseBuilder {
target: value.metricId,
timeAggregation: value.timeAggregation,
groupAggregation: value.groupAggregation,
segmentBy: keys.length === 1 ? keys[0].metricId : null,
segmentBy: keys.length > 0 ? keys.map((key) => key.metricId) : null,
filter: this.getTargetFilter(sysdigDashboard, sysdigPanel),
sortDirection: this.getTargetSortDirection(sysdigPanel),
pageLimit: this.getTargetPageLimit(sysdigPanel)
Expand Down Expand Up @@ -566,7 +566,7 @@ class TableBuilder extends TimeSeriesBuilder {
target: value.metricId,
timeAggregation: value.timeAggregation || 'concat',
groupAggregation: value.groupAggregation || 'concat',
segmentBy: keys.map((key) => key.metricId),
segmentBy: keys.length > 0 ? keys.map((key) => key.metricId) : null,
filter: this.getTargetFilter(sysdigDashboard, sysdigPanel),
sortDirection: this.getTargetSortDirection(sysdigPanel),
pageLimit: this.getTargetPageLimit(sysdigPanel)
Expand Down

0 comments on commit 5118823

Please sign in to comment.