metricChart.tsx 23 KB

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