From 0f87c3d001cf6ca054cc02555a15c9337ffc288b Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Mon, 21 Oct 2024 22:12:44 +1100 Subject: [PATCH] [8.16] [ES|QL] Enhance the recommended queries with the event rate option (#196803) (#197012) # Backport This will backport the following commits from `main` to `8.16`: - [[ES|QL] Enhance the recommended queries with the event rate option (#196803)](https://github.com/elastic/kibana/pull/196803) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Stratoula Kalafateli --- .../autocomplete/recommended_queries/templates.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/packages/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/templates.ts b/packages/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/templates.ts index f910d3ba05a3b..6a3226c9dcc8f 100644 --- a/packages/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/templates.ts +++ b/packages/kbn-esql-validation-autocomplete/src/autocomplete/recommended_queries/templates.ts @@ -100,6 +100,21 @@ export const getRecommendedQueries = ({ ), queryString: `${fromCommand}\n | WHERE ${timeField} <=?_tend and ${timeField} >?_tstart\n | STATS count = COUNT(*) BY \`Over time\` = BUCKET(${timeField}, 50, ?_tstart, ?_tend) // ?_tstart and ?_tend take the values of the time picker`, }, + { + label: i18n.translate( + 'kbn-esql-validation-autocomplete.recommendedQueries.eventRate.label', + { + defaultMessage: 'Calculate the event rate', + } + ), + description: i18n.translate( + 'kbn-esql-validation-autocomplete.recommendedQueries.eventRate.description', + { + defaultMessage: 'Event rate over time', + } + ), + queryString: `${fromCommand}\n | STATS count = COUNT(*), min_timestamp = MIN(${timeField}) // MIN(dateField) finds the earliest timestamp in the dataset.\n | EVAL event_rate = count / DATE_DIFF("seconds", min_timestamp, NOW()) // Calculates the event rate by dividing the total count of events by the time difference (in seconds) between the earliest event and the current time.\n | KEEP event_rate`, + }, { label: i18n.translate( 'kbn-esql-validation-autocomplete.recommendedQueries.lastHour.label',