diff --git a/src/main/java/com/ly/ckibana/handlers/ParamHandler.java b/src/main/java/com/ly/ckibana/handlers/ParamHandler.java index 2904b2b..2be7fbc 100644 --- a/src/main/java/com/ly/ckibana/handlers/ParamHandler.java +++ b/src/main/java/com/ly/ckibana/handlers/ParamHandler.java @@ -59,6 +59,8 @@ public class ParamHandler extends BaseHandler { private static final String ROUND_ABLE_MIN_PERIOD = "/config/updateRoundAbleMinPeriod"; + private static final String ROUND = "/config/updateRound"; + private static final String MAX_TIME_RANGE = "/config/updateMaxTimeRange"; private static final String ENABLE_MONITORING = "/config/updateEnableMonitoring"; @@ -76,6 +78,7 @@ public List<HttpRoute> routes() { HttpRoute.newRoute().path(SAMPLE_MAX_THRESHOLD).methods(HttpMethod.POST), HttpRoute.newRoute().path(USE_CACHE).methods(HttpMethod.POST), HttpRoute.newRoute().path(ROUND_ABLE_MIN_PERIOD).methods(HttpMethod.POST), + HttpRoute.newRoute().path(ROUND).methods(HttpMethod.POST), HttpRoute.newRoute().path(MAX_TIME_RANGE).methods(HttpMethod.POST), HttpRoute.newRoute().path(ENABLE_MONITORING).methods(HttpMethod.POST), HttpRoute.newRoute().path(MSEARCH_THREAD_POOL_CORE_SIZE).methods(HttpMethod.POST) @@ -120,6 +123,9 @@ public String doHandle(RequestContext context) { case ROUND_ABLE_MIN_PERIOD: kibanaProperty.getProxy().setRoundAbleMinPeriod(parseValue(params.get("roundAbleMinPeriod"))); break; + case ROUND: + kibanaProperty.getProxy().setRound(parseValue(params.get("round")).intValue()); + break; case MAX_TIME_RANGE: kibanaProperty.getProxy().setMaxTimeRange(parseValue(params.get("maxTimeRange"))); break; diff --git a/src/main/java/com/ly/ckibana/model/property/KibanaItemProperty.java b/src/main/java/com/ly/ckibana/model/property/KibanaItemProperty.java index 9325167..9eb96c3 100644 --- a/src/main/java/com/ly/ckibana/model/property/KibanaItemProperty.java +++ b/src/main/java/com/ly/ckibana/model/property/KibanaItemProperty.java @@ -30,9 +30,14 @@ public class KibanaItemProperty { private EsProperty es; /** - * 超过ROUND_ABLE_MIN_PERIOD 支持round. + * 超过ROUND_ABLE_MIN_PERIOD 支持round,单位ms. */ - private long roundAbleMinPeriod; + private long roundAbleMinPeriod = 120000; + + /** + * round值,单位s. + */ + private int round; /** * 支持的时间周期. diff --git a/src/main/java/com/ly/ckibana/parser/ParamParser.java b/src/main/java/com/ly/ckibana/parser/ParamParser.java index 5bd5251..75a2299 100644 --- a/src/main/java/com/ly/ckibana/parser/ParamParser.java +++ b/src/main/java/com/ly/ckibana/parser/ParamParser.java @@ -303,7 +303,7 @@ public long getTimeIntervalMillSeconds(Range timeRange) { /** * 时间参数round. - * 2分钟内数据不round,inSpecialTime round 20s,默认round 10s + * 2分钟内数据不round, 默认round 10s * 返回ui */ public Range getTimeRangeAfterRound(CkRequestContext ckRequestContext) { @@ -311,7 +311,7 @@ public Range getTimeRangeAfterRound(CkRequestContext ckRequestContext) { KibanaItemProperty kibanaItemProperty = proxyConfigLoader.getKibanaProperty().getProxy(); boolean isRoundAble = getTimeIntervalMillSeconds(result) > kibanaItemProperty.getRoundAbleMinPeriod(); if (isRoundAble) { - int realRound = Constants.ROUND_SECOND; + int realRound = kibanaItemProperty.getRound() > 0 ? kibanaItemProperty.getRound() : Constants.ROUND_SECOND; result.setHigh(DateUtils.roundToMSecond(Math.min(System.currentTimeMillis(), (Long) result.getHigh()), realRound)); result.setLow(DateUtils.roundToMSecond((Long) result.getLow(), realRound)); }