public void buildDetailRedirectUrl()

in ozhera-monitor/ozhera-monitor-service/src/main/java/org/apache/ozhera/monitor/service/helper/AlertHelperExtensionImpl.java [81:136]


    public void buildDetailRedirectUrl(String user, AppMonitor app, String alert, JsonObject jsonSummary, JsonObject labels) {
        if (labels == null) {
            return;
        }
        if (labels.has(ConstUtil.detailRedirectUrl)) {
            log.info("指标{}已经包含detailRedirectUrl={}", alert, labels);
            return;
        }
        AlarmPresetMetricsPOJO metric = alarmPresetMetricsService.getByCode(alert);
        if (metric == null || metric.getBasicUrlType() == null) {
            return;
        }
        labels.addProperty("ip", "{{$labels.ip}}");
        labels.addProperty("serverIp", "{{$labels.serverIp}}");
        labels.addProperty("job", "{{$labels.job}}");
        labels.addProperty("group", "{{$labels.group}}");
        if ((BasicUrlType.hera_dash_ip.getName().equals(metric.getBasicUrlType().getName()) || BasicUrlType.hera_dash_sip.getName().equals(metric.getBasicUrlType().getName())) && StringUtils.isNotBlank(heraDashUrl)) {
            Map<String, Object> params = new HashMap<>();
            params.put("id", app.getProjectId());
            params.put("name", app.getProjectName());
            String url = buildUrl(heraDashUrl, metric, params);
            if (StringUtils.isNotBlank(url)) {
                labels.addProperty(ConstUtil.detailRedirectUrl, url);
            }
            JsonObject json = metric.getBasicUrlType().getReqJsonObject();
            if (json != null) {
                jsonSummary.addProperty(ConstUtil.paramMapping,json.toString());
                labels.addProperty(ConstUtil.paramType,"normal");
            }
        } else if ((BasicUrlType.cn_grafana_ip.getName().equals(metric.getBasicUrlType().getName()) || BasicUrlType.cn_grafana_sip.getName().equals(metric.getBasicUrlType().getName()) || BasicUrlType.cn_grafana_ip_1d.getName().equals(metric.getBasicUrlType().getName()) || BasicUrlType.cn_grafana_sip_1d.getName().equals(metric.getBasicUrlType().getName())) && StringUtils.isNotBlank(cnGrafanaUrl)) {
            Map<String, Object> params = new HashMap<>();
            params.put("orgId", 1);
            params.put("refresh", "10s");
            String url = buildUrl(cnGrafanaUrl, metric, params);
            if (StringUtils.isNotBlank(url)) {
                labels.addProperty(ConstUtil.detailRedirectUrl, url);
            }
            JsonObject json = metric.getBasicUrlType().getReqJsonObject();
            if (json != null) {
                jsonSummary.addProperty(ConstUtil.paramMapping,json.toString());
                labels.addProperty(ConstUtil.paramType,"normal");
            }
        } else if (BasicUrlType.cn_grafana_disk_rate.getName().equals(metric.getBasicUrlType().getName()) && StringUtils.isNotBlank(cnGrafanaDiskRateUrl)) {
            Map<String, Object> params = new HashMap<>();
            params.put("orgId", 1);
            String url = buildUrl(cnGrafanaDiskRateUrl, metric, params);
            if (StringUtils.isNotBlank(url)) {
                labels.addProperty(ConstUtil.detailRedirectUrl, url);
            }
            JsonObject json = metric.getBasicUrlType().getReqJsonObject();
            if (json != null) {
                jsonSummary.addProperty(ConstUtil.paramMapping,json.toString());
                labels.addProperty(ConstUtil.paramType,"normal");
            }
        }
    }