Skip to content

Commit

Permalink
Correct graphite 'target' param serialization with traditional $.param
Browse files Browse the repository at this point in the history
  • Loading branch information
johnou committed Oct 3, 2024
1 parent 4de1606 commit 70a5c77
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion nsqadmin/static/build/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion nsqadmin/static/build/main.js.map

Large diffs are not rendered by default.

40 changes: 21 additions & 19 deletions nsqadmin/static/js/lib/handlebars_helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ Handlebars.registerHelper('nanotohuman', function(n) {
});

Handlebars.registerHelper('sparkline', function(typ, node, ns1, ns2, key) {
var interval = AppState.get('STATSD_INTERVAL') + 'sec';
var graphInterval = AppState.get('graph_interval');

var q = {
'colorList': genColorList(typ, key),
'height': '20',
Expand All @@ -248,19 +251,20 @@ Handlebars.registerHelper('sparkline', function(typ, node, ns1, ns2, key) {
'yMin': '0',
'lineMode': 'connected',
'drawNullAsZero': 'false',
'from': '-' + AppState.get('graph_interval'),
'until': '-1min'
'from': '-' + graphInterval,
'until': '-1min',
'target': _.map(genTargets(typ, node, ns1, ns2, key), function(t) {
return 'summarize(' + t + ',"' + interval + '","avg")';
})
};

var interval = AppState.get('STATSD_INTERVAL') + 'sec';
q['target'] = _.map(genTargets(typ, node, ns1, ns2, key), function(t) {
return 'summarize(' + t + ',"' + interval + '","avg")';
});

return AppState.get('GRAPHITE_URL') + '/render?' + $.param(q);
return AppState.get('GRAPHITE_URL') + '/render?' + $.param(q, true);
});

Handlebars.registerHelper('large_graph', function(typ, node, ns1, ns2, key) {
var statsdInterval = AppState.get('STATSD_INTERVAL');
var interval = statsdInterval + 'sec';

var q = {
'colorList': genColorList(typ, key),
'height': '450',
Expand All @@ -271,19 +275,17 @@ Handlebars.registerHelper('large_graph', function(typ, node, ns1, ns2, key) {
'lineMode': 'connected',
'drawNullAsZero': 'false',
'from': '-' + AppState.get('graph_interval'),
'until': '-1min'
'until': '-1min',
'target': _.map(genTargets(typ, node, ns1, ns2, key), function(t) {
if (metricType(key) === 'counter') {
var scale = 1 / statsdInterval;
t = 'scale(' + t + ',' + scale + ')';
}
return 'summarize(' + t + ',"' + interval + '","avg")';
})
};

var interval = AppState.get('STATSD_INTERVAL') + 'sec';
q['target'] = _.map(genTargets(typ, node, ns1, ns2, key), function(t) {
if (metricType(key) === 'counter') {
var scale = 1 / AppState.get('STATSD_INTERVAL');
t = 'scale(' + t + ',' + scale + ')';
}
return 'summarize(' + t + ',"' + interval + '","avg")';
});

return AppState.get('GRAPHITE_URL') + '/render?' + $.param(q);
return AppState.get('GRAPHITE_URL') + '/render?' + $.param(q, true);
});

Handlebars.registerHelper('rate', function(typ, node, ns1, ns2) {
Expand Down

0 comments on commit 70a5c77

Please sign in to comment.