metricChart.tsx 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  1. import {Fragment, PureComponent} from 'react';
  2. import type {WithRouterProps} from 'react-router';
  3. import styled from '@emotion/styled';
  4. import color from 'color';
  5. import type {LineSeriesOption} from 'echarts';
  6. import moment from 'moment';
  7. import momentTimezone from 'moment-timezone';
  8. import type {Client} from 'sentry/api';
  9. import Feature from 'sentry/components/acl/feature';
  10. import {OnDemandMetricAlert} from 'sentry/components/alerts/onDemandMetricAlert';
  11. import {Button} from 'sentry/components/button';
  12. import type {AreaChartSeries} from 'sentry/components/charts/areaChart';
  13. import {AreaChart} from 'sentry/components/charts/areaChart';
  14. import ChartZoom from 'sentry/components/charts/chartZoom';
  15. import MarkArea from 'sentry/components/charts/components/markArea';
  16. import MarkLine from 'sentry/components/charts/components/markLine';
  17. import EventsRequest from 'sentry/components/charts/eventsRequest';
  18. import LineSeries from 'sentry/components/charts/series/lineSeries';
  19. import SessionsRequest from 'sentry/components/charts/sessionsRequest';
  20. import {
  21. ChartControls,
  22. HeaderTitleLegend,
  23. InlineContainer,
  24. SectionHeading,
  25. SectionValue,
  26. } from 'sentry/components/charts/styles';
  27. import {isEmptySeries} from 'sentry/components/charts/utils';
  28. import CircleIndicator from 'sentry/components/circleIndicator';
  29. import type {StatsPeriodType} from 'sentry/components/organizations/pageFilters/parse';
  30. import {parseStatsPeriod} from 'sentry/components/organizations/pageFilters/parse';
  31. import Panel from 'sentry/components/panels/panel';
  32. import PanelBody from 'sentry/components/panels/panelBody';
  33. import Placeholder from 'sentry/components/placeholder';
  34. import {Tooltip} from 'sentry/components/tooltip';
  35. import {IconCheckmark, IconClock, IconFire, IconWarning} from 'sentry/icons';
  36. import {t} from 'sentry/locale';
  37. import ConfigStore from 'sentry/stores/configStore';
  38. import {space} from 'sentry/styles/space';
  39. import type {DateString, Organization, Project} from 'sentry/types';
  40. import {ActivationConditionType, MonitorType} from 'sentry/types/alerts';
  41. import type {ReactEchartsRef, Series} from 'sentry/types/echarts';
  42. import toArray from 'sentry/utils/array/toArray';
  43. import {browserHistory} from 'sentry/utils/browserHistory';
  44. import {getUtcDateString} from 'sentry/utils/dates';
  45. import {DiscoverDatasets} from 'sentry/utils/discover/types';
  46. import getDuration from 'sentry/utils/duration/getDuration';
  47. import getDynamicText from 'sentry/utils/getDynamicText';
  48. import {getForceMetricsLayerQueryExtras} from 'sentry/utils/metrics/features';
  49. import {formatMRIField} from 'sentry/utils/metrics/mri';
  50. import {shouldShowOnDemandMetricAlertUI} from 'sentry/utils/onDemandMetrics/features';
  51. import {MINUTES_THRESHOLD_TO_DISPLAY_SECONDS} from 'sentry/utils/sessions';
  52. import {capitalize} from 'sentry/utils/string/capitalize';
  53. import theme from 'sentry/utils/theme';
  54. import {normalizeUrl} from 'sentry/utils/withDomainRequired';
  55. // eslint-disable-next-line no-restricted-imports
  56. import withSentryRouter from 'sentry/utils/withSentryRouter';
  57. import {COMPARISON_DELTA_OPTIONS} from 'sentry/views/alerts/rules/metric/constants';
  58. import {makeDefaultCta} from 'sentry/views/alerts/rules/metric/metricRulePresets';
  59. import type {MetricRule} from 'sentry/views/alerts/rules/metric/types';
  60. import {
  61. AlertRuleTriggerType,
  62. Dataset,
  63. TimePeriod,
  64. } from 'sentry/views/alerts/rules/metric/types';
  65. import {getChangeStatus} from 'sentry/views/alerts/utils/getChangeStatus';
  66. import {AlertWizardAlertNames} from 'sentry/views/alerts/wizard/options';
  67. import {getAlertTypeFromAggregateDataset} from 'sentry/views/alerts/wizard/utils';
  68. import type {Incident} from '../../../types';
  69. import {
  70. alertDetailsLink,
  71. alertTooltipValueFormatter,
  72. isSessionAggregate,
  73. SESSION_AGGREGATE_TO_FIELD,
  74. } from '../../../utils';
  75. import {getMetricDatasetQueryExtras} from '../utils/getMetricDatasetQueryExtras';
  76. import {isCrashFreeAlert} from '../utils/isCrashFreeAlert';
  77. import type {TimePeriodType} from './constants';
  78. import {
  79. getMetricAlertChartOption,
  80. transformSessionResponseToSeries,
  81. } from './metricChartOption';
  82. type Props = WithRouterProps & {
  83. api: Client;
  84. filter: string[] | null;
  85. interval: string;
  86. organization: Organization;
  87. project: Project;
  88. query: string;
  89. rule: MetricRule;
  90. timePeriod: TimePeriodType;
  91. incidents?: Incident[];
  92. isOnDemandAlert?: boolean;
  93. selectedIncident?: Incident | null;
  94. };
  95. type State = Record<string, never>;
  96. function formatTooltipDate(date: moment.MomentInput, format: string): string {
  97. const {
  98. options: {timezone},
  99. } = ConfigStore.get('user');
  100. return momentTimezone.tz(date, timezone).format(format);
  101. }
  102. function getRuleChangeSeries(
  103. rule: MetricRule,
  104. data: AreaChartSeries[]
  105. ): LineSeriesOption[] {
  106. const {dateModified} = rule;
  107. if (!data.length || !data[0].data.length || !dateModified) {
  108. return [];
  109. }
  110. const seriesData = data[0].data;
  111. const seriesStart = new Date(seriesData[0].name).getTime();
  112. const ruleChanged = new Date(dateModified).getTime();
  113. if (ruleChanged < seriesStart) {
  114. return [];
  115. }
  116. return [
  117. {
  118. type: 'line',
  119. markLine: MarkLine({
  120. silent: true,
  121. animation: false,
  122. lineStyle: {color: theme.gray200, type: 'solid', width: 1},
  123. data: [{xAxis: ruleChanged}],
  124. label: {
  125. show: false,
  126. },
  127. }),
  128. markArea: MarkArea({
  129. silent: true,
  130. itemStyle: {
  131. color: color(theme.gray100).alpha(0.42).rgb().string(),
  132. },
  133. data: [[{xAxis: seriesStart}, {xAxis: ruleChanged}]],
  134. }),
  135. data: [],
  136. },
  137. ];
  138. }
  139. function shouldUseErrorsDataset(dataset: Dataset, query: string): boolean {
  140. return dataset === Dataset.ERRORS && /\bis:unresolved\b/.test(query);
  141. }
  142. class MetricChart extends PureComponent<Props, State> {
  143. ref: null | ReactEchartsRef = null;
  144. handleZoom = (start: DateString, end: DateString) => {
  145. const {location} = this.props;
  146. browserHistory.push({
  147. pathname: location.pathname,
  148. query: {
  149. start,
  150. end,
  151. },
  152. });
  153. };
  154. renderChartActions(
  155. totalDuration: number,
  156. criticalDuration: number,
  157. warningDuration: number,
  158. waitingForDataDuration: number
  159. ) {
  160. const {rule, organization, project, timePeriod, query} = this.props;
  161. let dataset: DiscoverDatasets | undefined = undefined;
  162. if (shouldUseErrorsDataset(rule.dataset, query)) {
  163. dataset = DiscoverDatasets.ERRORS;
  164. }
  165. const {buttonText, ...props} = makeDefaultCta({
  166. orgSlug: organization.slug,
  167. projects: [project],
  168. rule,
  169. timePeriod,
  170. query,
  171. dataset,
  172. });
  173. const resolvedPercent =
  174. (100 *
  175. Math.max(
  176. totalDuration - waitingForDataDuration - criticalDuration - warningDuration,
  177. 0
  178. )) /
  179. totalDuration;
  180. const criticalPercent = 100 * Math.min(criticalDuration / totalDuration, 1);
  181. const warningPercent = 100 * Math.min(warningDuration / totalDuration, 1);
  182. const waitingForDataPercent =
  183. 100 *
  184. Math.min(
  185. (waitingForDataDuration - criticalDuration - warningDuration) / totalDuration,
  186. 1
  187. );
  188. return (
  189. <StyledChartControls>
  190. <StyledInlineContainer>
  191. <Fragment>
  192. <SectionHeading>{t('Summary')}</SectionHeading>
  193. <StyledSectionValue>
  194. <ValueItem>
  195. <IconCheckmark color="successText" isCircled />
  196. {resolvedPercent ? resolvedPercent.toFixed(2) : 0}%
  197. </ValueItem>
  198. <ValueItem>
  199. <IconWarning color="warningText" />
  200. {warningPercent ? warningPercent.toFixed(2) : 0}%
  201. </ValueItem>
  202. <ValueItem>
  203. <IconFire color="errorText" />
  204. {criticalPercent ? criticalPercent.toFixed(2) : 0}%
  205. </ValueItem>
  206. {waitingForDataPercent > 0 && (
  207. <StyledTooltip
  208. underlineColor="gray200"
  209. showUnderline
  210. title={t(
  211. 'The time spent waiting for metrics matching the filters used.'
  212. )}
  213. >
  214. <ValueItem>
  215. <IconClock />
  216. {waitingForDataPercent.toFixed(2)}%
  217. </ValueItem>
  218. </StyledTooltip>
  219. )}
  220. </StyledSectionValue>
  221. </Fragment>
  222. </StyledInlineContainer>
  223. {!isSessionAggregate(rule.aggregate) && (
  224. <Feature features="discover-basic">
  225. <Button size="sm" {...props}>
  226. {buttonText}
  227. </Button>
  228. </Feature>
  229. )}
  230. </StyledChartControls>
  231. );
  232. }
  233. renderChart(
  234. loading: boolean,
  235. timeseriesData?: Series[],
  236. minutesThresholdToDisplaySeconds?: number,
  237. comparisonTimeseriesData?: Series[]
  238. ) {
  239. const {
  240. router,
  241. selectedIncident,
  242. interval,
  243. filter,
  244. incidents,
  245. rule,
  246. organization,
  247. timePeriod: {start, end},
  248. } = this.props;
  249. const {dateModified, timeWindow} = rule;
  250. if (loading || !timeseriesData) {
  251. return this.renderEmpty();
  252. }
  253. const handleIncidentClick = (incident: Incident) => {
  254. router.push(
  255. normalizeUrl({
  256. pathname: alertDetailsLink(organization, incident),
  257. query: {alert: incident.identifier},
  258. })
  259. );
  260. };
  261. const {
  262. criticalDuration,
  263. warningDuration,
  264. totalDuration,
  265. waitingForDataDuration,
  266. chartOption,
  267. } = getMetricAlertChartOption({
  268. timeseriesData,
  269. rule,
  270. incidents,
  271. selectedIncident,
  272. showWaitingForData:
  273. shouldShowOnDemandMetricAlertUI(organization) && this.props.isOnDemandAlert,
  274. handleIncidentClick,
  275. });
  276. const comparisonSeriesName = capitalize(
  277. COMPARISON_DELTA_OPTIONS.find(({value}) => value === rule.comparisonDelta)?.label ||
  278. ''
  279. );
  280. const additionalSeries: LineSeriesOption[] = [
  281. ...(comparisonTimeseriesData || []).map(({data: _data, ...otherSeriesProps}) =>
  282. LineSeries({
  283. name: comparisonSeriesName,
  284. data: _data.map(({name, value}) => [name, value]),
  285. lineStyle: {color: theme.gray200, type: 'dashed', width: 1},
  286. itemStyle: {color: theme.gray200},
  287. animation: false,
  288. animationThreshold: 1,
  289. animationDuration: 0,
  290. ...otherSeriesProps,
  291. })
  292. ),
  293. ...getRuleChangeSeries(rule, timeseriesData),
  294. ];
  295. const queryFilter =
  296. filter?.join(' ') + t(' over ') + getDuration(rule.timeWindow * 60);
  297. return (
  298. <ChartPanel>
  299. <StyledPanelBody withPadding>
  300. <ChartHeader>
  301. <HeaderTitleLegend>
  302. {AlertWizardAlertNames[getAlertTypeFromAggregateDataset(rule)]}
  303. </HeaderTitleLegend>
  304. </ChartHeader>
  305. <ChartFilters>
  306. <StyledCircleIndicator size={8} />
  307. <Filters>{formatMRIField(rule.aggregate)}</Filters>
  308. <Tooltip
  309. title={queryFilter}
  310. isHoverable
  311. skipWrapper
  312. overlayStyle={{maxWidth: '90vw', lineBreak: 'anywhere', textAlign: 'left'}}
  313. showOnlyOnOverflow
  314. >
  315. <QueryFilters>{queryFilter}</QueryFilters>
  316. </Tooltip>
  317. </ChartFilters>
  318. {getDynamicText({
  319. value: (
  320. <ChartZoom
  321. router={router}
  322. start={start}
  323. end={end}
  324. onZoom={zoomArgs => this.handleZoom(zoomArgs.start, zoomArgs.end)}
  325. >
  326. {zoomRenderProps => (
  327. <AreaChart
  328. {...zoomRenderProps}
  329. {...chartOption}
  330. showTimeInTooltip
  331. minutesThresholdToDisplaySeconds={minutesThresholdToDisplaySeconds}
  332. additionalSeries={additionalSeries}
  333. tooltip={{
  334. formatter: seriesParams => {
  335. // seriesParams can be object instead of array
  336. const pointSeries = toArray(seriesParams);
  337. const {marker, data: pointData, seriesName} = pointSeries[0];
  338. const [pointX, pointY] = pointData as [number, number];
  339. const pointYFormatted = alertTooltipValueFormatter(
  340. pointY,
  341. seriesName ?? '',
  342. rule.aggregate
  343. );
  344. const isModified =
  345. dateModified && pointX <= new Date(dateModified).getTime();
  346. const startTime = formatTooltipDate(moment(pointX), 'MMM D LT');
  347. const {period, periodLength} = parseStatsPeriod(interval) ?? {
  348. periodLength: 'm',
  349. period: `${timeWindow}`,
  350. };
  351. const endTime = formatTooltipDate(
  352. moment(pointX).add(
  353. parseInt(period, 10),
  354. periodLength as StatsPeriodType
  355. ),
  356. 'MMM D LT'
  357. );
  358. const comparisonSeries =
  359. pointSeries.length > 1
  360. ? pointSeries.find(
  361. ({seriesName: _sn}) => _sn === comparisonSeriesName
  362. )
  363. : undefined;
  364. const comparisonPointY = comparisonSeries?.data[1] as
  365. | number
  366. | undefined;
  367. const comparisonPointYFormatted =
  368. comparisonPointY !== undefined
  369. ? alertTooltipValueFormatter(
  370. comparisonPointY,
  371. seriesName ?? '',
  372. rule.aggregate
  373. )
  374. : undefined;
  375. const changePercentage =
  376. comparisonPointY === undefined
  377. ? NaN
  378. : ((pointY - comparisonPointY) * 100) / comparisonPointY;
  379. const changeStatus = getChangeStatus(
  380. changePercentage,
  381. rule.thresholdType,
  382. rule.triggers
  383. );
  384. const changeStatusColor =
  385. changeStatus === AlertRuleTriggerType.CRITICAL
  386. ? theme.red300
  387. : changeStatus === AlertRuleTriggerType.WARNING
  388. ? theme.yellow300
  389. : theme.green300;
  390. return [
  391. `<div class="tooltip-series">`,
  392. isModified &&
  393. `<div><span class="tooltip-label"><strong>${t(
  394. 'Alert Rule Modified'
  395. )}</strong></span></div>`,
  396. `<div><span class="tooltip-label">${marker} <strong>${seriesName}</strong></span>${pointYFormatted}</div>`,
  397. comparisonSeries &&
  398. `<div><span class="tooltip-label">${comparisonSeries.marker} <strong>${comparisonSeriesName}</strong></span>${comparisonPointYFormatted}</div>`,
  399. `</div>`,
  400. `<div class="tooltip-footer">`,
  401. `<span>${startTime} &mdash; ${endTime}</span>`,
  402. comparisonPointY !== undefined &&
  403. Math.abs(changePercentage) !== Infinity &&
  404. !isNaN(changePercentage) &&
  405. `<span style="color:${changeStatusColor};margin-left:10px;">${
  406. Math.sign(changePercentage) === 1 ? '+' : '-'
  407. }${Math.abs(changePercentage).toFixed(2)}%</span>`,
  408. `</div>`,
  409. '<div class="tooltip-arrow"></div>',
  410. ]
  411. .filter(e => e)
  412. .join('');
  413. },
  414. }}
  415. />
  416. )}
  417. </ChartZoom>
  418. ),
  419. fixed: <Placeholder height="200px" testId="skeleton-ui" />,
  420. })}
  421. </StyledPanelBody>
  422. {this.renderChartActions(
  423. totalDuration,
  424. criticalDuration,
  425. warningDuration,
  426. waitingForDataDuration
  427. )}
  428. </ChartPanel>
  429. );
  430. }
  431. renderEmptyOnDemandAlert(
  432. organization: Organization,
  433. timeseriesData: Series[] = [],
  434. loading?: boolean
  435. ) {
  436. if (
  437. loading ||
  438. !this.props.isOnDemandAlert ||
  439. !shouldShowOnDemandMetricAlertUI(organization) ||
  440. !isEmptySeries(timeseriesData[0])
  441. ) {
  442. return null;
  443. }
  444. return (
  445. <OnDemandMetricAlert
  446. dismissable
  447. message={t(
  448. 'This alert lacks historical data due to filters for which we don’t routinely extract metrics.'
  449. )}
  450. />
  451. );
  452. }
  453. renderEmpty(placeholderText = '') {
  454. return (
  455. <ChartPanel>
  456. <PanelBody withPadding>
  457. <TriggerChartPlaceholder>{placeholderText}</TriggerChartPlaceholder>
  458. </PanelBody>
  459. </ChartPanel>
  460. );
  461. }
  462. render() {
  463. const {
  464. api,
  465. rule,
  466. organization,
  467. timePeriod,
  468. project,
  469. interval,
  470. query,
  471. location,
  472. isOnDemandAlert,
  473. selectedIncident,
  474. } = this.props;
  475. const {aggregate, timeWindow, environment, dataset} = rule;
  476. // Fix for 7 days * 1m interval being over the max number of results from events api
  477. // 10k events is the current max
  478. if (
  479. timePeriod.usingPeriod &&
  480. timePeriod.period === TimePeriod.SEVEN_DAYS &&
  481. interval === '1m'
  482. ) {
  483. timePeriod.start = getUtcDateString(
  484. // -5 minutes provides a small cushion for rounding up minutes. This might be able to be smaller
  485. moment(moment.utc(timePeriod.end).subtract(10000 - 5, 'minutes'))
  486. );
  487. }
  488. // If the chart duration isn't as long as the rollup duration the events-stats
  489. // endpoint will return an invalid timeseriesData dataset
  490. const viableStartDate = getUtcDateString(
  491. moment.min(
  492. moment.utc(timePeriod.start),
  493. moment.utc(timePeriod.end).subtract(timeWindow, 'minutes')
  494. )
  495. );
  496. const viableEndDate = getUtcDateString(
  497. moment.utc(timePeriod.end).add(timeWindow, 'minutes')
  498. );
  499. let activationFilter = '';
  500. if (
  501. rule.monitorType === MonitorType.ACTIVATED &&
  502. selectedIncident &&
  503. selectedIncident.activation
  504. ) {
  505. const {activation} = selectedIncident;
  506. const {activator, conditionType} = activation;
  507. switch (conditionType) {
  508. case String(ActivationConditionType.RELEASE_CREATION):
  509. activationFilter = ` AND (release:${activator})`;
  510. break;
  511. case String(ActivationConditionType.DEPLOY_CREATION):
  512. activationFilter = ` AND (deploy:${activator})`;
  513. break;
  514. default:
  515. break;
  516. }
  517. }
  518. const queryExtras: Record<string, string> = {
  519. ...getMetricDatasetQueryExtras({
  520. organization,
  521. location,
  522. dataset,
  523. newAlertOrQuery: false,
  524. useOnDemandMetrics: isOnDemandAlert,
  525. }),
  526. ...getForceMetricsLayerQueryExtras(organization, dataset),
  527. };
  528. if (shouldUseErrorsDataset(dataset, query)) {
  529. queryExtras.dataset = 'errors';
  530. }
  531. return isCrashFreeAlert(dataset) ? (
  532. <SessionsRequest
  533. api={api}
  534. organization={organization}
  535. project={project.id ? [Number(project.id)] : []}
  536. environment={environment ? [environment] : undefined}
  537. start={viableStartDate}
  538. end={viableEndDate}
  539. query={query + activationFilter}
  540. interval={interval}
  541. field={SESSION_AGGREGATE_TO_FIELD[aggregate]}
  542. groupBy={['session.status']}
  543. >
  544. {({loading, response}) =>
  545. this.renderChart(
  546. loading,
  547. transformSessionResponseToSeries(response, rule),
  548. MINUTES_THRESHOLD_TO_DISPLAY_SECONDS
  549. )
  550. }
  551. </SessionsRequest>
  552. ) : (
  553. <EventsRequest
  554. api={api}
  555. organization={organization}
  556. query={query + activationFilter}
  557. environment={environment ? [environment] : undefined}
  558. project={project.id ? [Number(project.id)] : []}
  559. interval={interval}
  560. comparisonDelta={rule.comparisonDelta ? rule.comparisonDelta * 60 : undefined}
  561. start={viableStartDate}
  562. end={viableEndDate}
  563. yAxis={aggregate}
  564. includePrevious={false}
  565. currentSeriesNames={[aggregate]}
  566. partial={false}
  567. queryExtras={queryExtras}
  568. referrer="api.alerts.alert-rule-chart"
  569. useOnDemandMetrics
  570. >
  571. {({loading, timeseriesData, comparisonTimeseriesData}) => (
  572. <Fragment>
  573. {this.renderEmptyOnDemandAlert(organization, timeseriesData, loading)}
  574. {this.renderChart(
  575. loading,
  576. timeseriesData,
  577. undefined,
  578. comparisonTimeseriesData
  579. )}
  580. </Fragment>
  581. )}
  582. </EventsRequest>
  583. );
  584. }
  585. }
  586. export default withSentryRouter(MetricChart);
  587. const ChartPanel = styled(Panel)`
  588. margin-top: ${space(2)};
  589. `;
  590. const ChartHeader = styled('div')`
  591. margin-bottom: ${space(3)};
  592. `;
  593. const StyledChartControls = styled(ChartControls)`
  594. display: flex;
  595. justify-content: space-between;
  596. flex-wrap: wrap;
  597. `;
  598. const StyledInlineContainer = styled(InlineContainer)`
  599. grid-auto-flow: column;
  600. grid-column-gap: ${space(1)};
  601. `;
  602. const StyledCircleIndicator = styled(CircleIndicator)`
  603. background: ${p => p.theme.formText};
  604. height: ${space(1)};
  605. margin-right: ${space(0.5)};
  606. `;
  607. const ChartFilters = styled('div')`
  608. font-size: ${p => p.theme.fontSizeSmall};
  609. font-family: ${p => p.theme.text.family};
  610. color: ${p => p.theme.textColor};
  611. display: inline-grid;
  612. grid-template-columns: max-content max-content auto;
  613. align-items: center;
  614. `;
  615. const Filters = styled('span')`
  616. margin-right: ${space(1)};
  617. `;
  618. const QueryFilters = styled('span')`
  619. min-width: 0px;
  620. ${p => p.theme.overflowEllipsis}
  621. `;
  622. const StyledSectionValue = styled(SectionValue)`
  623. display: grid;
  624. grid-template-columns: repeat(4, auto);
  625. gap: ${space(1.5)};
  626. margin: 0 0 0 ${space(1.5)};
  627. `;
  628. const ValueItem = styled('div')`
  629. display: grid;
  630. grid-template-columns: repeat(2, auto);
  631. gap: ${space(0.5)};
  632. align-items: center;
  633. font-variant-numeric: tabular-nums;
  634. text-underline-offset: ${space(4)};
  635. `;
  636. /* Override padding to make chart appear centered */
  637. const StyledPanelBody = styled(PanelBody)`
  638. padding-right: 6px;
  639. `;
  640. const TriggerChartPlaceholder = styled(Placeholder)`
  641. height: 200px;
  642. text-align: center;
  643. padding: ${space(3)};
  644. `;
  645. const StyledTooltip = styled(Tooltip)`
  646. text-underline-offset: ${space(0.5)} !important;
  647. `;