Skip to content

Allow setting default_metric for numerics #132626

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

limotova
Copy link
Contributor

@limotova limotova commented Aug 11, 2025

This commit adds in an option in the field mapping for numerics where, if the numeric has time_series_metric set to gauge, you can set a default_metric, so when the field is downsampled, the resulting aggregate_metric_double gets that specified field as its default_metric. If no default_metric is specified, the resulting aggregate_metric_double will have max as its default, as was before.

Example mappings:

"my-default-min-metric": {
    "time_series_metric": "gauge",
    "type": "integer",
    "default_metric": "min"
},
"my-other-metric": {
    "time_series_metric": "gauge",
    "type": "integer"
}

becomes this after downsampling:

"my-default-min-metric": {
    "type": "aggregate_metric_double",
    "metrics": [
        "min",
        "max",
        "sum",
        "value_count"
    ],
    "default_metric": "min",
    "time_series_metric": "gauge"
},
"my-other-metric": {
    "type": "aggregate_metric_double",
    "metrics": [
        "min",
        "max",
        "sum",
        "value_count"
    ],
    "default_metric": "max",
    "time_series_metric": "gauge"
}

@limotova limotova force-pushed the default-metric branch 3 times, most recently from ecd0d83 to ee2eeac Compare August 11, 2025 02:31
@@ -783,6 +783,11 @@ public static AggregateMetricDoubleFieldSupportedMetrics getSupportedMetrics(
(String) fieldProperties.get(AggregateMetricDoubleFieldMapper.Names.DEFAULT_METRIC),
defaultMetric
);
} else {
defaultMetric = Objects.requireNonNullElse(
(String) fieldProperties.get(TimeSeriesParams.TIME_SERIES_DEFAULT_METRIC_PARAM),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works out to be the same logic as above (in the sourceIsAggregate branch) because the names of the option is the same (default_metric), but I wasn't sure if we wanted to maybe have a different name in the option when it's a numeric (like maybe to make it more clear to users what default_metric is referring to)

Copy link
Contributor

@jordan-powers jordan-powers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@jordan-powers jordan-powers added the :StorageEngine/Downsampling Downsampling (replacement for rollups) - Turn fine-grained time-based data into coarser-grained data label Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:StorageEngine/Downsampling Downsampling (replacement for rollups) - Turn fine-grained time-based data into coarser-grained data v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants