use of io.gravitee.rest.api.model.analytics.query.StatsQuery in project gravitee-management-rest-api by gravitee-io.
the class EnvironmentAnalyticsResource method executeStats.
private Analytics executeStats(AnalyticsParam analyticsParam, String extraFilter) {
final StatsQuery query = new StatsQuery();
query.setFrom(analyticsParam.getFrom());
query.setTo(analyticsParam.getTo());
query.setInterval(analyticsParam.getInterval());
query.setQuery(analyticsParam.getQuery());
query.setField(analyticsParam.getField());
addExtraFilter(query, extraFilter);
return analyticsService.execute(query);
}
use of io.gravitee.rest.api.model.analytics.query.StatsQuery in project gravitee-management-rest-api by gravitee-io.
the class ApiMetricsResource method getNbHits.
private Number getNbHits(String apiId) {
StatsQuery query = new StatsQuery();
Instant now = Instant.now();
query.setFrom(now.minus(7, ChronoUnit.DAYS).toEpochMilli());
query.setTo(now.toEpochMilli());
query.setInterval(43200000);
query.setRootField("api");
query.setRootIdentifier(apiId);
query.setField("response-time");
try {
final StatsAnalytics analytics = analyticsService.execute(query);
if (analytics != null) {
return analytics.getCount();
}
} catch (final Exception e) {
// do nothing as the analytics errors should not break the portal
}
return null;
}
Aggregations