onDemandMetricAlert.tsx 890 B

1234567891011121314151617181920212223242526272829
  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. const unsupportedAggregates = [
  13. AggregationKey.PERCENTILE,
  14. AggregationKey.APDEX,
  15. AggregationKey.FAILURE_RATE,
  16. ];
  17. return !unsupportedAggregates.some(agg => aggregate.includes(agg));
  18. }
  19. /**
  20. * We determine that an alert is an on-demand metric alert if the query contains
  21. * one of the tags that are not supported by the standard metrics.
  22. */
  23. export function isOnDemandMetricAlert(dataset: Dataset, query: string): boolean {
  24. return dataset === Dataset.GENERIC_METRICS && isOnDemandQueryString(query);
  25. }