Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into telemetry/eve…
Browse files Browse the repository at this point in the history
…nt_loop_delays
  • Loading branch information
Bamieh committed Jun 21, 2021
2 parents fb82ae2 + 773647e commit 8dcd50e
Show file tree
Hide file tree
Showing 18 changed files with 352 additions and 171 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-public](./kibana-plugin-plugins-data-public.md) &gt; [AggConfigs](./kibana-plugin-plugins-data-public.aggconfigs.md) &gt; [getResolvedTimeRange](./kibana-plugin-plugins-data-public.aggconfigs.getresolvedtimerange.md)

## AggConfigs.getResolvedTimeRange() method

Returns the current time range as moment instance (date math will get resolved using the current "now" value or system time if not set)

<b>Signature:</b>

```typescript
getResolvedTimeRange(): import("../..").TimeRangeBounds | undefined;
```
<b>Returns:</b>

`import("../..").TimeRangeBounds | undefined`

Current time range as resolved date.

Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export declare class AggConfigs
| [getAll()](./kibana-plugin-plugins-data-public.aggconfigs.getall.md) | | |
| [getRequestAggById(id)](./kibana-plugin-plugins-data-public.aggconfigs.getrequestaggbyid.md) | | |
| [getRequestAggs()](./kibana-plugin-plugins-data-public.aggconfigs.getrequestaggs.md) | | |
| [getResolvedTimeRange()](./kibana-plugin-plugins-data-public.aggconfigs.getresolvedtimerange.md) | | Returns the current time range as moment instance (date math will get resolved using the current "now" value or system time if not set) |
| [getResponseAggById(id)](./kibana-plugin-plugins-data-public.aggconfigs.getresponseaggbyid.md) | | Find a response agg by it's id. This may be an agg in the aggConfigs, or one created specifically for a response value |
| [getResponseAggs()](./kibana-plugin-plugins-data-public.aggconfigs.getresponseaggs.md) | | Gets the AggConfigs (and possibly ResponseAggConfigs) that represent the values that will be produced when all aggs are run.<!-- -->With multi-value metric aggs it is possible for a single agg request to result in multiple agg values, which is why the length of a vis' responseValuesAggs may be different than the vis' aggs {<!-- -->array\[AggConfig\]<!-- -->} |
| [getSearchSourceTimeFilter(forceNow)](./kibana-plugin-plugins-data-public.aggconfigs.getsearchsourcetimefilter.md) | | |
Expand Down
5 changes: 2 additions & 3 deletions src/plugins/data/common/search/aggs/agg_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,8 @@ export class AggConfig {
} else if (!this.aggConfigs.timeRange) {
return;
}
return moment.duration(
moment(this.aggConfigs.timeRange.to).diff(this.aggConfigs.timeRange.from)
);
const resolvedBounds = this.aggConfigs.getResolvedTimeRange()!;
return moment.duration(moment(resolvedBounds.max).diff(resolvedBounds.min));
}
return parsedTimeShift;
}
Expand Down
15 changes: 14 additions & 1 deletion src/plugins/data/common/search/aggs/agg_configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { IAggType } from './agg_type';
import { AggTypesRegistryStart } from './agg_types_registry';
import { AggGroupNames } from './agg_groups';
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
import { TimeRange, getTime, isRangeFilter } from '../../../common';
import { TimeRange, getTime, isRangeFilter, calculateBounds } from '../../../common';
import { IBucketAggConfig } from './buckets';
import { insertTimeShiftSplit, mergeTimeShifts } from './utils/time_splits';

Expand Down Expand Up @@ -127,6 +127,19 @@ export class AggConfigs {
this.aggs.forEach(updateAggTimeRange);
}

/**
* Returns the current time range as moment instance (date math will get resolved using the current "now" value or system time if not set)
* @returns Current time range as resolved date.
*/
getResolvedTimeRange() {
return (
this.timeRange &&
calculateBounds(this.timeRange, {
forceNow: this.forceNow,
})
);
}

// clone method will reuse existing AggConfig in the list (will not create new instances)
clone({ enabledOnly = true } = {}) {
const filterAggs = (agg: AggConfig) => {
Expand Down
1 change: 1 addition & 0 deletions src/plugins/data/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ export class AggConfigs {
getRequestAggById(id: string): AggConfig | undefined;
// (undocumented)
getRequestAggs(): AggConfig[];
getResolvedTimeRange(): import("../..").TimeRangeBounds | undefined;
getResponseAggById(id: string): AggConfig | undefined;
getResponseAggs(): AggConfig[];
// (undocumented)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,21 @@ export default function ({
expect(getCell(result, 0, 2)).to.be(4618);
});

it('shifts multiple metrics with relative time range and previous', async () => {
const expression = `
kibana_context timeRange={timerange from='${timeRange.from}' to='now'}
| esaggs index={indexPatternLoad id='logstash-*'}
aggs={aggCount id="1" enabled=true schema="metric"}
aggs={aggCount id="2" enabled=true schema="metric" timeShift="previous"}
`;
const result = await expectExpression(
'esaggs_shift_multi_metric_previous',
expression
).getResponse();
expect(getCell(result, 0, 0)).to.be(9247);
expect(getCell(result, 0, 1)).to.be(4763);
});

it('shifts single percentile', async () => {
const expression = `
kibana_context timeRange={timerange from='${timeRange.from}' to='${timeRange.to}'}
Expand Down Expand Up @@ -137,7 +152,7 @@ export default function ({
customMetric={aggAvg id="3"
field="bytes"
enabled=true
schema="metric"
schema="metric"
}
enabled=true
schema="metric"
Expand All @@ -154,7 +169,7 @@ export default function ({
customMetric={aggAvg id="5"
field="bytes"
enabled=true
schema="metric"
schema="metric"
}
enabled=true
schema="metric"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export function DetailView({ errorGroup, urlParams }: Props) {
const status = error.http?.response?.status_code;

return (
<EuiPanel>
<EuiPanel hasBorder={true}>
<HeaderContainer>
<EuiTitle size="s">
<h3>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,13 @@ export function ErrorGroupDetails({

return (
<>
<EuiSpacer size={'s'} />

<ErrorGroupHeader groupId={groupId} isUnhandled={isUnhandled} />

<EuiPanel>
<EuiSpacer size={'m'} />

<EuiPanel hasBorder={true}>
{showDetails && (
<Titles>
<EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) {
return (
<EuiFlexGroup direction="column" gutterSize="s">
<EuiFlexItem>
<EuiPanel>
<EuiPanel hasBorder={true}>
<ErrorDistribution
distribution={errorDistributionData}
title={i18n.translate(
Expand All @@ -85,7 +85,7 @@ export function ErrorGroupOverview({ serviceName }: ErrorGroupOverviewProps) {
</EuiFlexItem>

<EuiFlexItem>
<EuiPanel>
<EuiPanel hasBorder={true}>
<EuiTitle size="xs">
<h3>
{i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ export interface Props {
* Current autoplay interval
*/
autoplayInterval: number;
/**
* Enables autoplay
*/
enableAutoplay: (autoplay: boolean) => void;
/**
* Sets autoplay interval
*/
Expand All @@ -110,7 +106,6 @@ export const ViewMenu: FunctionComponent<Props> = ({
setRefreshInterval,
autoplayEnabled,
autoplayInterval,
enableAutoplay,
setAutoplayInterval,
}) => {
const setRefresh = (val: number) => setRefreshInterval(val);
Expand Down Expand Up @@ -259,6 +254,5 @@ ViewMenu.propTypes = {
setRefreshInterval: PropTypes.func.isRequired,
autoplayEnabled: PropTypes.bool.isRequired,
autoplayInterval: PropTypes.number.isRequired,
enableAutoplay: PropTypes.func.isRequired,
setAutoplayInterval: PropTypes.func.isRequired,
};
Loading

0 comments on commit 8dcd50e

Please sign in to comment.