onDemandMetricAlert.tsx 772 B

12345678910111213141516171819202122
  1. import {isOnDemandAggregate, isOnDemandQueryString} from 'sentry/utils/onDemandMetrics';
  2. import {Dataset} from 'sentry/views/alerts/rules/metric/types';
  3. import {isCustomMetricField} from 'sentry/views/alerts/rules/metric/utils/isCustomMetricField';
  4. /**
  5. * We determine that an alert is an on-demand metric alert if the query contains
  6. * one of the tags that are not supported by the standard metrics.
  7. */
  8. export function isOnDemandMetricAlert(
  9. dataset: Dataset,
  10. aggregate: string,
  11. query: string
  12. ): boolean {
  13. if (isOnDemandAggregate(aggregate)) {
  14. return true;
  15. }
  16. // TODO: extend to also support other MRI use-cases
  17. if (isCustomMetricField(aggregate)) {
  18. return false;
  19. }
  20. return dataset === Dataset.GENERIC_METRICS && isOnDemandQueryString(query);
  21. }