✨ Retrieve bucket by period
This commit is contained in:
parent
ce01994b3b
commit
f31cab780b
@ -5,13 +5,15 @@ meta {
|
||||
}
|
||||
|
||||
get {
|
||||
url: http://localhost:4000/api/metrics/analytics-backend-deployment-8695d9f87f-v8n7r/WORKLOAD?bucket-unit=RAW
|
||||
url: {{origin}}/api/metrics/analytics-backend-deployment-8695d9f87f-v8n7r/WORKLOAD?bucket-unit=RAW&from=2017-04-26T15:13:12.016+02:00&to=2017-04-26T15:13:12.016+02:00
|
||||
body: none
|
||||
auth: basic
|
||||
}
|
||||
|
||||
params:query {
|
||||
bucket-unit: RAW
|
||||
from: 2017-04-26T15:13:12.016+02:00
|
||||
to: 2017-04-26T15:13:12.016+02:00
|
||||
}
|
||||
|
||||
auth:basic {
|
||||
|
||||
@ -5,7 +5,7 @@ meta {
|
||||
}
|
||||
|
||||
post {
|
||||
url: http://localhost:4000/api/metrics/analytics-backend-deployment-8695d9f87f-v8n7r/WORKLOAD
|
||||
url: {{origin}}/api/metrics/analytics-backend-deployment-8695d9f87f-v8n7r/WORKLOAD
|
||||
body: json
|
||||
auth: basic
|
||||
}
|
||||
|
||||
3
bruno/collection.bru
Normal file
3
bruno/collection.bru
Normal file
@ -0,0 +1,3 @@
|
||||
vars:pre-request {
|
||||
origin: http://localhost:8090
|
||||
}
|
||||
@ -19,13 +19,8 @@ public class Repo implements PanacheRepositoryBase<Bucket, String>
|
||||
return find("resource = :resource AND name = :name AND timestamp = :timestamp AND bucketUnit = :bucketUnit", Parameters.with("resource", resource).and("name", name).and("timestamp", timestamp).and("bucketUnit", bucketUnit)).firstResultOptional();
|
||||
}
|
||||
|
||||
public List<Bucket> findByResourceAndMetricAndTimeUnit(String resource, String name, BucketUnit bucketUnit)
|
||||
{
|
||||
return list("resource = :resource AND name = :name AND bucketUnit = :bucketUnit ORDER BY timestamp ASC", Parameters.with("resource", resource).and("name", name).and("bucketUnit", bucketUnit));
|
||||
}
|
||||
|
||||
public List<Bucket> findByResourceAndMetricAndTimeUnitAndPeriod(String resource, String name, BucketUnit bucketUnit, Long from, Long to)
|
||||
{
|
||||
return list("resource = :resource AND name = :name AND bucketUnit = :bucketUnit AND (unix >= :from AND unix <= :to) ORDER BY timestamp ASC", Parameters.with("resource", resource).and("name", name).and("bucketUnit", bucketUnit).and("from", from).and("to", to));
|
||||
return list("resource = :resource AND name = :name AND bucketUnit = :bucketUnit AND unixTimestamp >= :from AND unixTimestamp <= :to ORDER BY unixTimestamp DESC", Parameters.with("resource", resource).and("name", name).and("bucketUnit", bucketUnit).and("from", from).and("to", to));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package dev.dinauer.metrics.service;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -41,12 +42,12 @@ public class Resource
|
||||
}
|
||||
|
||||
@GET
|
||||
public List<Bucket> get(@PathParam("resource") String resource, @PathParam("metric") String metric, @QueryParam("bucket-unit") Optional<BucketUnit> bucketUnit)
|
||||
public List<Bucket> get(@PathParam("resource") String resource, @PathParam("metric") String metric, @QueryParam("bucket-unit") Optional<BucketUnit> bucketUnit, @QueryParam("from") ZonedDateTime from, @QueryParam("to") ZonedDateTime to)
|
||||
{
|
||||
if (authenticationService.canRead())
|
||||
{
|
||||
Timer timer = Timer.start();
|
||||
List<Bucket> buckets = service.get(resource, metric, bucketUnit.orElse(BucketUnit.RAW));
|
||||
List<Bucket> buckets = service.get(resource, metric, bucketUnit.orElse(BucketUnit.RAW), from, to);
|
||||
LOG.infof("Retrieving %s buckets in %s seconds.", buckets.size(), timer.stop());
|
||||
return buckets;
|
||||
}
|
||||
|
||||
@ -63,8 +63,8 @@ public class Service
|
||||
}
|
||||
}
|
||||
|
||||
public List<Bucket> get(String resource, String metric, BucketUnit unit)
|
||||
public List<Bucket> get(String resource, String metric, BucketUnit unit, ZonedDateTime from, ZonedDateTime to)
|
||||
{
|
||||
return repo.findByResourceAndMetricAndTimeUnit(resource, metric, unit);
|
||||
return repo.findByResourceAndMetricAndTimeUnitAndPeriod(resource, metric, unit, from.toEpochSecond(), to.toEpochSecond());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
# HTTP
|
||||
quarkus.http.root-path=/api/metrics
|
||||
%dev.quarkus.http.port=4000
|
||||
%dev.quarkus.http.port=8090
|
||||
|
||||
# Test Client
|
||||
%dev.big.bucket.client.test.rw=test
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user