Search in sources :

Example 26 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class ExtractorsResource method single.

@GET
@Timed
@ApiOperation(value = "Get information of a single extractor of an input")
@Path("/{extractorId}")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input on this node."), @ApiResponse(code = 404, message = "No such extractor on this input.") })
@Produces(MediaType.APPLICATION_JSON)
public ExtractorSummary single(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId, @ApiParam(name = "extractorId", required = true) @PathParam("extractorId") final String extractorId) throws NotFoundException {
    checkPermission(RestPermissions.INPUTS_READ, inputId);
    final MessageInput input = persistedInputs.get(inputId);
    if (input == null) {
        LOG.error("Input <{}> not found.", inputId);
        throw new javax.ws.rs.NotFoundException("Couldn't find input " + inputId);
    }
    final Input mongoInput = inputService.find(input.getPersistId());
    final Extractor extractor = inputService.getExtractor(mongoInput, extractorId);
    return toSummary(extractor);
}
Also used : Input(org.graylog2.inputs.Input) MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) NotFoundException(org.graylog2.database.NotFoundException) Extractor(org.graylog2.plugin.inputs.Extractor) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 27 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class ExtractorsResource method terminate.

@DELETE
@Timed
@ApiOperation(value = "Delete an extractor")
@Path("/{extractorId}")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid request."), @ApiResponse(code = 404, message = "Input not found."), @ApiResponse(code = 404, message = "Extractor not found.") })
@Produces(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.EXTRACTOR_DELETE)
public void terminate(@ApiParam(name = "inputId", required = true) @PathParam("inputId") String inputId, @ApiParam(name = "extractorId", required = true) @PathParam("extractorId") String extractorId) throws NotFoundException {
    checkPermission(RestPermissions.INPUTS_EDIT, inputId);
    final MessageInput input = persistedInputs.get(inputId);
    if (input == null) {
        LOG.error("Input <{}> not found.", inputId);
        throw new javax.ws.rs.NotFoundException("Couldn't find input " + inputId);
    }
    // Remove from Mongo.
    final Input mongoInput = inputService.find(input.getPersistId());
    final Extractor extractor = inputService.getExtractor(mongoInput, extractorId);
    inputService.removeExtractor(mongoInput, extractor.getId());
    final String msg = "Deleted extractor <" + extractorId + "> of type [" + extractor.getType() + "] " + "from input <" + inputId + ">.";
    LOG.info(msg);
    activityWriter.write(new Activity(msg, InputsResource.class));
}
Also used : Input(org.graylog2.inputs.Input) MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) NotFoundException(org.graylog2.database.NotFoundException) Activity(org.graylog2.shared.system.activities.Activity) Extractor(org.graylog2.plugin.inputs.Extractor) Path(javax.ws.rs.Path) DELETE(javax.ws.rs.DELETE) Produces(javax.ws.rs.Produces) Timed(com.codahale.metrics.annotation.Timed) ApiOperation(io.swagger.annotations.ApiOperation) AuditEvent(org.graylog2.audit.jersey.AuditEvent) ApiResponses(io.swagger.annotations.ApiResponses)

Example 28 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class PersistedInputsImpl method iterator.

@Override
public Iterator<MessageInput> iterator() {
    List<MessageInput> result = Lists.newArrayList();
    for (Input io : inputService.allOfThisNode(serverStatus.getNodeId().toString())) {
        try {
            final MessageInput input = inputService.getMessageInput(io);
            result.add(input);
        } catch (NoSuchInputTypeException e) {
            LOG.warn("Cannot instantiate persisted input. No such type [{}].", io.getType());
        } catch (Throwable e) {
            LOG.warn("Cannot instantiate persisted input. Exception caught: ", e);
        }
    }
    return result.iterator();
}
Also used : MessageInput(org.graylog2.plugin.inputs.MessageInput) MessageInput(org.graylog2.plugin.inputs.MessageInput) NoSuchInputTypeException(org.graylog2.shared.inputs.NoSuchInputTypeException)

Example 29 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class TcpTransport method getCustomChildChannelHandlers.

@Override
protected LinkedHashMap<String, Callable<? extends ChannelHandler>> getCustomChildChannelHandlers(MessageInput input) {
    final LinkedHashMap<String, Callable<? extends ChannelHandler>> childChannelHandlers = new LinkedHashMap<>();
    childChannelHandlers.put("framer", () -> new LenientDelimiterBasedFrameDecoder(maxFrameLength, delimiter));
    childChannelHandlers.putAll(super.getCustomChildChannelHandlers(input));
    return childChannelHandlers;
}
Also used : LenientDelimiterBasedFrameDecoder(org.graylog2.inputs.transports.netty.LenientDelimiterBasedFrameDecoder) ChannelHandler(io.netty.channel.ChannelHandler) Callable(java.util.concurrent.Callable) LinkedHashMap(java.util.LinkedHashMap)

Example 30 with MessageInput

use of org.graylog2.plugin.inputs.MessageInput in project graylog2-server by Graylog2.

the class UdpTransport method getBootstrap.

@VisibleForTesting
Bootstrap getBootstrap(MessageInput input) {
    LOG.debug("Setting UDP receive buffer size to {} bytes", getRecvBufferSize());
    final NettyTransportType transportType = nettyTransportConfiguration.getType();
    eventLoopGroup = eventLoopGroupFactory.create(workerThreads, localRegistry, "workers");
    return new Bootstrap().group(eventLoopGroup).channelFactory(new DatagramChannelFactory(transportType)).option(ChannelOption.RCVBUF_ALLOCATOR, new FixedRecvByteBufAllocator(getRecvBufferSize())).option(ChannelOption.SO_RCVBUF, getRecvBufferSize()).option(UnixChannelOption.SO_REUSEPORT, true).handler(getChannelInitializer(getChannelHandlers(input))).validate();
}
Also used : FixedRecvByteBufAllocator(io.netty.channel.FixedRecvByteBufAllocator) NettyTransportType(org.graylog2.inputs.transports.netty.NettyTransportType) Bootstrap(io.netty.bootstrap.Bootstrap) DatagramChannelFactory(org.graylog2.inputs.transports.netty.DatagramChannelFactory) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

MessageInput (org.graylog2.plugin.inputs.MessageInput)47 Test (org.junit.Test)18 Callable (java.util.concurrent.Callable)17 NotFoundException (org.graylog2.database.NotFoundException)10 Configuration (org.graylog2.plugin.configuration.Configuration)9 ChannelHandler (io.netty.channel.ChannelHandler)8 LinkedHashMap (java.util.LinkedHashMap)8 Input (org.graylog2.inputs.Input)8 MisfireException (org.graylog2.plugin.inputs.MisfireException)7 ChannelHandler (org.jboss.netty.channel.ChannelHandler)7 Timed (com.codahale.metrics.annotation.Timed)6 ApiOperation (io.swagger.annotations.ApiOperation)6 ApiResponses (io.swagger.annotations.ApiResponses)6 EventBus (com.google.common.eventbus.EventBus)5 AuditEvent (org.graylog2.audit.jersey.AuditEvent)5 Subscribe (com.google.common.eventbus.Subscribe)4 Produces (javax.ws.rs.Produces)4 IOState (org.graylog2.plugin.IOState)4 LocalMetricRegistry (org.graylog2.plugin.LocalMetricRegistry)4 Extractor (org.graylog2.plugin.inputs.Extractor)4