use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class GrokResource method updatePattern.
@PUT
@Timed
@Path("/{patternId}")
@ApiOperation("Update an existing pattern")
@AuditEvent(type = AuditEventTypes.GROK_PATTERN_UPDATE)
public GrokPattern updatePattern(@ApiParam(name = "patternId", required = true) @PathParam("patternId") String patternId, @ApiParam(name = "pattern", required = true) GrokPattern pattern) throws NotFoundException, ValidationException {
checkPermission(RestPermissions.INPUTS_EDIT);
final GrokPattern oldPattern = grokPatternService.load(patternId);
final Set<String> deletedNames = Sets.newHashSet(oldPattern.name());
final Set<String> updatedNames = Sets.newHashSet(pattern.name());
final GrokPattern toSave = oldPattern.toBuilder().name(pattern.name()).pattern(pattern.pattern()).build();
clusterBus.post(GrokPatternsChangedEvent.create(deletedNames, updatedNames));
return grokPatternService.save(toSave);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class LoggersResource method setSubsystemLoggerLevel.
@PUT
@Timed
@ApiOperation(value = "Set the loglevel of a whole subsystem", notes = "Provided level is falling back to DEBUG if it does not exist")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such subsystem.") })
@Path("/subsystems/{subsystem}/level/{level}")
@AuditEvent(type = AuditEventTypes.LOG_LEVEL_UPDATE)
public void setSubsystemLoggerLevel(@ApiParam(name = "subsystem", required = true) @PathParam("subsystem") @NotEmpty String subsystemTitle, @ApiParam(name = "level", required = true) @PathParam("level") @NotEmpty String level) {
if (!SUBSYSTEMS.containsKey(subsystemTitle)) {
final String msg = "No such logging subsystem: [" + subsystemTitle + "]";
LOG.warn(msg);
throw new NotFoundException(msg);
}
checkPermission(RestPermissions.LOGGERS_EDITSUBSYSTEM, subsystemTitle);
final Subsystem subsystem = SUBSYSTEMS.get(subsystemTitle);
final Level newLevel = Level.toLevel(level.toUpperCase(Locale.ENGLISH));
setLoggerLevel(subsystem.getCategory(), newLevel);
LOG.debug("Successfully set log level for subsystem \"{}\" to \"{}\"", subsystem.getTitle(), newLevel);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class OutputResource method create.
@POST
@Timed
@ApiOperation(value = "Create an output")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid output specification in input.", response = OutputSummary.class) })
@AuditEvent(type = AuditEventTypes.MESSAGE_OUTPUT_CREATE)
public Response create(@ApiParam(name = "JSON body", required = true) CreateOutputRequest csor) throws ValidationException {
checkPermission(RestPermissions.OUTPUTS_CREATE);
final AvailableOutputSummary outputSummary = messageOutputFactory.getAvailableOutputs().get(csor.type());
if (outputSummary == null) {
throw new ValidationException("type", "Invalid output type");
}
// Make sure the config values will be stored with the correct type.
final CreateOutputRequest createOutputRequest = CreateOutputRequest.create(csor.title(), csor.type(), ConfigurationMapConverter.convertValues(csor.configuration(), outputSummary.requestedConfiguration()), csor.streams());
final Output output = outputService.create(createOutputRequest, getCurrentUser().getName());
final URI outputUri = getUriBuilderToSelf().path(OutputResource.class).path("{outputId}").build(output.getId());
return Response.created(outputUri).entity(OutputSummary.create(output.getId(), output.getTitle(), output.getType(), output.getCreatorUserId(), new DateTime(output.getCreatedAt()), new HashMap<>(output.getConfiguration()), output.getContentPack())).build();
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class OutputResource method update.
@PUT
@Path("/{outputId}")
@Timed
@ApiOperation(value = "Update output")
@RequiresPermissions(RestPermissions.OUTPUTS_EDIT)
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such output on this node.") })
@AuditEvent(type = AuditEventTypes.MESSAGE_OUTPUT_UPDATE)
public Output update(@ApiParam(name = "outputId", value = "The id of the output that should be deleted", required = true) @PathParam("outputId") String outputId, @ApiParam(name = "JSON body", required = true) Map<String, Object> deltas) throws ValidationException, NotFoundException {
checkPermission(RestPermissions.OUTPUTS_EDIT, outputId);
final Output oldOutput = outputService.load(outputId);
final AvailableOutputSummary outputSummary = messageOutputFactory.getAvailableOutputs().get(oldOutput.getType());
if (outputSummary == null) {
throw new ValidationException("type", "Invalid output type");
}
deltas.remove("streams");
if (deltas.containsKey("configuration")) {
@SuppressWarnings("unchecked") final Map<String, Object> configuration = (Map<String, Object>) deltas.get("configuration");
deltas.put("configuration", ConfigurationMapConverter.convertValues(configuration, outputSummary.requestedConfiguration()));
}
final Output output = this.outputService.update(outputId, deltas);
this.outputRegistry.removeOutput(oldOutput);
return output;
}
Aggregations