[8.6] [Synthetics UI] Filter history stats by location (#145515) (#145550)

# Backport

This will backport the following commits from `main` to `8.6`:
- [[Synthetics UI] Filter history stats by location
(#145515)](https://github.com/elastic/kibana/pull/145515)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Gómez","email":"alejandro.fernandez@elastic.co"},"sourceCommit":{"committedDate":"2022-11-17T12:10:19Z","message":"[Synthetics
UI] Filter history stats by location (#145515)\n\n##
Summary\r\n\r\nRelated to #144857. Ensure the stats in the history page
also take into\r\naccount the monitor
location.","sha":"ce1ec3178d1c329fe287d49cfc03681682f89b79","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:uptime","release_note:skip","v8.6.0","v8.7.0"],"number":145515,"url":"https://github.com/elastic/kibana/pull/145515","mergeCommit":{"message":"[Synthetics
UI] Filter history stats by location (#145515)\n\n##
Summary\r\n\r\nRelated to #144857. Ensure the stats in the history page
also take into\r\naccount the monitor
location.","sha":"ce1ec3178d1c329fe287d49cfc03681682f89b79"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/145515","number":145515,"mergeCommit":{"message":"[Synthetics
UI] Filter history stats by location (#145515)\n\n##
Summary\r\n\r\nRelated to #144857. Ensure the stats in the history page
also take into\r\naccount the monitor
location.","sha":"ce1ec3178d1c329fe287d49cfc03681682f89b79"}}]}]
BACKPORT-->

Co-authored-by: Alejandro Fernández Gómez <alejandro.fernandez@elastic.co>
This commit is contained in:
Kibana Machine 2022-11-17 08:13:37 -05:00 committed by GitHub
parent fa977c9c12
commit 2f2d4af9a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View file

@ -10,6 +10,7 @@ import React from 'react';
import { ReportTypes } from '@kbn/observability-plugin/public';
import { ClientPluginsStart } from '../../../../../plugin';
import { useMonitorQueryId } from '../hooks/use_monitor_query_id';
import { useSelectedLocation } from '../hooks/use_selected_location';
interface MonitorCompleteCountProps {
from: string;
@ -22,8 +23,9 @@ export const MonitorCompleteCount = (props: MonitorCompleteCountProps) => {
const { ExploratoryViewEmbeddable } = observability;
const monitorId = useMonitorQueryId();
const selectedLocation = useSelectedLocation();
if (!monitorId) {
if (!monitorId || !selectedLocation) {
return null;
}
@ -34,7 +36,10 @@ export const MonitorCompleteCount = (props: MonitorCompleteCountProps) => {
attributes={[
{
time: props,
reportDefinitions: { config_id: [monitorId] },
reportDefinitions: {
'monitor.id': [monitorId],
'observer.geo.name': [selectedLocation.label],
},
dataType: 'synthetics',
selectedMetricField: 'monitor_complete',
name: 'synthetics-series-1',

View file

@ -10,6 +10,7 @@ import React from 'react';
import { useEuiTheme } from '@elastic/eui';
import { ClientPluginsStart } from '../../../../../plugin';
import { useMonitorQueryId } from '../hooks/use_monitor_query_id';
import { useSelectedLocation } from '../hooks/use_selected_location';
interface Props {
from: string;
@ -21,10 +22,11 @@ export const MonitorCompleteSparklines = (props: Props) => {
const { ExploratoryViewEmbeddable } = observability;
const monitorId = useMonitorQueryId();
const selectedLocation = useSelectedLocation();
const { euiTheme } = useEuiTheme();
if (!monitorId) {
if (!monitorId || !selectedLocation) {
return null;
}
@ -38,7 +40,10 @@ export const MonitorCompleteSparklines = (props: Props) => {
{
seriesType: 'area',
time: props,
reportDefinitions: { 'monitor.id': [monitorId] },
reportDefinitions: {
'monitor.id': [monitorId],
'observer.geo.name': [selectedLocation.label],
},
dataType: 'synthetics',
selectedMetricField: 'state.id',
name: 'Monitor complete',

View file

@ -10,6 +10,7 @@ import React from 'react';
import { ReportTypes } from '@kbn/observability-plugin/public';
import { ClientPluginsStart } from '../../../../../plugin';
import { useMonitorQueryId } from '../hooks/use_monitor_query_id';
import { useSelectedLocation } from '../hooks/use_selected_location';
interface MonitorTotalRunsCountProps {
from: string;
@ -22,8 +23,9 @@ export const MonitorTotalRunsCount = (props: MonitorTotalRunsCountProps) => {
const { ExploratoryViewEmbeddable } = observability;
const monitorId = useMonitorQueryId();
const selectedLocation = useSelectedLocation();
if (!monitorId) {
if (!monitorId || !selectedLocation) {
return null;
}
@ -34,7 +36,10 @@ export const MonitorTotalRunsCount = (props: MonitorTotalRunsCountProps) => {
attributes={[
{
time: props,
reportDefinitions: { config_id: [monitorId] },
reportDefinitions: {
'monitor.id': [monitorId],
'observer.geo.name': [selectedLocation.label],
},
dataType: 'synthetics',
selectedMetricField: 'monitor_total_runs',
name: 'synthetics-series-1',