Package org.graylog2.plugin.streams

Examples of org.graylog2.plugin.streams.Stream


    })
    public Response list(@ApiParam(name = "streamId", value = "The stream id this new alert condition belongs to.", required = true) @PathParam("streamId") String streamid,
                         @ApiParam(name = "since", value = "Optional parameter to define a lower date boundary. (UNIX timestamp)", required = false) @QueryParam("since") int sinceTs) {
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }

        final DateTime since;
        if (sinceTs > 0) {
            since = new DateTime(sinceTs*1000L, DateTimeZone.UTC);
        } else {
            since = null;
        }

        List<Map<String,Object>> conditions = Lists.newArrayList();
        for(Alert alert : alertService.loadRecentOfStream(stream.getId(), since)) {
            conditions.add(alert.toMap());
        }

        long total = alertService.totalCountForStream(streamid);

View Full Code Here


            @ApiResponse(code = 400, message = "Invalid ObjectId.")
    })
    public Response checkConditions(@ApiParam(name = "streamId", value = "The ID of the stream to check.", required = true) @PathParam("streamId") String streamid) {
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        final Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }

        Map<String, Object> result;
        try {
            result = cache.get(CACHE_KEY_BASE + stream.getId(), new Callable<Map<String, Object>>() {
                @Override
                public Map<String, Object> call() throws Exception {
                    List<Map<String, Object>> results = Lists.newArrayList();
                    int triggered = 0;
                    for (AlertCondition alertCondition : streamService.getAlertConditions(stream)) {
View Full Code Here

            @ApiResponse(code = 404, message = "Stream not found."),
            @ApiResponse(code = 400, message = "Invalid ObjectId.")
    })
    public Response delete(@ApiParam(name = "streamId", required = true) @PathParam("streamId") String streamId) throws NotFoundException {
        checkPermission(RestPermissions.STREAMS_EDIT, streamId);
        Stream stream = streamService.load(streamId);
        streamService.destroy(stream);

        return Response.noContent().build();
    }
View Full Code Here

            LOG.error("Missing streamId. Returning HTTP 400.");
            throw new WebApplicationException(400);
        }
        checkPermission(RestPermissions.STREAMS_CHANGESTATE, streamId);

        final Stream stream = streamService.load(streamId);
        streamService.pause(stream);

        return Response.ok().build();
    }
View Full Code Here

    @Produces(MediaType.APPLICATION_JSON)
    public StreamRuleListResponse get(@ApiParam(name = "streamid", value = "The id of the stream whose stream rules we want.", required = true) @PathParam("streamid") String streamid) {
        List<Map<String, Object>> streamRules = Lists.newArrayList();
        checkPermission(RestPermissions.STREAMS_READ, streamid);

        final Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (NotFoundException e) {
            throw new javax.ws.rs.NotFoundException("Stream not found!");
        }
View Full Code Here

            LOG.error("Missing streamId. Returning HTTP 400.");
            throw new WebApplicationException(400);
        }
        checkPermission(RestPermissions.STREAMS_CHANGESTATE, streamId);

        final Stream stream = streamService.load(streamId);
        streamService.resume(stream);

        return Response.ok().build();
    }
View Full Code Here

        if (serialisedMessage.get("message") == null) {
            LOG.error("Received invalid JSON body. Returning HTTP 400.");
            throw new WebApplicationException(400);
        }

        final Stream stream = streamService.load(streamId);
        final Message message = new Message(serialisedMessage.get("message"));

        final Map<StreamRule, Boolean> ruleMatches = streamRouter.getRuleMatches(stream, message);
        final Map<String, Boolean> rules = Maps.newHashMap();
View Full Code Here

    public Response cloneStream(@ApiParam(name = "streamId", required = true) @PathParam("streamId") String streamId,
                          @ApiParam(name = "JSON body", required = true) CreateRequest cr) throws ValidationException, NotFoundException {
        checkPermission(RestPermissions.STREAMS_CREATE);
        checkPermission(RestPermissions.STREAMS_READ, streamId);

        final Stream sourceStream = streamService.load(streamId);

        // Create stream.
        final Map<String, Object> streamData = Maps.newHashMap();
        streamData.put("title", cr.title);
        streamData.put("description", cr.description);
        streamData.put("creator_user_id", getCurrentUser().getName());
        streamData.put("created_at", Tools.iso8601());

        final Stream stream = streamService.create(streamData);
        streamService.pause(stream);
        final String id;
        streamService.save(stream);
        id = stream.getId();

        final List<StreamRule> sourceStreamRules;

        sourceStreamRules = streamRuleService.loadForStream(sourceStream);
View Full Code Here

        } catch(IOException e) {
            LOG.error("Error while parsing JSON", e);
            throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
        }

        Stream stream;
        try {
            stream = streamService.load(streamid);
        } catch (org.graylog2.database.NotFoundException e) {
            throw new WebApplicationException(404);
        }
View Full Code Here

        } catch(IOException e) {
            LOG.error("Error while parsing JSON", e);
            throw new WebApplicationException(e, Response.Status.BAD_REQUEST);
        }

        Stream stream;
        AlertCondition alertCondition;
        try {
            stream = streamService.load(streamid);
            alertCondition = streamService.getAlertCondition(stream, conditionid);
            alertCondition = alertService.updateFromRequest(alertCondition, ccr);
View Full Code Here

TOP

Related Classes of org.graylog2.plugin.streams.Stream

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.