use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class ClusterLoggersResource method setSubsystemLoggerLevel.
@PUT
@Timed
@Path("/{nodeId}/subsystems/{subsystem}/level/{level}")
@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.") })
@NoAuditEvent("proxy resource, audit event will be emitted on target nodes")
public void setSubsystemLoggerLevel(@ApiParam(name = "nodeId", required = true) @PathParam("nodeId") @NotEmpty String nodeId, @ApiParam(name = "subsystem", required = true) @PathParam("subsystem") @NotEmpty String subsystemTitle, @ApiParam(name = "level", required = true) @PathParam("level") @NotEmpty String level) throws NodeNotFoundException, IOException {
final Node node = this.nodeService.byNodeId(nodeId);
final RemoteLoggersResource remoteLoggersResource = this.remoteInterfaceProvider.get(node, this.authenticationToken, RemoteLoggersResource.class);
remoteLoggersResource.setSubsystemLoggerLevel(subsystemTitle, level).execute();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class RuleResource method parse.
@ApiOperation(value = "Parse a processing rule without saving it", notes = "")
@POST
@Path("/parse")
@NoAuditEvent("only used to parse a rule, no changes made in the system")
public RuleSource parse(@ApiParam(name = "rule", required = true) @NotNull RuleSource ruleSource) throws ParseException {
final Rule rule;
try {
// be silent about parse errors here, many requests will result in invalid syntax
rule = pipelineRuleParser.parseRule(ruleSource.id(), ruleSource.source(), true);
} catch (ParseException e) {
throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(e.getErrors()).build());
}
final DateTime now = DateTime.now(DateTimeZone.UTC);
return RuleSource.builder().title(rule.name()).description(ruleSource.description()).source(ruleSource.source()).createdAt(now).modifiedAt(now).build();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class SimulatorResource method simulate.
@ApiOperation(value = "Simulate the execution of the pipeline message processor")
@POST
@RequiresPermissions(PipelineRestPermissions.PIPELINE_RULE_READ)
@NoAuditEvent("only used to test pipelines, no changes made in the system")
public SimulationResponse simulate(@ApiParam(name = "simulation", required = true) @NotNull SimulationRequest request) throws NotFoundException {
checkPermission(RestPermissions.STREAMS_READ, request.streamId());
final Message message = new Message(request.message());
// Save off the original message fields to compare post pipeline processing
Map<String, Object> originalFields = new HashMap<>(message.getFields());
final Stream stream = streamService.load(request.streamId());
message.addStream(stream);
if (!Strings.isNullOrEmpty(request.inputId())) {
message.setSourceInputId(request.inputId());
}
final List<ResultMessageSummary> simulationResults = new ArrayList<>();
final PipelineInterpreterTracer pipelineInterpreterTracer = new PipelineInterpreterTracer();
org.graylog2.plugin.Messages processedMessages = pipelineInterpreter.process(message, pipelineInterpreterTracer.getSimulatorInterpreterListener(), pipelineStateUpdater.getLatestState());
for (Message processedMessage : processedMessages) {
ResultMessageSummary summary = ResultMessageSummary.create(null, processedMessage.getFields(), "");
// generate the DecorationStats and add it to the summary
DecorationStats decorationStats = DecorationStats.create(originalFields, processedMessage.getFields());
simulationResults.add(summary.toBuilder().decorationStats(decorationStats).build());
}
return SimulationResponse.create(simulationResults, pipelineInterpreterTracer.getExecutionTrace(), pipelineInterpreterTracer.took());
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class SuggestionsResource method suggestFieldValue.
@POST
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation("Suggest field value")
@NoAuditEvent("Only suggesting field value for query, not changing any data")
public SuggestionsDTO suggestFieldValue(@ApiParam(name = "validationRequest") SuggestionsRequestDTO suggestionsRequest, @Context SearchUser searchUser) {
final SuggestionRequest req = SuggestionRequest.builder().field(suggestionsRequest.field()).input(suggestionsRequest.input()).streams(adaptStreams(suggestionsRequest.streams(), searchUser)).size(Math.min(suggestionsRequest.size(), SUGGESTIONS_COUNT_MAX)).timerange(Optional.ofNullable(suggestionsRequest.timerange()).orElse(defaultTimeRange())).build();
SuggestionResponse res = querySuggestionsService.suggest(req);
final List<SuggestionEntryDTO> suggestions = res.suggestions().stream().map(s -> SuggestionEntryDTO.create(s.getValue(), s.getOccurrence())).collect(Collectors.toList());
final SuggestionsDTO.Builder suggestionsBuilder = SuggestionsDTO.builder(res.field(), res.input()).suggestions(suggestions).sumOtherDocsCount(res.sumOtherDocsCount());
res.suggestionError().map(e -> SuggestionsErrorDTO.create(e.type(), e.reason())).ifPresent(suggestionsBuilder::error);
return suggestionsBuilder.build();
}
use of org.graylog2.audit.jersey.NoAuditEvent in project graylog2-server by Graylog2.
the class MessagesResource method retrieveForSearch.
@ApiOperation(value = "Export a search result as CSV")
@POST
@Path("{searchId}")
@Produces(MoreMediaTypes.TEXT_CSV)
@NoAuditEvent("Has custom audit events")
public ChunkedOutput<SimpleMessageChunk> retrieveForSearch(@ApiParam(value = "ID of an existing Search", name = "searchId") @PathParam("searchId") String searchId, @ApiParam(value = "Optional overrides") @Valid ResultFormat formatFromClient, @Context SearchUser searchUser) {
ResultFormat format = fillInIfNecessary(emptyIfNull(formatFromClient), searchUser);
Search search = loadSearch(searchId, format.executionState(), searchUser);
ExportMessagesCommand command = commandFactory.buildWithSearchOnly(search, format);
return asyncRunner.apply(chunkConsumer -> exporter(searchId).export(command, chunkConsumer));
}
Aggregations