public Result fetchAggregatedMetrics()

in src/main/java/org/opensearch/performanceanalyzer/reader/MasterThrottlingMetricsSnapshot.java [118:241]


    public Result<Record> fetchAggregatedMetrics() {

        List<SelectField<?>> fields =
                new ArrayList<SelectField<?>>() {
                    {
                        this.add(
                                DSL.sum(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                        .toString()),
                                                        Long.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.SUM)));
                        this.add(
                                DSL.avg(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                        .toString()),
                                                        Double.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.AVG)));
                        this.add(
                                DSL.min(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                        .toString()),
                                                        Long.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.MIN)));
                        this.add(
                                DSL.max(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                        .toString()),
                                                        Long.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .MASTER_THROTTLED_PENDING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.MAX)));

                        this.add(
                                DSL.sum(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .DATA_RETRYING_TASK_COUNT
                                                                        .toString()),
                                                        Long.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .DATA_RETRYING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.SUM)));
                        this.add(
                                DSL.avg(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .DATA_RETRYING_TASK_COUNT
                                                                        .toString()),
                                                        Double.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .DATA_RETRYING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.AVG)));
                        this.add(
                                DSL.min(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .DATA_RETRYING_TASK_COUNT
                                                                        .toString()),
                                                        Long.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .DATA_RETRYING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.MIN)));
                        this.add(
                                DSL.max(
                                                DSL.field(
                                                        DSL.name(
                                                                AllMetrics.MasterThrottlingValue
                                                                        .DATA_RETRYING_TASK_COUNT
                                                                        .toString()),
                                                        Long.class))
                                        .as(
                                                DBUtils.getAggFieldName(
                                                        AllMetrics.MasterThrottlingValue
                                                                .DATA_RETRYING_TASK_COUNT
                                                                .toString(),
                                                        MetricsDB.MAX)));
                    }
                };
        ArrayList<Field<?>> groupByFields = new ArrayList<Field<?>>();

        return create.select(fields).from(DSL.table(this.tableName)).groupBy(groupByFields).fetch();
    }