import React , { ReactNode } from 'react' ; import { ERROR_GROUP_ID , SERVICE_NAME , } from '../../../../../common/elasticsearch_fieldnames' ; import { APMError } from '../../../../../typings/es_schemas/ui/apm_error' ; import { DiscoverLink } from './discover_link' ; function getDiscoverQuery ( error , kuery ? ) { const serviceName = error . service . name ; const groupId = error . error . grouping_key ; let query = `${ SERVICE_NAME }:"${ serviceName }" AND ${ ERROR_GROUP_ID }:"${ groupId }"` ; if ( kuery ) { query += ` AND ${ kuery }` ; } return { _a : { interval : 'auto' , query : { language : 'kuery' , query , } , sort : { '@timestamp' : 'desc' } , } , } ; } function DiscoverErrorLink ( { error , kuery , children , } ) { return ( < DiscoverLink query = { getDiscoverQuery ( error , kuery ) } children = { children } / > ) ; } export { DiscoverErrorLink } ;