use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class StreamRuleResource method delete.
@DELETE
@Path("/{streamRuleId}")
@Timed
@ApiOperation(value = "Delete a stream rule")
@ApiResponses(value = { @ApiResponse(code = 404, message = "Stream rule not found."), @ApiResponse(code = 400, message = "Invalid ObjectId.") })
@AuditEvent(type = AuditEventTypes.STREAM_RULE_DELETE)
public void delete(@ApiParam(name = "streamid", value = "The stream id this new rule belongs to.", required = true) @PathParam("streamid") String streamid, @ApiParam(name = "streamRuleId", required = true) @PathParam("streamRuleId") @NotEmpty String streamRuleId) throws NotFoundException {
checkPermission(RestPermissions.STREAMS_EDIT, streamid);
checkNotDefaultStream(streamid, "Cannot delete stream rule from default stream.");
final StreamRule streamRule = streamRuleService.load(streamRuleId);
if (streamRule.getStreamId().equals(streamid)) {
streamRuleService.destroy(streamRule);
clusterEventBus.post(StreamsChangedEvent.create(streamid));
} else {
throw new NotFoundException("Couldn't delete stream rule " + streamRuleId + "in stream " + streamid);
}
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class ClusterConfigResource method update.
@PUT
@Timed
@Path("{configClass}")
@Consumes(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Update configuration in database")
@RequiresPermissions({ RestPermissions.CLUSTER_CONFIG_ENTRY_CREATE, RestPermissions.CLUSTER_CONFIG_ENTRY_EDIT })
@AuditEvent(type = AuditEventTypes.CLUSTER_CONFIGURATION_UPDATE)
public Response update(@ApiParam(name = "configClass", value = "The name of the cluster configuration class", required = true) @PathParam("configClass") @NotBlank String configClass, @ApiParam(name = "body", value = "The payload of the cluster configuration", required = true) @NotNull InputStream body) throws IOException {
final Class<?> cls = classFromName(configClass);
if (cls == null) {
throw new NotFoundException("Couldn't find configuration class \"" + configClass + "\"");
}
final Object o;
try {
o = objectMapper.readValue(body, cls);
} catch (Exception e) {
final String msg = "Couldn't parse cluster configuration \"" + configClass + "\".";
LOG.error(msg, e);
throw new BadRequestException(msg);
}
try {
clusterConfigService.write(o);
} catch (Exception e) {
final String msg = "Couldn't write cluster config \"" + configClass + "\".";
LOG.error(msg, e);
throw new InternalServerErrorException(msg, e);
}
return Response.accepted(o).build();
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class DeflectorResource method deprecatedCycle.
@POST
@Timed
@ApiOperation(value = "Cycle deflector to new/next index")
@RequiresPermissions(RestPermissions.DEFLECTOR_CYCLE)
@Path("/cycle")
@RestrictToMaster
@AuditEvent(type = AuditEventTypes.ES_WRITE_INDEX_UPDATE_JOB_START)
@Deprecated
public void deprecatedCycle() {
final IndexSet indexSet = indexSetRegistry.getDefault();
checkCycle(indexSet);
final String msg = "Cycling deflector for default index set <" + indexSet.getConfig().id() + ">. Reason: REST request.";
LOG.info(msg);
activityWriter.write(new Activity(msg, DeflectorResource.class));
indexSet.cycle();
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class GettingStartedResource method dismissGettingStarted.
@POST
@Path("dismiss")
@ApiOperation("Dismiss auto-showing getting started guide for this version")
@AuditEvent(type = AuditEventTypes.GETTING_STARTED_GUIDE_OPT_OUT_CREATE)
public void dismissGettingStarted() {
final GettingStartedState gettingStartedState = clusterConfigService.getOrDefault(GettingStartedState.class, GettingStartedState.create(Sets.<String>newHashSet()));
gettingStartedState.dismissedInVersions().add(currentMinorVersionString());
clusterConfigService.write(gettingStartedState);
}
use of org.graylog2.audit.jersey.AuditEvent in project graylog2-server by Graylog2.
the class GrokResource method bulkUpdatePatternsFromTextFile.
@POST
@Consumes(MediaType.TEXT_PLAIN)
@Timed
@ApiOperation("Add a list of new patterns")
@AuditEvent(type = AuditEventTypes.GROK_PATTERN_IMPORT_CREATE)
public Response bulkUpdatePatternsFromTextFile(@ApiParam(name = "patterns", required = true) @NotNull InputStream patternsFile, @ApiParam(name = "replace", value = "Replace all patterns with the new ones.") @QueryParam("replace") @DefaultValue("false") boolean replace) throws ValidationException, IOException {
checkPermission(RestPermissions.INPUTS_CREATE);
final List<GrokPattern> grokPatterns = readGrokPatterns(patternsFile);
if (!grokPatterns.isEmpty()) {
final Set<String> updatedPatternNames = Sets.newHashSetWithExpectedSize(grokPatterns.size());
for (final GrokPattern pattern : grokPatterns) {
updatedPatternNames.add(pattern.name());
if (!grokPatternService.validate(pattern)) {
throw new ValidationException("Invalid pattern " + pattern + ". Did not save any patterns.");
}
}
grokPatternService.saveAll(grokPatterns, replace);
clusterBus.post(GrokPatternsChangedEvent.create(Collections.emptySet(), updatedPatternNames));
}
return Response.accepted().build();
}
Aggregations