Package org.graylog2.indexer.searches.timeranges

Examples of org.graylog2.indexer.searches.timeranges.RelativeRange


    @Override
    protected CheckResult runCheck() {
        this.searchHits = Collections.emptyList();
        try {
            String filter = "streams:" + stream.getId();
            FieldStatsResult fieldStatsResult = searches.fieldStats(field, "*", filter, new RelativeRange(time * 60));
            if (getBacklog() != null && getBacklog() > 0) {
                this.searchHits = Lists.newArrayList();
                for (ResultMessage resultMessage : fieldStatsResult.getSearchHits()) {
                    this.searchHits.add(new Message(resultMessage.getMessage()));
                }
View Full Code Here


    @Override
    protected CheckResult runCheck() {
        this.searchHits = Collections.emptyList();
        try {
            String filter = "streams:" + stream.getId();
            CountResult result = searches.count("*", new RelativeRange(time * 60), filter);
            long count = result.getCount();

            LOG.debug("Alert check <{}> result: [{}]", id, count);

            boolean triggered = false;
            switch (thresholdType) {
                case MORE:
                    triggered = count > threshold;
                    break;
                case LESS:
                    triggered = count < threshold;
                    break;
            }

            if (triggered) {
                Integer backlogSize = getBacklog();
                if (backlogSize != null && backlogSize > 0) {
                    SearchResult backlogResult = searches.search("*", filter, new RelativeRange(time * 60), backlogSize, 0, new Sorting("timestamp", Sorting.Direction.DESC));
                    this.searchHits = Lists.newArrayList();
                    for (ResultMessage resultMessage : backlogResult.getResults()) {
                        searchHits.add(new Message(resultMessage.getMessage()));
                    }
                }
View Full Code Here

        try {
            sources = cache.get(CACHE_KEY + range, new Callable<TermsResult>() {
                @Override
                public TermsResult call() throws Exception {
                    try {
                        return searches.terms("source", 5000, "*", new RelativeRange(range));
                    } catch (IndexHelper.InvalidRangeFormatException e) {
                        throw new ExecutionException(e);
                    } catch (InvalidRangeParametersException e) {
                        throw new ExecutionException(e);
                    }
View Full Code Here

            throw new InvalidRangeParametersException("range_type not set");
        }

        String rangeType = (String) awr.config.get("range_type");
        if (rangeType.equals("relative")) {
            timeRange = new RelativeRange(Integer.parseInt((String) awr.config.get("range")));
        } else if (rangeType.equals("keyword")) {
            timeRange = new KeywordRange((String) awr.config.get("keyword"));
        } else if (rangeType.equals("absolute")) {
            timeRange = new AbsoluteRange((String) awr.config.get("from"), (String) awr.config.get("to"));
        } else {
View Full Code Here

        }

        String rangeType = (String) timerangeConfig.get("type");

        if (rangeType.equals("relative")) {
            timeRange = new RelativeRange((Integer) timerangeConfig.get("range"));
        } else if (rangeType.equals("keyword")) {
            timeRange = new KeywordRange((String) timerangeConfig.get("keyword"));
        } else if (rangeType.equals("absolute")) {

            String from = new DateTime(timerangeConfig.get("from"), DateTimeZone.UTC).toString(Tools.ES_DATE_FORMAT);
View Full Code Here

        inputData.put("creator_user_id", rir.creatorUserId);
        inputData.put("configuration", rir.configuration);
        inputData.put("created_at", Tools.iso8601());
        inputData.put("radio_id", rir.radioId);

        Input mongoInput = new InputImpl(inputData);

        // Write to database.
        String id;
        try {
            id = inputService.save(mongoInput);
View Full Code Here

            LOG.error("Radio <{}> not found.", radioId);
            throw new NotFoundException("Radio <" + radioId + "> not found.");
        }

        try {
            final Input input = inputService.findForThisRadioOrGlobal(radioId, inputId);
            if (!input.isGlobal())
                inputService.destroy(input);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new NotFoundException(e);
        }
View Full Code Here

                        new CacheLoader<String, Optional<MessageInput>>() {
                            @Override
                            public Optional<MessageInput> load(String key) throws Exception {
                                LOG.debug("Loading message input {}", key);
                                try {
                                    final Input input = inputService.find(key);
                                    return Optional.fromNullable(inputService.buildMessageInput(input));
                                } catch (NotFoundException | NoSuchInputTypeException e) {
                                    return Optional.absent();
                                }
                            }
View Full Code Here

        inputData.put("creator_user_id", rir.creatorUserId);
        inputData.put("configuration", rir.configuration);
        inputData.put("created_at", Tools.iso8601());
        inputData.put("radio_id", rir.radioId);

        Input mongoInput = new InputImpl(inputData);

        // Write to database.
        String id;
        try {
            id = inputService.save(mongoInput);
View Full Code Here

            LOG.debug("Version check reports current version: " + parsedResponse);

            if (reportedVersion.greaterMinor(ServerVersion.VERSION)) {
                LOG.debug("Reported version is higher than ours ({}). Writing notification.", ServerVersion.VERSION);

                Notification notification = notificationService.buildNow()
                        .addSeverity(Notification.Severity.NORMAL)
                        .addType(Notification.Type.OUTDATED_VERSION)
                        .addDetail("current_version", parsedResponse.toString());
                notificationService.publishIfFirst(notification);
            } else {
View Full Code Here

TOP

Related Classes of org.graylog2.indexer.searches.timeranges.RelativeRange

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.