Fix `DurationUtils.getDurationPoints` exceed, when `startTimeBucket` equals `endTimeBucket`. (#10441)
This commit is contained in:
parent
cc7a2c9e97
commit
1a2f794472
|
|
@ -103,6 +103,7 @@
|
|||
* Support prometheus HTTP API and promQL.
|
||||
* `Scope` in the Entity of Metrics query v1 protocol is not required and automatical correction. The scope is determined based on the metric itself.
|
||||
* Add explicit `ReadTimeout` for ConsulConfigurationWatcher to avoid `IllegalArgumentException: Cache watchInterval=10sec >= networkClientReadTimeout=10000ms`.
|
||||
* Fix `DurationUtils.getDurationPoints` exceed, when `startTimeBucket` equals `endTimeBucket`.
|
||||
|
||||
#### UI
|
||||
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ The Configuration Vocabulary lists all available configurations provided by `app
|
|||
| - | - | maxQueryComplexity | Maximum complexity allowed for the GraphQL query that can be used to abort a query if the total number of data fields queried exceeds the defined threshold. | SW_QUERY_MAX_QUERY_COMPLEXITY | 1000 |
|
||||
| - | - | enableUpdateUITemplate | Allow user add,disable and update UI template. | SW_ENABLE_UPDATE_UI_TEMPLATE | false |
|
||||
| - | - | enableOnDemandPodLog | Ondemand Pod log: fetch the Pod logs on users' demand, the logs are fetched and displayed in real time, and are not persisted in any kind. This is helpful when users want to do some experiments and monitor the logs and see what's happing inside the service. Note: if you print secrets in the logs, they are also visible to the UI, so for the sake of security, this feature is disabled by default, please set this configuration to enable the feature manually. | SW_ENABLE_ON_DEMAND_POD_LOG | false |
|
||||
| query | graphql | - | GraphQL query implementation. | - | |
|
||||
| query-zipkin | default | - | This module is for Zipkin query API and support zipkin-lens UI | - | |
|
||||
| - | - | restHost | Binding IP of RESTful services. | SW_QUERY_ZIPKIN_REST_HOST | 0.0.0.0 |
|
||||
| - | - | restPort | Binding port of RESTful services. | SW_QUERY_ZIPKIN_REST_PORT | 9412 |
|
||||
| - | - | restContextPath | Web context path of RESTful services. | SW_QUERY_ZIPKIN_REST_CONTEXT_PATH | zipkin |
|
||||
|
|
@ -253,6 +253,13 @@ The Configuration Vocabulary lists all available configurations provided by `app
|
|||
| - | - | namesMaxAge | The Cache-Control max-age (seconds) for serviceNames, remoteServiceNames and spanNames | SW_QUERY_ZIPKIN_NAMES_MAX_AGE | 300 |
|
||||
| - | - | uiQueryLimit | Default traces query max size | SW_QUERY_ZIPKIN_UI_QUERY_LIMIT | 10 |
|
||||
| - | - | uiDefaultLookback | Default look back on the UI for search traces, 15 minutes in millis | SW_QUERY_ZIPKIN_UI_DEFAULT_LOOKBACK | 900000 |
|
||||
| promql | default | - | This module is for PromQL API. | - | |
|
||||
| - | - | restHost | Binding IP of RESTful services. | SW_PROMQL_REST_HOST | 0.0.0.0 |
|
||||
| - | - | restPort | Binding port of RESTful services. | SW_PROMQL_REST_PORT | 9090 |
|
||||
| - | - | restContextPath | Web context path of RESTful services. | SW_PROMQL_REST_CONTEXT_PATH | / |
|
||||
| - | - | restMaxThreads | Maximum thread number of RESTful services. | SW_PROMQL_REST_MAX_THREADS | 200 |
|
||||
| - | - | restIdleTimeOut | Connector idle timeout of RESTful services (in milliseconds). | SW_PROMQL_REST_IDLE_TIMEOUT | 30000 |
|
||||
| - | - | restAcceptQueueSize | Maximum request header size accepted. | SW_PROMQL_REST_QUEUE_SIZE | 0 |
|
||||
| alarm | default | - | Read [alarm doc](backend-alarm.md) for more details. | - | |
|
||||
| telemetry | - | - | Read [telemetry doc](backend-telemetry.md) for more details. | - | |
|
||||
| - | none | - | No op implementation. | - | |
|
||||
|
|
|
|||
|
|
@ -88,6 +88,9 @@ public enum DurationUtils {
|
|||
|
||||
List<PointOfTime> durations = new LinkedList<>();
|
||||
durations.add(new PointOfTime(startTimeBucket));
|
||||
if (startTimeBucket == endTimeBucket) {
|
||||
return durations;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
do {
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ GT: '>';
|
|||
|
||||
// Literals
|
||||
NUMBER: Digit+ (DOT Digit+)?;
|
||||
DURATION: Digit+ ('s' | 'm' | 'h' | 'd' | 'w' | 'y');
|
||||
DURATION: Digit+ ('ms' | 's' | 'm' | 'h' | 'd' | 'w');
|
||||
NAME_STRING: NameLetter+;
|
||||
VALUE_STRING: '\'' .*? '\'' | '"' .*? '"';
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,6 @@ public class PromQLApiHandler {
|
|||
}
|
||||
|
||||
@Get
|
||||
@Post
|
||||
@Path("/api/v1/metadata")
|
||||
public HttpResponse metadata(
|
||||
@Param("limit") Optional<Integer> limit,
|
||||
|
|
@ -174,7 +173,6 @@ public class PromQLApiHandler {
|
|||
* reserve these param to keep consistent with API protocol.
|
||||
*/
|
||||
@Get
|
||||
@Post
|
||||
@Path("/api/v1/label/{label_name}/values")
|
||||
public HttpResponse labelValues(
|
||||
@Param("label_name") String labelName,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ import org.apache.skywalking.oap.server.core.query.input.Duration;
|
|||
import org.apache.skywalking.oap.server.core.query.type.MetricsValues;
|
||||
import org.apache.skywalking.promql.rt.grammar.PromQLParser;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.format.PeriodFormatter;
|
||||
import org.joda.time.format.PeriodFormatterBuilder;
|
||||
|
||||
public class PromOpUtils {
|
||||
//Adopt skywalking time step.
|
||||
|
|
@ -252,4 +254,22 @@ public class PromOpUtils {
|
|||
DecimalFormat format = new DecimalFormat("#.##");
|
||||
return format.format(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format duration string to org.joda.time.Duration.
|
||||
* Don't support year and month because the days vary in length.
|
||||
* @param duration such as "5d", "30m", "5d30m, "1w, "1w5d"
|
||||
* @return org.joda.time.Duration
|
||||
*/
|
||||
public static org.joda.time.Duration formatDuration(String duration) {
|
||||
PeriodFormatter f = new PeriodFormatterBuilder()
|
||||
.appendWeeks().appendSuffix("w")
|
||||
.appendDays().appendSuffix("d")
|
||||
.appendHours().appendSuffix("h")
|
||||
.appendMinutes().appendSuffix("m")
|
||||
.appendSeconds().appendSuffix("s")
|
||||
.appendMillis().appendSuffix("ms")
|
||||
.toFormatter();
|
||||
return f.parsePeriod(duration).toStandardDuration();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ import org.apache.skywalking.promql.rt.grammar.PromQLParser;
|
|||
import org.apache.skywalking.promql.rt.grammar.PromQLParserBaseVisitor;
|
||||
|
||||
import static org.apache.skywalking.oap.query.promql.rt.PromOpUtils.buildMatrixValues;
|
||||
import static org.apache.skywalking.oap.query.promql.rt.PromOpUtils.formatDuration;
|
||||
import static org.apache.skywalking.oap.query.promql.rt.PromOpUtils.matrixBinaryOp;
|
||||
import static org.apache.skywalking.oap.query.promql.rt.PromOpUtils.matrixCompareOp;
|
||||
import static org.apache.skywalking.oap.query.promql.rt.PromOpUtils.matrixScalarBinaryOp;
|
||||
|
|
@ -247,9 +248,9 @@ public class PromQLExprQueryVisitor extends PromQLParserBaseVisitor<ParseResult>
|
|||
return result;
|
||||
}
|
||||
|
||||
String timeRange = "PT" + ctx.DURATION().getText().toUpperCase();
|
||||
String timeRange = ctx.DURATION().getText().toUpperCase();
|
||||
long endTS = System.currentTimeMillis();
|
||||
long startTS = endTS - java.time.Duration.parse(timeRange).toMillis();
|
||||
long startTS = endTS - formatDuration(timeRange).getMillis();
|
||||
duration = timestamp2Duration(startTS, endTS);
|
||||
ParseResult result = visit(ctx.metricInstant());
|
||||
result.setRangeExpression(true);
|
||||
|
|
|
|||
|
|
@ -435,12 +435,13 @@ query-zipkin:
|
|||
# Default look back on the UI for search traces, 15 minutes in millis
|
||||
uiDefaultLookback: ${SW_QUERY_ZIPKIN_UI_DEFAULT_LOOKBACK:900000}
|
||||
|
||||
#This module is for PromQL API.
|
||||
promql:
|
||||
selector: ${SW_PROMQL:default}
|
||||
default:
|
||||
# For HTTP server
|
||||
restHost: ${SW_PROMQL_REST_HOST:0.0.0.0}
|
||||
restPort: ${SW_PROMQL_REST_PORT:9099}
|
||||
restPort: ${SW_PROMQL_REST_PORT:9090}
|
||||
restContextPath: ${SW_PROMQL_REST_CONTEXT_PATH:/}
|
||||
restMaxThreads: ${SW_PROMQL_REST_MAX_THREADS:200}
|
||||
restIdleTimeOut: ${SW_PROMQL_REST_IDLE_TIMEOUT:30000}
|
||||
|
|
|
|||
Loading…
Reference in New Issue