use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class ClusterResource method nodes.
@GET
@Timed
@Path("/nodes")
@ApiOperation(value = "List all active nodes in this cluster.")
public NodeSummaryList nodes() {
final Map<String, Node> nodes = nodeService.allActive(Node.Type.SERVER);
final List<NodeSummary> nodeList = new ArrayList<>(nodes.size());
for (Node node : nodes.values()) {
nodeList.add(nodeSummary(node));
}
return NodeSummaryList.create(nodeList);
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class DeflectorResource method cycle.
@POST
@Timed
@ApiOperation(value = "Cycle deflector to new/next index in index set")
@RequiresPermissions(RestPermissions.DEFLECTOR_CYCLE)
@Path("/{indexSetId}/cycle")
@RestrictToMaster
@AuditEvent(type = AuditEventTypes.ES_WRITE_INDEX_UPDATE_JOB_START)
public void cycle(@ApiParam(name = "indexSetId") @PathParam("indexSetId") String indexSetId) {
final IndexSet indexSet = getIndexSet(indexSetRegistry, indexSetId);
checkCycle(indexSet);
final String msg = "Cycling deflector for index set <" + indexSetId + ">. Reason: REST request.";
LOG.info(msg);
activityWriter.write(new Activity(msg, DeflectorResource.class));
indexSet.cycle();
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class GrokResource method bulkUpdatePatterns.
@PUT
@Timed
@ApiOperation("Add a list of new patterns")
@AuditEvent(type = AuditEventTypes.GROK_PATTERN_IMPORT_CREATE)
public Response bulkUpdatePatterns(@ApiParam(name = "patterns", required = true) @NotNull GrokPatternList patternList, @ApiParam(name = "replace", value = "Replace all patterns with the new ones.") @QueryParam("replace") @DefaultValue("false") boolean replace) throws ValidationException {
checkPermission(RestPermissions.INPUTS_CREATE);
final Set<String> updatedPatternNames = Sets.newHashSet();
for (final GrokPattern pattern : patternList.patterns()) {
updatedPatternNames.add(pattern.name());
if (!grokPatternService.validate(pattern)) {
throw new ValidationException("Invalid pattern " + pattern + ". Did not save any patterns.");
}
}
grokPatternService.saveAll(patternList.patterns(), replace);
clusterBus.post(GrokPatternsChangedEvent.create(Collections.emptySet(), updatedPatternNames));
return Response.accepted().build();
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class GrokResource method removePattern.
@DELETE
@Timed
@Path("/{patternId}")
@ApiOperation("Remove an existing pattern by id")
@AuditEvent(type = AuditEventTypes.GROK_PATTERN_DELETE)
public void removePattern(@ApiParam(name = "patternId", required = true) @PathParam("patternId") String patternId) throws NotFoundException {
checkPermission(RestPermissions.INPUTS_EDIT);
final GrokPattern pattern = grokPatternService.load(patternId);
clusterBus.post(GrokPatternsChangedEvent.create(Sets.newHashSet(pattern.name()), Collections.emptySet()));
if (grokPatternService.delete(patternId) == 0) {
throw new javax.ws.rs.NotFoundException("Couldn't remove Grok pattern with ID " + patternId);
}
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class GrokResource method createPattern.
@POST
@Timed
@ApiOperation(value = "Add a new named pattern", response = GrokPattern.class)
@AuditEvent(type = AuditEventTypes.GROK_PATTERN_CREATE)
public Response createPattern(@ApiParam(name = "pattern", required = true) @Valid @NotNull GrokPattern pattern) throws ValidationException {
checkPermission(RestPermissions.INPUTS_CREATE);
// remove the ID from the pattern, this is only used to create new patterns
final GrokPattern newPattern = grokPatternService.save(pattern.toBuilder().id(null).build());
clusterBus.post(GrokPatternsChangedEvent.create(Collections.emptySet(), Sets.newHashSet(newPattern.name())));
final URI patternUri = getUriBuilderToSelf().path(GrokResource.class, "listPattern").build(newPattern.id());
return Response.created(patternUri).entity(newPattern).build();
}
Aggregations