wu-sheng opened a new pull request #4725: URL: https://github.com/apache/skywalking/pull/4725
## Percentile Function Read [percentile in WIKI](https://en.wikipedia.org/wiki/Percentile). Unlike in the OAL, we provide 50/75/90/95/99 in default, in the meter system function, percentile function accepts several ranks, which should be in the (0, 100) range. ## API Usage ```java meterSystem.create( "test_percentile_metrics", "percentile", ScopeType.SERVICE, PercentileFunction.PercentileArgument.class ); // Percentile Example final AcceptableValue<PercentileFunction.PercentileArgument> testPercentileMetrics = service.buildMetrics( "test_percentile_metrics", PercentileFunction.PercentileArgument.class); testPercentileMetrics.setTimeBucket(TimeBucket.getMinuteTimeBucket(System.currentTimeMillis())); testPercentileMetrics.accept( MeterEntity.newService("service-test"), new PercentileFunction.PercentileArgument( new BucketedValues( // Buckets new int[] { 0, 51, 100, 250 }, // Values new long[] { 10, 20, 30, 40 } ), // Ranks new int[] { 50, 90 } ) ); service.doStreamingCalculation(testPercentileMetrics); ``` ## Constraint Condition 1. The buckets and percentile ranks should be consistent for every metrics name. Otherwise, data will be abandoned. ## GraphQL query ```graphql { readLabeledMetricsValues(condition : { name: "test_percentile_metrics", entity: { scope: Service, serviceName: "service-test", normal: true, } }, labels: ["50", "90", "no-labled"] duration: {step:MINUTE, start: "2020-04-28 1100", end: "2020-04-28 1105"} ) { label, values { values { id, value } } } } ``` ```graphql { "data": { "readLabeledMetricsValues": [ { # Even label doesn't exist in the declaration stage, no error happens. "label": "no-labled", "values": { "values": [ { "id": "202004281100_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281101_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281102_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281103_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281104_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281105_c2VydmljZS10ZXN0.1", "value": 0 } ] } }, { "label": "50", "values": { "values": [ { "id": "202004281100_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281101_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281102_c2VydmljZS10ZXN0.1", "value": 100 }, { "id": "202004281103_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281104_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281105_c2VydmljZS10ZXN0.1", "value": 0 } ] } }, { "label": "90", "values": { "values": [ { "id": "202004281100_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281101_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281102_c2VydmljZS10ZXN0.1", "value": 250 }, { "id": "202004281103_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281104_c2VydmljZS10ZXN0.1", "value": 0 }, { "id": "202004281105_c2VydmljZS10ZXN0.1", "value": 0 } ] } } ] } } ``` ## Data in the storage  ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
