You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by "wankai123 (via GitHub)" <gi...@apache.org> on 2024/05/07 06:57:05 UTC

[PR] MQE support `sort_values` and `sort_label_values` functions. [skywalking]

wankai123 opened a new pull request, #12193:
URL: https://github.com/apache/skywalking/pull/12193

   - [ ] If this is non-trivial feature, paste the links/URLs to the design doc.
   - [X] Update the documentation to include this new feature.
   - [X] Tests(including UT, IT, E2E) are added to verify the new feature.
   - [ ] If it's UI related, attach the screenshots below.
   
   - [X] If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #12121.
   - [X] Update the [`CHANGES` log](https://github.com/apache/skywalking/blob/master/docs/en/changes/changes.md).
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MQE support `sort_values` and `sort_label_values` functions. [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng commented on code in PR #12193:
URL: https://github.com/apache/skywalking/pull/12193#discussion_r1591910600


##########
docs/en/api/metrics-query-expression.md:
##########
@@ -379,6 +378,62 @@ V(T1)-V(T1-2), V(T2)-V(T1-1), V(T3)-V(T1)
 ### Result Type
 TIME_SERIES_VALUES.
 
+## Sort Operation
+### SortValues Operation
+SortValues Operation takes an expression and sorts the values of the input expression result.
+
+Expression:
+```text
+sort_values(Expression, <limit>, <order>)
+```
+- `limit` is the number of the sort results, should be a positive integer, if not specified, will return all results. Optional.
+- `order` is the order of the sort results. The value of `order` can be `asc` or `des`.
+
+For example:
+If we want to sort the `service_resp_time` metric values in descending order and get the top 10 values, we can use the following expression:
+```text
+sort_values(service_resp_time, 10, des)
+```
+
+#### Result Type
+The result type follows the input expression.
+
+### SortLabelValues Operation
+SortLabelValues Operation takes an expression and sorts the label values of the input expression result. This function uses `natural sort order`.
+
+Expression:
+```text
+sort_label_values(Expression, <order>, <label1_name>, <label2_name> ...)
+```
+- `order` is the order of the sort results. The value of `order` can be `asc` or `des`.
+- `<label1_name>, <label2_name> ...` is the label names that need to be sorted by their values. At least one label name should be specified.
+The labels in the head of the list will be sorted first, and if the label not be included in the expression result will be ignored.
+
+For example:
+If we want to sort the `service_percentile` metric label values in descending order by the `p` label, we can use the following expression:
+```text
+sort_label_values(service_percentile{p='50,75,90,95,99'}, des, p)
+```
+
+For multiple labels, assume the metric has 2 labels:
+```text
+metric{label1='1', label2='21'} 
+metric{label1='1', label2='22'}
+metric{label1='2', label2='21'}
+metric{label1='2', label2='22'}

Review Comment:
   How about when label values are string? I think we should be more specific for String#compare. 



-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MQE support `sort_values` and `sort_label_values` functions. [skywalking]

Posted by "wu-sheng (via GitHub)" <gi...@apache.org>.
wu-sheng merged PR #12193:
URL: https://github.com/apache/skywalking/pull/12193


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org