Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dilate the period in heatmap view. #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

* Dilate period for tsbuckets/heatmap panels so we don't overwhelm the browser.

## 0.9.4

* Fix labels for untagged metrics
Expand Down
5 changes: 3 additions & 2 deletions dist/module.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/module.js.map

Large diffs are not rendered by default.

22 changes: 17 additions & 5 deletions src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export default class IrondbDatasource {
headers['Accept'] = 'application/json';
if (irondbOptions['std']['names'].length) {
const paneltype = irondbOptions['std']['names'][0]['leaf_data']['paneltype'] || 'Graph';
const dataFormat = irondbOptions['std']['names'][0]['leaf_data']['dataFormat'] || '';
for (let i = 0; i < irondbOptions['std']['names'].length; i++) {
options = {};
options.url = this.url;
Expand All @@ -374,7 +375,7 @@ export default class IrondbDatasource {
const interval = this.getRollupSpan(irondbOptions, start, end, false, irondbOptions['std']['names'][i]['leaf_data']);
start -= interval;
end += interval;
const reduce = paneltype === 'Heatmap' ? 'merge' : 'pass';
const reduce = paneltype === 'heatmap' ? 'merge' : 'pass';
const streams = [];
const data = { streams: streams };
data['period'] = interval;
Expand All @@ -387,7 +388,7 @@ export default class IrondbDatasource {
const stream = {};
let transform = irondbOptions['std']['names'][i]['leaf_data']['egress_function'];
if (metrictype === 'histogram') {
if (paneltype === 'Heatmap') {
if (paneltype === 'heatmap') {
transform = 'none';
} else {
transform = HISTOGRAM_TRANSFORMS[transform];
Expand Down Expand Up @@ -416,6 +417,7 @@ export default class IrondbDatasource {
}
options.metricLabels = metricLabels;
options.paneltype = paneltype;
options.dataFormat = dataFormat;
options.isCaql = false;
options.retry = 1;
queries.push(options);
Expand All @@ -424,6 +426,8 @@ export default class IrondbDatasource {
if (irondbOptions['caql']['names'].length) {
for (let i = 0; i < irondbOptions['caql']['names'].length; i++) {
options = {};
options.paneltype = irondbOptions['caql']['names'][i].leaf_data.paneltype;
options.dataFormat = irondbOptions['caql']['names'][i].leaf_data.dataFormat;
options.url = this.url;
if ('hosted' === this.irondbType) {
options.url = options.url + '/irondb';
Expand Down Expand Up @@ -512,7 +516,13 @@ export default class IrondbDatasource {
}

getRollupSpan(options, start, end, isCaql, leafData) {
log(() => `getRollupSpan() intervalMs = ${options.intervalMs}, maxDataPoints = ${options.maxDataPoints}`);
var maxDataPoints = options.maxDataPoints;
const paneltype = leafData.paneltype;
const dataFormat = leafData.dataFormat;
if (dataFormat === 'tsbuckets' || paneltype === 'heatmap') {
maxDataPoints = 80; /* Antying larger makes grafana choke */
}
log(() => `getRollupSpan() intervalMs = ${options.intervalMs}, maxDataPoints = ${maxDataPoints}`);
log(() => `getRollupSpan() ${isCaql ? 'CAQL' : '/fetch'} ${JSON.stringify(leafData)}`);
let rolluptype = leafData.rolluptype;
const metricrollup = leafData.metricrollup;
Expand All @@ -524,7 +534,7 @@ export default class IrondbDatasource {
const exactMs = parseDurationMs(metricrollup);
const exactDatapoints = Math.floor(((end - start) * 1000) / exactMs);
log(() => `getRollupSpan() exactMs = ${exactMs}, exactDatapoints = ${exactDatapoints}`);
if (exactDatapoints > options.maxDataPoints * IrondbDatasource.MAX_EXACT_DATAPOINTS_THRESHOLD) {
if (exactDatapoints > maxDataPoints * IrondbDatasource.MAX_EXACT_DATAPOINTS_THRESHOLD) {
throw new Error('Too many datapoints requested');
}
IrondbDatasource.checkRollupAligned(exactMs);
Expand All @@ -543,7 +553,7 @@ export default class IrondbDatasource {
intervalMs = minimumMs;
}
let interval = nudgeInterval(intervalMs / 1000, -1);
while ((end - start) / interval > options.maxDatapoints * IrondbDatasource.MAX_DATAPOINTS_THRESHOLD) {
while ((end - start) / interval > maxDataPoints * IrondbDatasource.MAX_DATAPOINTS_THRESHOLD) {
interval = nudgeInterval(interval + 0.001, 1);
}
log(() => `getRollupSpan() intervalMs = ${intervalMs} -> interval ${interval}`);
Expand Down Expand Up @@ -646,6 +656,8 @@ export default class IrondbDatasource {
leaf_data: {
rolluptype: target.rolluptype,
metricrollup: target.metricrollup,
dataFormat: target.dataFormat,
paneltype: target.paneltype,
},
});
return Promise.resolve(cleanOptions);
Expand Down
4 changes: 3 additions & 1 deletion src/query_ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ export class IrondbQueryCtrl extends QueryCtrl {
this.target.rolluptype = this.target.rolluptype || 'automatic';
this.target.query = this.target.query || '';
this.target.segments = this.target.segments || [];
this.target.paneltype = this.panelCtrl.pluginName;
this.target.paneltype = this.panelCtrl.panel.type;
this.target.dataFormat = this.panelCtrl.panel.dataFormat;
this.queryModel = new IrondbQuery(this.datasource, this.target, templateSrv);
this.buildSegments();
this.updateMetricLabelValue(false);
Expand All @@ -85,6 +86,7 @@ export class IrondbQueryCtrl extends QueryCtrl {
this.target.egressoverride = 'average';
this.target.labeltype = 'default';
this.target.rolluptype = 'automatic';
this.target.dataFormat = '';
this.emptySegments();
this.parseTarget();
this.panelCtrl.refresh();
Expand Down