public String convertDorisSqlCount()

in ozhera-monitor/ozhera-monitor-service/src/main/java/org/apache/ozhera/monitor/service/model/prometheus/MetricDetailQuery.java [192:248]


    public String convertDorisSqlCount(){

        StringBuilder sqlBuilder = new StringBuilder();
        sqlBuilder.append("select count(1) as total from hera_error_slow_trace where 1=1 ");
        sqlBuilder.append(" and serviceName='").append(projectId).append("_").append(projectName.replaceAll("-","_")).append("' ");
        sqlBuilder.append(" and host='").append(serverIp).append("' ");
        sqlBuilder.append(" and type='").append(type).append("' ");
        sqlBuilder.append(" and errorType='").append(errorType).append("' ");

        if(EsIndexDataType.http.name().equals(type)
                ||EsIndexDataType.http_client.name().equals(type)
                ||EsIndexDataType.mq_consumer.name().equals(type)
                ||EsIndexDataType.mq_producer.name().equals(type)
                ||EsIndexDataType.redis.name().equals(type) ){
            sqlBuilder.append(" and url='").append(methodName).append("' ");
        }

        if(EsIndexDataType.dubbo_consumer.name().equals(type)
                || EsIndexDataType.dubbo_provider.name().equals(type)
                ||EsIndexDataType.grpc_client.name().equals(type)
                ||EsIndexDataType.grpc_server.name().equals(type)
                ||EsIndexDataType.thrift_client.name().equals(type)
                ||EsIndexDataType.thrift_server.name().equals(type)
                ||EsIndexDataType.apus_client.name().equals(type)
                ||EsIndexDataType.apus_server.name().equals(type)
        ){
            sqlBuilder.append(" and url='").append(serviceName + "/" + methodName).append("' ");
        }

        if(EsIndexDataType.mysql.name().equals(type)
                || EsIndexDataType.oracle.name().equals(type)
                || EsIndexDataType.hbase.name().equals(type)
                || EsIndexDataType.elasticsearch.name().equals(type)){
            sqlBuilder.append(" and dataSource='").append(dataSource).append("' ");
            sqlBuilder.append(" and url like '%").append(sql).append("%' ");
        }

        if(startTime != null){
            sqlBuilder.append(" and timestamp>=").append(startTime).append(" ");
        }

        if(endTime != null){
            sqlBuilder.append(" and timestamp<=").append(endTime).append(" ");
        }

        if(page == null || page.intValue() < 1){
            page = 1;
        }
        if(pageSize == null || pageSize.intValue() < 1){
            pageSize = 20;
        }

        sqlBuilder.append(" limit ").append((page-1)*pageSize).append(",").append(pageSize);

        return sqlBuilder.toString();

    }