Search in sources :

Example 1 with AnomalyDetectorJob

use of org.opensearch.ad.model.AnomalyDetectorJob in project anomaly-detection by opensearch-project.

the class EntityColdStarter method getEntityColdStartData.

/**
 * Get training data for an entity.
 *
 * We first note the maximum and minimum timestamp, and sample at most 24 points
 * (with 60 points apart between two neighboring samples) between those minimum
 * and maximum timestamps.  Samples can be missing.  We only interpolate points
 * between present neighboring samples. We then transform samples and interpolate
 * points to shingles. Finally, full shingles will be used for cold start.
 *
 * @param detectorId detector Id
 * @param entity the entity's information
 * @param listener listener to return training data
 */
private void getEntityColdStartData(String detectorId, Entity entity, ActionListener<Optional<List<double[][]>>> listener) {
    ActionListener<Optional<AnomalyDetector>> getDetectorListener = ActionListener.wrap(detectorOp -> {
        if (!detectorOp.isPresent()) {
            listener.onFailure(new EndRunException(detectorId, "AnomalyDetector is not available.", false));
            return;
        }
        List<double[][]> coldStartData = new ArrayList<>();
        AnomalyDetector detector = detectorOp.get();
        ActionListener<Optional<Long>> minTimeListener = ActionListener.wrap(earliest -> {
            if (earliest.isPresent()) {
                long startTimeMs = earliest.get().longValue();
                nodeStateManager.getAnomalyDetectorJob(detectorId, ActionListener.wrap(jobOp -> {
                    if (!jobOp.isPresent()) {
                        listener.onFailure(new EndRunException(detectorId, "AnomalyDetector job is not available.", false));
                        return;
                    }
                    AnomalyDetectorJob job = jobOp.get();
                    // End time uses milliseconds as start time is assumed to be in milliseconds.
                    // Opensearch uses a set of preconfigured formats to recognize and parse these strings into a long value
                    // representing milliseconds-since-the-epoch in UTC.
                    // More on https://tinyurl.com/wub4fk92
                    // Existing samples either predates or coincide with cold start data. In either case,
                    // combining them without reordering based on time stamps is not ok. We might introduce
                    // anomalies in the process.
                    // An ideal solution would be to record time stamps of data points and combine existing
                    // samples and cold start samples and do interpolation afterwards. Recording time stamps
                    // requires changes across the board like bwc in checkpoints. A pragmatic solution is to use
                    // job enabled time as the end time of cold start period as it is easier to combine
                    // existing samples with cold start data. We just need to appends existing samples after
                    // cold start data as existing samples all happen after job enabled time. There might
                    // be some gaps in between the last cold start sample and the first accumulated sample.
                    // We will need to accept that precision loss in current solution.
                    long endTimeMs = job.getEnabledTime().toEpochMilli();
                    Pair<Integer, Integer> params = selectRangeParam(detector);
                    int stride = params.getLeft();
                    int numberOfSamples = params.getRight();
                    // we start with round 0
                    getFeatures(listener, 0, coldStartData, detector, entity, stride, numberOfSamples, startTimeMs, endTimeMs);
                }, listener::onFailure));
            } else {
                listener.onResponse(Optional.empty());
            }
        }, listener::onFailure);
        searchFeatureDao.getEntityMinDataTime(detector, entity, new ThreadedActionListener<>(logger, threadPool, AnomalyDetectorPlugin.AD_THREAD_POOL_NAME, minTimeListener, false));
    }, listener::onFailure);
    nodeStateManager.getAnomalyDetector(detectorId, new ThreadedActionListener<>(logger, threadPool, AnomalyDetectorPlugin.AD_THREAD_POOL_NAME, getDetectorListener, false));
}
Also used : Arrays(java.util.Arrays) Precision(com.amazon.randomcutforest.config.Precision) RequestPriority(org.opensearch.ad.ratelimit.RequestPriority) ThreadPool(org.opensearch.threadpool.ThreadPool) SimpleImmutableEntry(java.util.AbstractMap.SimpleImmutableEntry) ThreadedActionListener(org.opensearch.action.support.ThreadedActionListener) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) AnomalyDetectorSettings(org.opensearch.ad.settings.AnomalyDetectorSettings) ArrayList(java.util.ArrayList) AnomalyDetectionException(org.opensearch.ad.common.exception.AnomalyDetectionException) Throwables(org.apache.logging.log4j.core.util.Throwables) DoorKeeper(org.opensearch.ad.caching.DoorKeeper) Pair(org.apache.commons.lang3.tuple.Pair) Duration(java.time.Duration) Map(java.util.Map) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) ActionListener(org.opensearch.action.ActionListener) EndRunException(org.opensearch.ad.common.exception.EndRunException) Interpolator(org.opensearch.ad.dataprocessor.Interpolator) COOLDOWN_MINUTES(org.opensearch.ad.settings.AnomalyDetectorSettings.COOLDOWN_MINUTES) FeatureManager(org.opensearch.ad.feature.FeatureManager) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Settings(org.opensearch.common.settings.Settings) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) MaintenanceState(org.opensearch.ad.MaintenanceState) List(java.util.List) Stream(java.util.stream.Stream) Logger(org.apache.logging.log4j.Logger) ExceptionUtil(org.opensearch.ad.util.ExceptionUtil) Entity(org.opensearch.ad.model.Entity) NodeStateManager(org.opensearch.ad.NodeStateManager) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) ThresholdedRandomCutForest(com.amazon.randomcutforest.parkservices.ThresholdedRandomCutForest) Entry(java.util.Map.Entry) SearchFeatureDao(org.opensearch.ad.feature.SearchFeatureDao) Clock(java.time.Clock) Optional(java.util.Optional) AnomalyDetectorPlugin(org.opensearch.ad.AnomalyDetectorPlugin) Queue(java.util.Queue) ArrayDeque(java.util.ArrayDeque) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) LogManager(org.apache.logging.log4j.LogManager) CheckpointWriteWorker(org.opensearch.ad.ratelimit.CheckpointWriteWorker) EndRunException(org.opensearch.ad.common.exception.EndRunException) Optional(java.util.Optional) ArrayList(java.util.ArrayList) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) Pair(org.apache.commons.lang3.tuple.Pair)

Example 2 with AnomalyDetectorJob

use of org.opensearch.ad.model.AnomalyDetectorJob in project anomaly-detection by opensearch-project.

the class ADDataMigrator method backfillRealtimeTask.

/**
 * Backfill realtiem task for realtime job.
 * @param detectorJobs realtime AD jobs
 * @param backfillAllJob backfill task for all realtime job or not
 */
public void backfillRealtimeTask(ConcurrentLinkedQueue<AnomalyDetectorJob> detectorJobs, boolean backfillAllJob) {
    AnomalyDetectorJob job = detectorJobs.poll();
    if (job == null) {
        logger.info("AD data migration done.");
        if (backfillAllJob) {
            this.dataMigrated.set(true);
        }
        return;
    }
    String jobId = job.getName();
    AnomalyDetectorFunction createRealtimeTaskFunction = () -> {
        GetRequest getRequest = new GetRequest(DETECTION_STATE_INDEX, jobId);
        client.get(getRequest, ActionListener.wrap(r -> {
            if (r != null && r.isExists()) {
                try (XContentParser parser = createXContentParserFromRegistry(xContentRegistry, r.getSourceAsBytesRef())) {
                    ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
                    DetectorInternalState detectorState = DetectorInternalState.parse(parser);
                    createRealtimeADTask(job, detectorState.getError(), detectorJobs, backfillAllJob);
                } catch (IOException e) {
                    logger.error("Failed to parse detector internal state " + jobId, e);
                    createRealtimeADTask(job, null, detectorJobs, backfillAllJob);
                }
            } else {
                createRealtimeADTask(job, null, detectorJobs, backfillAllJob);
            }
        }, e -> {
            logger.error("Failed to query detector internal state " + jobId, e);
            createRealtimeADTask(job, null, detectorJobs, backfillAllJob);
        }));
    };
    checkIfRealtimeTaskExistsAndBackfill(job, createRealtimeTaskFunction, detectorJobs, backfillAllJob);
}
Also used : GetRequest(org.opensearch.action.get.GetRequest) DetectorInternalState(org.opensearch.ad.model.DetectorInternalState) ADTaskType.taskTypeToString(org.opensearch.ad.model.ADTaskType.taskTypeToString) IOException(java.io.IOException) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) AnomalyDetectorFunction(org.opensearch.ad.rest.handler.AnomalyDetectorFunction) XContentParser(org.opensearch.common.xcontent.XContentParser)

Example 3 with AnomalyDetectorJob

use of org.opensearch.ad.model.AnomalyDetectorJob in project anomaly-detection by opensearch-project.

the class ADDataMigrator method checkIfRealtimeTaskExistsAndBackfill.

private void checkIfRealtimeTaskExistsAndBackfill(AnomalyDetectorJob job, AnomalyDetectorFunction createRealtimeTaskFunction, ConcurrentLinkedQueue<AnomalyDetectorJob> detectorJobs, boolean migrateAll) {
    String jobId = job.getName();
    BoolQueryBuilder query = new BoolQueryBuilder();
    query.filter(new TermQueryBuilder(DETECTOR_ID_FIELD, jobId));
    if (job.isEnabled()) {
        query.filter(new TermQueryBuilder(IS_LATEST_FIELD, true));
    }
    query.filter(new TermsQueryBuilder(TASK_TYPE_FIELD, taskTypeToString(ADTaskType.REALTIME_TASK_TYPES)));
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(query).size(1);
    SearchRequest searchRequest = new SearchRequest(DETECTION_STATE_INDEX).source(searchSourceBuilder);
    client.search(searchRequest, ActionListener.wrap(r -> {
        if (r != null && r.getHits().getTotalHits().value > 0) {
            // Backfill next realtime job
            backfillRealtimeTask(detectorJobs, migrateAll);
            return;
        }
        createRealtimeTaskFunction.execute();
    }, e -> {
        if (e instanceof ResourceNotFoundException) {
            createRealtimeTaskFunction.execute();
        }
        logger.error("Failed to search tasks of detector " + jobId);
    }));
}
Also used : ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) ADTask(org.opensearch.ad.model.ADTask) MAX_DETECTOR_UPPER_LIMIT(org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_DETECTOR_UPPER_LIMIT) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ADTaskType.taskTypeToString(org.opensearch.ad.model.ADTaskType.taskTypeToString) ADTaskState(org.opensearch.ad.model.ADTaskState) XCONTENT_WITH_TYPE(org.opensearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE) AnomalyDetectorFunction(org.opensearch.ad.rest.handler.AnomalyDetectorFunction) XContentParser(org.opensearch.common.xcontent.XContentParser) WriteRequest(org.opensearch.action.support.WriteRequest) ANOMALY_DETECTOR_JOB_INDEX(org.opensearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX) DETECTOR_ID_FIELD(org.opensearch.ad.model.ADTask.DETECTOR_ID_FIELD) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) XContentFactory(org.opensearch.common.xcontent.XContentFactory) SearchRequest(org.opensearch.action.search.SearchRequest) ActionListener(org.opensearch.action.ActionListener) Client(org.opensearch.client.Client) CommonName(org.opensearch.ad.constant.CommonName) RestHandlerUtils.createXContentParserFromRegistry(org.opensearch.ad.util.RestHandlerUtils.createXContentParserFromRegistry) Iterator(java.util.Iterator) SearchHit(org.opensearch.search.SearchHit) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) ANOMALY_DETECTORS_INDEX(org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX) GetRequest(org.opensearch.action.get.GetRequest) ExceptionsHelper(org.opensearch.ExceptionsHelper) ADTaskType(org.opensearch.ad.model.ADTaskType) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) IOException(java.io.IOException) AnomalyDetectionIndices(org.opensearch.ad.indices.AnomalyDetectionIndices) IS_LATEST_FIELD(org.opensearch.ad.model.ADTask.IS_LATEST_FIELD) DETECTION_STATE_INDEX(org.opensearch.ad.constant.CommonName.DETECTION_STATE_INDEX) Instant(java.time.Instant) TASK_TYPE_FIELD(org.opensearch.ad.model.ADTask.TASK_TYPE_FIELD) Logger(org.apache.logging.log4j.Logger) ExceptionUtil(org.opensearch.ad.util.ExceptionUtil) DetectorInternalState(org.opensearch.ad.model.DetectorInternalState) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ClusterService(org.opensearch.cluster.service.ClusterService) ResourceAlreadyExistsException(org.opensearch.ResourceAlreadyExistsException) TermsQueryBuilder(org.opensearch.index.query.TermsQueryBuilder) IndexRequest(org.opensearch.action.index.IndexRequest) MatchAllQueryBuilder(org.opensearch.index.query.MatchAllQueryBuilder) LogManager(org.apache.logging.log4j.LogManager) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) SearchRequest(org.opensearch.action.search.SearchRequest) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) TermsQueryBuilder(org.opensearch.index.query.TermsQueryBuilder) ADTaskType.taskTypeToString(org.opensearch.ad.model.ADTaskType.taskTypeToString) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder)

Example 4 with AnomalyDetectorJob

use of org.opensearch.ad.model.AnomalyDetectorJob in project anomaly-detection by opensearch-project.

the class ADDataMigrator method migrateDetectorInternalStateToRealtimeTask.

/**
 * Migrate detector internal state to realtime task.
 */
public void migrateDetectorInternalStateToRealtimeTask() {
    SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().query(new MatchAllQueryBuilder()).size(MAX_DETECTOR_UPPER_LIMIT);
    SearchRequest searchRequest = new SearchRequest(ANOMALY_DETECTOR_JOB_INDEX).source(searchSourceBuilder);
    client.search(searchRequest, ActionListener.wrap(r -> {
        if (r == null || r.getHits().getTotalHits() == null || r.getHits().getTotalHits().value == 0) {
            logger.info("No anomaly detector job found, no need to migrate");
            return;
        }
        ConcurrentLinkedQueue<AnomalyDetectorJob> detectorJobs = new ConcurrentLinkedQueue<>();
        Iterator<SearchHit> iterator = r.getHits().iterator();
        while (iterator.hasNext()) {
            SearchHit searchHit = iterator.next();
            try (XContentParser parser = createXContentParserFromRegistry(xContentRegistry, searchHit.getSourceRef())) {
                ensureExpectedToken(XContentParser.Token.START_OBJECT, parser.nextToken(), parser);
                AnomalyDetectorJob job = AnomalyDetectorJob.parse(parser);
                detectorJobs.add(job);
            } catch (IOException e) {
                logger.error("Fail to parse AD job " + searchHit.getId(), e);
            }
        }
        logger.info("Total AD jobs to backfill realtime task: {}", detectorJobs.size());
        backfillRealtimeTask(detectorJobs, true);
    }, e -> {
        if (ExceptionUtil.getErrorMessage(e).contains("all shards failed")) {
            // This error may happen when AD job index not ready for query as some nodes not in cluster yet.
            // Will recreate realtime task when AD job starts.
            logger.warn("No available shards of AD job index, reset dataMigrated as false");
            this.dataMigrated.set(false);
        } else if (!(e instanceof IndexNotFoundException)) {
            logger.error("Failed to migrate AD data", e);
        }
    }));
}
Also used : ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) ADTask(org.opensearch.ad.model.ADTask) MAX_DETECTOR_UPPER_LIMIT(org.opensearch.ad.settings.AnomalyDetectorSettings.MAX_DETECTOR_UPPER_LIMIT) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ADTaskType.taskTypeToString(org.opensearch.ad.model.ADTaskType.taskTypeToString) ADTaskState(org.opensearch.ad.model.ADTaskState) XCONTENT_WITH_TYPE(org.opensearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE) AnomalyDetectorFunction(org.opensearch.ad.rest.handler.AnomalyDetectorFunction) XContentParser(org.opensearch.common.xcontent.XContentParser) WriteRequest(org.opensearch.action.support.WriteRequest) ANOMALY_DETECTOR_JOB_INDEX(org.opensearch.ad.model.AnomalyDetectorJob.ANOMALY_DETECTOR_JOB_INDEX) DETECTOR_ID_FIELD(org.opensearch.ad.model.ADTask.DETECTOR_ID_FIELD) AnomalyDetector(org.opensearch.ad.model.AnomalyDetector) XContentFactory(org.opensearch.common.xcontent.XContentFactory) SearchRequest(org.opensearch.action.search.SearchRequest) ActionListener(org.opensearch.action.ActionListener) Client(org.opensearch.client.Client) CommonName(org.opensearch.ad.constant.CommonName) RestHandlerUtils.createXContentParserFromRegistry(org.opensearch.ad.util.RestHandlerUtils.createXContentParserFromRegistry) Iterator(java.util.Iterator) SearchHit(org.opensearch.search.SearchHit) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) ANOMALY_DETECTORS_INDEX(org.opensearch.ad.model.AnomalyDetector.ANOMALY_DETECTORS_INDEX) GetRequest(org.opensearch.action.get.GetRequest) ExceptionsHelper(org.opensearch.ExceptionsHelper) ADTaskType(org.opensearch.ad.model.ADTaskType) TermQueryBuilder(org.opensearch.index.query.TermQueryBuilder) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) IOException(java.io.IOException) AnomalyDetectionIndices(org.opensearch.ad.indices.AnomalyDetectionIndices) IS_LATEST_FIELD(org.opensearch.ad.model.ADTask.IS_LATEST_FIELD) DETECTION_STATE_INDEX(org.opensearch.ad.constant.CommonName.DETECTION_STATE_INDEX) Instant(java.time.Instant) TASK_TYPE_FIELD(org.opensearch.ad.model.ADTask.TASK_TYPE_FIELD) Logger(org.apache.logging.log4j.Logger) ExceptionUtil(org.opensearch.ad.util.ExceptionUtil) DetectorInternalState(org.opensearch.ad.model.DetectorInternalState) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ClusterService(org.opensearch.cluster.service.ClusterService) ResourceAlreadyExistsException(org.opensearch.ResourceAlreadyExistsException) TermsQueryBuilder(org.opensearch.index.query.TermsQueryBuilder) IndexRequest(org.opensearch.action.index.IndexRequest) MatchAllQueryBuilder(org.opensearch.index.query.MatchAllQueryBuilder) LogManager(org.apache.logging.log4j.LogManager) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) BoolQueryBuilder(org.opensearch.index.query.BoolQueryBuilder) SearchRequest(org.opensearch.action.search.SearchRequest) SearchHit(org.opensearch.search.SearchHit) Iterator(java.util.Iterator) IndexNotFoundException(org.opensearch.index.IndexNotFoundException) IOException(java.io.IOException) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) XContentParser(org.opensearch.common.xcontent.XContentParser) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) MatchAllQueryBuilder(org.opensearch.index.query.MatchAllQueryBuilder)

Example 5 with AnomalyDetectorJob

use of org.opensearch.ad.model.AnomalyDetectorJob in project anomaly-detection by opensearch-project.

the class AnomalyDetectorJobRunner method runAnomalyDetectionJob.

private void runAnomalyDetectionJob(AnomalyDetectorJob jobParameter, LockService lockService, LockModel lock, Instant detectionStartTime, Instant executionStartTime, String detectorId, String user, List<String> roles) {
    try (InjectSecurity injectSecurity = new InjectSecurity(detectorId, settings, client.threadPool().getThreadContext())) {
        // Injecting user role to verify if the user has permissions for our API.
        injectSecurity.inject(user, roles);
        AnomalyResultRequest request = new AnomalyResultRequest(detectorId, detectionStartTime.toEpochMilli(), executionStartTime.toEpochMilli());
        client.execute(AnomalyResultAction.INSTANCE, request, ActionListener.wrap(response -> {
            indexAnomalyResult(jobParameter, lockService, lock, detectionStartTime, executionStartTime, response);
        }, exception -> {
            handleAdException(jobParameter, lockService, lock, detectionStartTime, executionStartTime, exception);
        }));
    } catch (Exception e) {
        indexAnomalyResultException(jobParameter, lockService, lock, detectionStartTime, executionStartTime, e, true);
        log.error("Failed to execute AD job " + detectorId, e);
    }
}
Also used : ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) ADTaskState(org.opensearch.ad.model.ADTaskState) AnomalyDetectionException(org.opensearch.ad.common.exception.AnomalyDetectionException) AnomalyDetectorFunction(org.opensearch.ad.rest.handler.AnomalyDetectorFunction) XContentParser(org.opensearch.common.xcontent.XContentParser) AD_THREAD_POOL_NAME(org.opensearch.ad.AnomalyDetectorPlugin.AD_THREAD_POOL_NAME) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) WriteRequest(org.opensearch.action.support.WriteRequest) ADIndex(org.opensearch.ad.indices.ADIndex) ActionListener(org.opensearch.action.ActionListener) GetResponse(org.opensearch.action.get.GetResponse) Client(org.opensearch.client.Client) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LoggingDeprecationHandler(org.opensearch.common.xcontent.LoggingDeprecationHandler) Set(java.util.Set) XContentParserUtils.ensureExpectedToken(org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken) ADTaskManager(org.opensearch.ad.task.ADTaskManager) Settings(org.opensearch.common.settings.Settings) Instant(java.time.Instant) UPDATED(org.opensearch.action.DocWriteResponse.Result.UPDATED) List(java.util.List) AnomalyResultAction(org.opensearch.ad.transport.AnomalyResultAction) Logger(org.apache.logging.log4j.Logger) AnomalyResult(org.opensearch.ad.model.AnomalyResult) CAN_NOT_FIND_LATEST_TASK(org.opensearch.ad.constant.CommonErrorMessages.CAN_NOT_FIND_LATEST_TASK) CREATED(org.opensearch.action.DocWriteResponse.Result.CREATED) IntervalSchedule(org.opensearch.jobscheduler.spi.schedule.IntervalSchedule) XContentType(org.opensearch.common.xcontent.XContentType) InjectSecurity(org.opensearch.commons.InjectSecurity) JobExecutionContext(org.opensearch.jobscheduler.spi.JobExecutionContext) DiscoveryNodeFilterer(org.opensearch.ad.util.DiscoveryNodeFilterer) AnomalyIndexHandler(org.opensearch.ad.transport.handler.AnomalyIndexHandler) AnomalyResultRequest(org.opensearch.ad.transport.AnomalyResultRequest) ThreadPool(org.opensearch.threadpool.ThreadPool) FeatureData(org.opensearch.ad.model.FeatureData) AnomalyDetectorSettings(org.opensearch.ad.settings.AnomalyDetectorSettings) ArrayList(java.util.ArrayList) ProfileRequest(org.opensearch.ad.transport.ProfileRequest) XCONTENT_WITH_TYPE(org.opensearch.ad.util.RestHandlerUtils.XCONTENT_WITH_TYPE) HashSet(java.util.HashSet) ImmutableList(com.google.common.collect.ImmutableList) LockModel(org.opensearch.jobscheduler.spi.LockModel) ExecutorService(java.util.concurrent.ExecutorService) EndRunException(org.opensearch.ad.common.exception.EndRunException) LockService(org.opensearch.jobscheduler.spi.utils.LockService) InternalFailure(org.opensearch.ad.common.exception.InternalFailure) GetRequest(org.opensearch.action.get.GetRequest) Throwables(com.google.common.base.Throwables) IOException(java.io.IOException) AnomalyDetectionIndices(org.opensearch.ad.indices.AnomalyDetectionIndices) DetectorProfileName(org.opensearch.ad.model.DetectorProfileName) ScheduledJobParameter(org.opensearch.jobscheduler.spi.ScheduledJobParameter) AnomalyResultTransportAction(org.opensearch.ad.transport.AnomalyResultTransportAction) XContentBuilder(org.opensearch.common.xcontent.XContentBuilder) User(org.opensearch.commons.authuser.User) AnomalyResultResponse(org.opensearch.ad.transport.AnomalyResultResponse) AnomalyDetectorJob(org.opensearch.ad.model.AnomalyDetectorJob) NamedXContentRegistry(org.opensearch.common.xcontent.NamedXContentRegistry) ScheduledJobRunner(org.opensearch.jobscheduler.spi.ScheduledJobRunner) IndexRequest(org.opensearch.action.index.IndexRequest) IntervalTimeConfiguration(org.opensearch.ad.model.IntervalTimeConfiguration) LogManager(org.apache.logging.log4j.LogManager) ProfileAction(org.opensearch.ad.transport.ProfileAction) AnomalyResultRequest(org.opensearch.ad.transport.AnomalyResultRequest) InjectSecurity(org.opensearch.commons.InjectSecurity) ResourceNotFoundException(org.opensearch.ad.common.exception.ResourceNotFoundException) AnomalyDetectionException(org.opensearch.ad.common.exception.AnomalyDetectionException) EndRunException(org.opensearch.ad.common.exception.EndRunException) IOException(java.io.IOException)

Aggregations

AnomalyDetectorJob (org.opensearch.ad.model.AnomalyDetectorJob)38 ActionListener (org.opensearch.action.ActionListener)18 AnomalyDetector (org.opensearch.ad.model.AnomalyDetector)18 XContentParser (org.opensearch.common.xcontent.XContentParser)18 GetRequest (org.opensearch.action.get.GetRequest)17 IOException (java.io.IOException)16 ADTask (org.opensearch.ad.model.ADTask)15 Instant (java.time.Instant)13 LogManager (org.apache.logging.log4j.LogManager)13 Logger (org.apache.logging.log4j.Logger)13 GetResponse (org.opensearch.action.get.GetResponse)13 Client (org.opensearch.client.Client)13 IndexRequest (org.opensearch.action.index.IndexRequest)12 AnomalyDetectionIndices (org.opensearch.ad.indices.AnomalyDetectionIndices)12 IntervalTimeConfiguration (org.opensearch.ad.model.IntervalTimeConfiguration)12 NamedXContentRegistry (org.opensearch.common.xcontent.NamedXContentRegistry)12 XContentParserUtils.ensureExpectedToken (org.opensearch.common.xcontent.XContentParserUtils.ensureExpectedToken)12 ADTaskState (org.opensearch.ad.model.ADTaskState)11 OpenSearchStatusException (org.opensearch.OpenSearchStatusException)10 WriteRequest (org.opensearch.action.support.WriteRequest)10