use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class ThroughputResource method total.
@GET
@Timed
@RequiresPermissions(RestPermissions.THROUGHPUT_READ)
@ApiOperation(value = "Current throughput of this node in messages per second")
@Produces(MediaType.APPLICATION_JSON)
public Throughput total() {
final SortedMap<String, Gauge> gauges = metricRegistry.getGauges(MetricUtils.filterSingleMetric(GlobalMetricNames.OUTPUT_THROUGHPUT_RATE));
final Gauge gauge = Iterables.getOnlyElement(gauges.values(), null);
if (gauge == null || !(gauge.getValue() instanceof Number)) {
return Throughput.create(0);
} else {
return Throughput.create(((Number) gauge.getValue()).longValue());
}
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class InputTypesResource method info.
@GET
@Timed
@Path("{inputType}")
@ApiOperation(value = "Get information about a single input type")
@ApiResponses(value = { @ApiResponse(code = 404, message = "No such input type registered.") })
public InputTypeInfo info(@ApiParam(name = "inputType", required = true) @PathParam("inputType") String inputType) {
final InputDescription description = messageInputFactory.getAvailableInputs().get(inputType);
if (description == null) {
final String message = "Unknown input type " + inputType + " requested.";
LOG.error(message);
throw new NotFoundException(message);
}
return InputTypeInfo.create(inputType, description.getName(), description.isExclusive(), description.getRequestedConfiguration(), description.getLinkToDocs());
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class IndexRangesResource method rebuildIndexSet.
@POST
@Timed
@Path("/index_set/{indexSetId}/rebuild")
@RequiresPermissions(RestPermissions.INDEXRANGES_REBUILD)
@ApiOperation(value = "Rebuild/sync index range information for the given index set.", notes = "This triggers a systemjob that scans every index in the given index set and stores meta information " + "about what indices contain messages in what timeranges. It atomically overwrites " + "already existing meta information.")
@ApiResponses(value = { @ApiResponse(code = 202, message = "Rebuild/sync systemjob triggered.") })
@Produces(MediaType.APPLICATION_JSON)
@AuditEvent(type = AuditEventTypes.ES_INDEX_RANGE_UPDATE_JOB)
public Response rebuildIndexSet(@ApiParam(name = "indexSetId") @PathParam("indexSetId") @NotBlank final String indexSetId) {
final IndexSet indexSet = indexSetRegistry.get(indexSetId).orElseThrow(() -> new javax.ws.rs.NotFoundException("Index set <" + indexSetId + "> not found!"));
submitIndexRangesJob(Collections.singleton(indexSet));
return Response.accepted().build();
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class IndexRangesResource method show.
@GET
@Path("/{index: [a-z_0-9]+}")
@Timed
@ApiOperation(value = "Show single index range")
@Produces(MediaType.APPLICATION_JSON)
public IndexRangeSummary show(@ApiParam(name = "index", value = "The name of the Graylog-managed Elasticsearch index", required = true) @PathParam("index") @NotEmpty String index) throws NotFoundException {
if (!indexSetRegistry.isManagedIndex(index)) {
throw new BadRequestException(index + " is not a Graylog-managed Elasticsearch index.");
}
checkPermission(RestPermissions.INDEXRANGES_READ, index);
final IndexRange indexRange = indexRangeService.get(index);
return IndexRangeSummary.create(indexRange.indexName(), indexRange.begin(), indexRange.end(), indexRange.calculatedAt(), indexRange.calculationDuration());
}
use of com.codahale.metrics.annotation.Timed in project graylog2-server by Graylog2.
the class MessageProcessorsResource method config.
@GET
@Timed
@ApiOperation(value = "Get message processor configuration")
@Path("config")
public MessageProcessorsConfigWithDescriptors config() {
checkPermission(RestPermissions.CLUSTER_CONFIG_ENTRY_READ);
final MessageProcessorsConfig config = clusterConfigService.getOrDefault(MessageProcessorsConfig.class, MessageProcessorsConfig.defaultConfig());
return MessageProcessorsConfigWithDescriptors.fromConfig(config.withProcessors(processorClassNames), processorDescriptors);
}
Aggregations