Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature(new_metrics): support filters for selected metric fields in response #1236

Closed
Tracked by #1206
empiredan opened this issue Nov 10, 2022 · 0 comments
Closed
Tracked by #1206
Labels
type/enhancement Indicates new feature requests

Comments

@empiredan
Copy link
Contributor

empiredan commented Nov 10, 2022

1. Motivation

According to #1206, with_metric_fields and without_metric_fields will be provided as the parameters in the RESTful API to filter the fields of metric in the response to client.

2. Usage for with_metric_fields

with_metric_fields will ask for the metric fields that are not included in the request. For example, if the request is given as below:

/metrics?with_metric_fields=value,p99

The response will only contain the fields of "value" and "p99":

[
    { // entity 1
        "metrics": [
            // gauge
            {
                "value": 100
            },
            // counter
            {
                "value": 10000
            },
            // percentile
            {
                "p99": 10
            }
        ]
    },
    ...
]

3. Usage for without_metric_fields

Similarly, without_metric_fields will ask for the metric fields that are not included in the request. For example, if the request is given as below:

/metrics?without_metric_fields=value,p99

The response will contain all the fields except "value" and "p99":

[
    { // entity 1
        "metrics": [
            // gauge
            {
                "name": "<gauge_name>"
            },
            // counter
            {
                "name": "<counter_name>"
            },
            // percentile
            {
                "name": "<percentile_name>",
                "p50": 1,
                "p90": 5,
                "p95": 8,
                "p999": 15
            }
        ]
    },
    ...
]

4. Wrong usage

Once both with_metric_fields and without_metric_fields are provided in the request, it will considered as invalid. We can discuss the reason in 2 conditions.

Firstly, suppose both with_metric_fields and without_metric_fields are provided, and they include the same fields. In this condition, each conflicts with another. For example, with_metric_fields=a,b and without_metric_fields=b,c will lead to contradiction: we cannot decide if b should be put in the response to client.

On the contrary, suppose with_metric_fields and without_metric_fields do not include any same field. In this condition, they can be simplified as a unique with_metric_fields. For example, with_metric_fields=a,b and without_metric_fields=c,d can be simplified as with_metric_fields=a,b: without_metric_fields=c,d is useless here since we have declared that only a and b fields are needed according to with_metric_fields=a,b.

Therefore, we can draw a conclusion that with_metric_fields and without_metric_fields should not be provided at the same time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement Indicates new feature requests
Projects
None yet
Development

No branches or pull requests

1 participant