@@ -9,19 +9,19 @@ import {
99 EuiFlexGroup ,
1010 EuiFlexItem ,
1111 EuiPage ,
12- EuiPageBody ,
13- EuiPageContent ,
14- EuiPageContentBody ,
1512 EuiPanel ,
1613 EuiSuperDatePicker ,
14+ EuiBadge ,
15+ EuiText ,
1716} from '@elastic/eui' ;
1817import { i18n } from '@kbn/i18n' ;
18+ import numeral from '@elastic/numeral' ;
19+ import { FormattedMessage } from '@kbn/i18n/react' ;
1920import moment from 'moment' ;
2021import React , { useCallback , useMemo , useState } from 'react' ;
21-
22- import euiStyled from '../../../../../../common/eui_styled_components' ;
2322import { TimeRange } from '../../../../common/http_api/shared/time_range' ;
2423import { bucketSpan } from '../../../../common/log_analysis' ;
24+ import euiStyled from '../../../../../../common/eui_styled_components' ;
2525import { LoadingPage } from '../../../components/loading_page' ;
2626import {
2727 StringTimeRange ,
@@ -31,6 +31,8 @@ import {
3131import { useTrackPageview } from '../../../hooks/use_track_metric' ;
3232import { FirstUseCallout } from './first_use' ;
3333import { LogRateResults } from './sections/log_rate' ;
34+ import { AnomaliesResults } from './sections/anomalies' ;
35+ import { useKibanaUiSetting } from '../../../utils/use_kibana_ui_setting' ;
3436
3537export const AnalysisResultsContent = ( {
3638 sourceId,
@@ -42,6 +44,8 @@ export const AnalysisResultsContent = ({
4244 useTrackPageview ( { app : 'infra_logs' , path : 'analysis_results' } ) ;
4345 useTrackPageview ( { app : 'infra_logs' , path : 'analysis_results' , delay : 15000 } ) ;
4446
47+ const [ dateFormat ] = useKibanaUiSetting ( 'dateFormat' , 'MMMM D, YYYY h:mm A' ) ;
48+
4549 const {
4650 timeRange : selectedTimeRange ,
4751 setTimeRange : setSelectedTimeRange ,
@@ -56,13 +60,13 @@ export const AnalysisResultsContent = ({
5660 const bucketDuration = useMemo ( ( ) => {
5761 // This function takes the current time range in ms,
5862 // works out the bucket interval we'd need to always
59- // display 200 data points, and then takes that new
63+ // display 100 data points, and then takes that new
6064 // value and works out the nearest multiple of
6165 // 900000 (15 minutes) to it, so that we don't end up with
6266 // jaggy bucket boundaries between the ML buckets and our
6367 // aggregation buckets.
6468 const msRange = moment ( queryTimeRange . endTime ) . diff ( moment ( queryTimeRange . startTime ) ) ;
65- const bucketIntervalInMs = msRange / 200 ;
69+ const bucketIntervalInMs = msRange / 100 ;
6670 const result = bucketSpan * Math . round ( bucketIntervalInMs / bucketSpan ) ;
6771 const roundedResult = parseInt ( Number ( result ) . toFixed ( 0 ) , 10 ) ;
6872 return roundedResult < bucketSpan ? bucketSpan : roundedResult ;
@@ -130,39 +134,71 @@ export const AnalysisResultsContent = ({
130134 />
131135 ) : (
132136 < >
133- < EuiPage >
134- < EuiPanel paddingSize = "l" >
135- < EuiFlexGroup justifyContent = "spaceBetween" >
136- < EuiFlexItem > </ EuiFlexItem >
137- < EuiFlexItem grow = { false } >
138- < EuiSuperDatePicker
139- start = { selectedTimeRange . startTime }
140- end = { selectedTimeRange . endTime }
141- onTimeChange = { handleSelectedTimeRangeChange }
142- isPaused = { autoRefresh . isPaused }
143- refreshInterval = { autoRefresh . interval }
144- onRefreshChange = { handleAutoRefreshChange }
145- onRefresh = { handleQueryTimeRangeChange }
146- />
147- </ EuiFlexItem >
148- </ EuiFlexGroup >
149- </ EuiPanel >
150- </ EuiPage >
151- < ExpandingPage >
152- < EuiPageBody >
153- < EuiPageContent >
154- < EuiPageContentBody >
137+ < ResultsContentPage >
138+ < EuiFlexGroup direction = "column" >
139+ < EuiFlexItem grow = { false } >
140+ < EuiPanel paddingSize = "l" >
141+ < EuiFlexGroup justifyContent = "spaceBetween" alignItems = "center" >
142+ < EuiFlexItem grow = { false } >
143+ { ! isLoading && logEntryRate ? (
144+ < EuiText size = "s" >
145+ < FormattedMessage
146+ id = "xpack.infra.logs.analysis.logRateResultsToolbarText"
147+ defaultMessage = "Analyzed {numberOfLogs} log entries from {startTime} to {endTime}"
148+ values = { {
149+ numberOfLogs : (
150+ < EuiBadge color = "primary" >
151+ < EuiText size = "s" color = "ghost" >
152+ { numeral ( logEntryRate . totalNumberOfLogEntries ) . format ( '0.00a' ) }
153+ </ EuiText >
154+ </ EuiBadge >
155+ ) ,
156+ startTime : (
157+ < b > { moment ( queryTimeRange . startTime ) . format ( dateFormat ) } </ b >
158+ ) ,
159+ endTime : < b > { moment ( queryTimeRange . endTime ) . format ( dateFormat ) } </ b > ,
160+ } }
161+ />
162+ </ EuiText >
163+ ) : null }
164+ </ EuiFlexItem >
165+ < EuiFlexItem grow = { false } >
166+ < EuiSuperDatePicker
167+ start = { selectedTimeRange . startTime }
168+ end = { selectedTimeRange . endTime }
169+ onTimeChange = { handleSelectedTimeRangeChange }
170+ isPaused = { autoRefresh . isPaused }
171+ refreshInterval = { autoRefresh . interval }
172+ onRefreshChange = { handleAutoRefreshChange }
173+ onRefresh = { handleQueryTimeRangeChange }
174+ />
175+ </ EuiFlexItem >
176+ </ EuiFlexGroup >
177+ </ EuiPanel >
178+ </ EuiFlexItem >
179+ < EuiFlexItem grow = { false } >
180+ < EuiPanel paddingSize = "l" >
155181 { isFirstUse && ! hasResults ? < FirstUseCallout /> : null }
156182 < LogRateResults
157183 isLoading = { isLoading }
158184 results = { logEntryRate }
159185 setTimeRange = { handleChartTimeRangeChange }
160186 timeRange = { queryTimeRange }
161187 />
162- </ EuiPageContentBody >
163- </ EuiPageContent >
164- </ EuiPageBody >
165- </ ExpandingPage >
188+ </ EuiPanel >
189+ </ EuiFlexItem >
190+ < EuiFlexItem grow = { false } >
191+ < EuiPanel paddingSize = "l" >
192+ < AnomaliesResults
193+ isLoading = { isLoading }
194+ results = { logEntryRate }
195+ setTimeRange = { handleChartTimeRangeChange }
196+ timeRange = { queryTimeRange }
197+ />
198+ </ EuiPanel >
199+ </ EuiFlexItem >
200+ </ EuiFlexGroup >
201+ </ ResultsContentPage >
166202 </ >
167203 ) }
168204 </ >
@@ -183,6 +219,10 @@ const stringToNumericTimeRange = (timeRange: StringTimeRange): TimeRange => ({
183219 ) . valueOf ( ) ,
184220} ) ;
185221
186- const ExpandingPage = euiStyled ( EuiPage ) `
187- flex: 1 0 0%;
222+ // This is needed due to the flex-basis: 100% !important; rule that
223+ // kicks in on small screens via media queries breaking when using direction="column"
224+ export const ResultsContentPage = euiStyled ( EuiPage ) `
225+ .euiFlexGroup--responsive > .euiFlexItem {
226+ flex-basis: auto !important;
227+ }
188228` ;
0 commit comments