onDemandMetricAlert.tsx 823 B

123456789101112131415161718192021222324
  1. import {AggregationKey} from 'sentry/utils/fields';
  2. import {isOnDemandQueryString} from 'sentry/utils/onDemandMetrics';
  3. import {Dataset} from 'sentry/views/alerts/rules/metric/types';
  4. export function isValidOnDemandMetricAlert(
  5. dataset: Dataset,
  6. aggregate: string,
  7. query: string
  8. ): boolean {
  9. if (!isOnDemandMetricAlert(dataset, query)) {
  10. return true;
  11. }
  12. // On demand metric alerts do not support generic percentile aggregations
  13. return !aggregate.includes(AggregationKey.PERCENTILE);
  14. }
  15. /**
  16. * We determine that an alert is an on-demand metric alert if the query contains
  17. * one of the tags that are not supported by the standard metrics.
  18. */
  19. export function isOnDemandMetricAlert(dataset: Dataset, query: string): boolean {
  20. return dataset === Dataset.GENERIC_METRICS && isOnDemandQueryString(query);
  21. }