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

Fixes #12113 - Add timezone to date histogram aggregations for TSVB #13378

Merged
merged 5 commits into from
Aug 14, 2017
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { validateInterval } from '../lib/validate_interval';
import { dashboardContextProvider } from 'plugins/kibana/dashboard/dashboard_context';
import { timezoneProvider } from 'ui/vis/lib/timezone';

const MetricsRequestHandlerProvider = function (Private, Notifier, config, timefilter, $http) {
const dashboardContext = Private(dashboardContextProvider);
Expand All @@ -8,12 +9,13 @@ const MetricsRequestHandlerProvider = function (Private, Notifier, config, timef
return {
name: 'metrics',
handler: function (vis /*, appState, uiState, queryFilter*/) {
const timezone = Private(timezoneProvider)();

return new Promise((resolve) => {
const panel = vis.params;
if (panel && panel.id) {
const params = {
timerange: timefilter.getBounds(),
timerange: { timezone, ...timefilter.getBounds() },
filters: [dashboardContext()],
panels: [panel]
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const body = JSON.parse(`
}
],
"timerange": {
"timezone": "UTC",
"max": "2017-01-26T20:52:35.881Z",
"min": "2017-01-26T20:37:35.881Z"
}
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('buildRequestBody(req)', () => {
'field': '@timestamp',
'interval': '10s',
'min_doc_count': 0,
'time_zone': 'UTC',
'extended_bounds': {
'min': 1485463055881,
'max': 1485463955881
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ export default function dateHistogram(req, panel, annotation) {
const timeField = annotation.time_field;
const { bucketSize, intervalString } = getBucketSize(req, 'auto');
const { from, to } = getTimerange(req);
const { timezone:time_zone } = req.payload.timerange;
_.set(doc, `aggs.${annotation.id}.date_histogram`, {
field: timeField,
interval: intervalString,
min_doc_count: 0,
time_zone,
extended_bounds: {
min: from.valueOf(),
max: to.valueOf() - (bucketSize * 1000)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('dateHistogram(req, panel, series)', () => {
req = {
payload: {
timerange: {
timezone: 'UTC',
min: '2017-01-01T00:00:00Z',
max: '2017-01-01T01:00:00Z'
}
Expand Down Expand Up @@ -42,6 +43,7 @@ describe('dateHistogram(req, panel, series)', () => {
field: '@timestamp',
interval: '10s',
min_doc_count: 0,
time_zone: 'UTC',
extended_bounds: {
min: 1483228800000,
max: 1483232400000
Expand All @@ -67,6 +69,7 @@ describe('dateHistogram(req, panel, series)', () => {
field: '@timestamp',
interval: '10s',
min_doc_count: 0,
time_zone: 'UTC',
extended_bounds: {
min: 1483225200000,
max: 1483228800000
Expand Down Expand Up @@ -95,6 +98,7 @@ describe('dateHistogram(req, panel, series)', () => {
field: 'timestamp',
interval: '20s',
min_doc_count: 0,
time_zone: 'UTC',
extended_bounds: {
min: 1483228800000,
max: 1483232400000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ export default function dateHistogram(req, panel, series) {
const { timeField, interval } = getIntervalAndTimefield(panel, series);
const { intervalString } = getBucketSize(req, interval);
const { from, to } = offsetTime(req, series.offset_time);
const { timezone:time_zone } = req.payload.timerange;

set(doc, `aggs.${series.id}.aggs.timeseries.date_histogram`, {
field: timeField,
interval: intervalString,
min_doc_count: 0,
time_zone,
extended_bounds: {
min: from.valueOf(),
max: to.valueOf()
Expand Down