Skip to content

Commit

Permalink
[Synthetics UI] Filter history stats by location (#145515)
Browse files Browse the repository at this point in the history
## Summary

Related to #144857. Ensure the stats in the history page also take into
account the monitor location.
  • Loading branch information
Alejandro Fernández Gómez authored Nov 17, 2022
1 parent 55816d9 commit ce1ec31
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand All @@ -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',
Expand Down

0 comments on commit ce1ec31

Please sign in to comment.