提交 c0629f94 编写于 作者: Y youyong205

modify the metric title builder

上级 cd2a1380
......@@ -63,7 +63,6 @@ public class AggregationGraphCreator extends BaseGraphCreator {
private Pair<String, LineChart> buildAggerationChart(final Map<String, double[]> datas, Date startDate,
Date endDate, final Map<String, double[]> dataWithOutFutures, MetricAggregation metricAggregation) {
MetricAggregationGroup metricAggregationGroup = m_metricAggregationConfigManager.getMetricAggregationConfig()
.findMetricAggregationGroup(m_aggregationGroup);
List<MetricItemConfig> alertItems = m_alertInfo.getLastestAlarm(5);
......@@ -88,7 +87,7 @@ public class AggregationGraphCreator extends BaseGraphCreator {
String itemKey = domain + ":" + type + ":" + metricAggregationItem.getKey() + ":" + displayType.toUpperCase();
if (dataWithOutFutures.containsKey(itemKey)) {
buildLineChartTitle(alertItems, lineChart, itemKey, title);
buildLineChartTitle(alertItems, lineChart, itemKey);
Map<Long, Double> all = convertToMap(datas.get(itemKey), startDate, 1);
Map<Long, Double> current = convertToMap(dataWithOutFutures.get(itemKey), startDate, step);
......
......@@ -62,8 +62,10 @@ public abstract class BaseGraphCreator implements LogEnabled {
protected void addLastMinuteData(Map<Long, Double> current, Map<Long, Double> all, int minute, Date end) {
int step = m_dataExtractor.getStep();
if (step == 1)
if (step == 1) {
return;
}
long endTime = 0;
long currentTime = System.currentTimeMillis();
if (end.getTime() > currentTime) {
......@@ -95,21 +97,10 @@ public abstract class BaseGraphCreator implements LogEnabled {
protected void buildLineChartTitle(List<MetricItemConfig> alertItems, LineChart chart, String key) {
int index = key.lastIndexOf(":");
String id = key.substring(0, index);
String metricId = key.substring(0, index);
String type = key.substring(index + 1);
MetricItemConfig config = m_metricConfigManager.queryMetricItemConfig(id);
String metricId = m_metricConfigManager.buildMetricKey(config.getDomain(), config.getType(),
config.getMetricKey());
String des = "";
config.setId(metricId);
if (MetricType.AVG.name().equals(type)) {
des = Chinese.Suffix_AVG;
} else if (MetricType.SUM.name().equals(type)) {
des = Chinese.Suffix_SUM;
} else if (MetricType.COUNT.name().equals(type)) {
des = Chinese.Suffix_COUNT;
}
MetricItemConfig config = m_metricConfigManager.queryMetricItemConfig(metricId);
String des = queryMetricItemDes(type);
String title = config.getTitle() + des;
chart.setTitle(title);
......@@ -122,24 +113,18 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
}
public void buildLineChartTitle(List<MetricItemConfig> alertItems, LineChart chart, String key, String title) {
if (chart.getHtmlTitle().contains("<span style='color:red'>")) {
return;
}
int index = key.lastIndexOf(":");
String id = key.substring(0, index);
MetricItemConfig config = m_metricConfigManager.queryMetricItemConfig(id);
String metricId = m_metricConfigManager.buildMetricKey(config.getDomain(), config.getType(),
config.getMetricKey());
config.setId(metricId);
private String queryMetricItemDes(String type) {
String des = "";
if (alertItems.contains(config)) {
chart.setHtmlTitle("<span style='color:red'>" + title + "</span>");
} else {
chart.setHtmlTitle(title);
if (MetricType.AVG.name().equals(type)) {
des = Chinese.Suffix_AVG;
} else if (MetricType.SUM.name().equals(type)) {
des = Chinese.Suffix_SUM;
} else if (MetricType.COUNT.name().equals(type)) {
des = Chinese.Suffix_COUNT;
}
}
return des;
}
protected double[] convert(double[] value, int removeLength) {
int length = value.length;
......@@ -202,7 +187,7 @@ public abstract class BaseGraphCreator implements LogEnabled {
for (; start < end; start += TimeUtil.ONE_HOUR) {
Map<String, double[]> currentValues = queryMetricValueByDate(productLine, start);
mergeMap(oldCurrentValues, currentValues, totalSize, index);
index++;
}
......@@ -234,7 +219,7 @@ public abstract class BaseGraphCreator implements LogEnabled {
MetricReport metricReport = m_metricReportService.queryMetricReport(productLine, new Date(start));
List<String> domains = m_productLineConfigManager.queryDomainsByProductLine(productLine);
List<MetricItemConfig> metricConfigs = m_metricConfigManager.queryMetricItemConfigs(domains);
Collections.sort(metricConfigs, new Comparator<MetricItemConfig>() {
@Override
public int compare(MetricItemConfig o1, MetricItemConfig o2) {
......@@ -254,7 +239,8 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
// if current report is not exist, use last day value replace it.
if (sum <= 0 && start < TimeUtil.getCurrentHour().getTime()) {
MetricReport lastMetricReport = m_metricReportService.queryMetricReport(productLine, new Date(start - TimeUtil.ONE_DAY));
MetricReport lastMetricReport = m_metricReportService.queryMetricReport(productLine, new Date(start
- TimeUtil.ONE_DAY));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss");
m_logger.error("Replace error value, Metric report is not exsit, productLine:" + productLine + " ,date:"
......@@ -269,8 +255,8 @@ public abstract class BaseGraphCreator implements LogEnabled {
// remove the minute of future
Map<String, double[]> newCurrentValues = new LinkedHashMap<String, double[]>();
int step = m_dataExtractor.getStep();
if (step <= 0){
if (step <= 0) {
return allCurrentValues;
}
int minute = Calendar.getInstance().get(Calendar.MINUTE);
......@@ -295,7 +281,7 @@ public abstract class BaseGraphCreator implements LogEnabled {
}
values.put(key, value);
}
protected void put(Map<String, LineChart> charts, Map<String, LineChart> result, String key) {
LineChart value = charts.get(key);
......
......@@ -36,7 +36,6 @@ public class DefaultAggGraphCreator extends GraphCreator {
@Override
public Map<String, LineChart> buildChartData(final Map<String, double[]> datas, Date startDate, Date endDate,
final Map<String, double[]> dataWithOutFutures) {
Map<String, List<String>> aggregationKeys = buildLineChartKeys(dataWithOutFutures.keySet());
Map<String, LineChart> charts = new LinkedHashMap<String, LineChart>();
List<MetricItemConfig> alertItems = m_alertInfo.getLastestAlarm(5);
......@@ -54,7 +53,7 @@ public class DefaultAggGraphCreator extends GraphCreator {
for (String key : keyMapEntry.getValue()) {
if (dataWithOutFutures.containsKey(key)) {
buildLineChartTitle(alertItems, lineChart, key, chartTitle);
buildLineChartTitle(alertItems, lineChart, key);
double[] baselines = queryBaseline(key, startDate, endDate);
Map<Long, Double> all = convertToMap(datas.get(key), startDate, 1);
......
......@@ -12,7 +12,7 @@ public class AlertInfo {
private ConcurrentHashMap<MetricItemConfig, Long> m_alerts = new ConcurrentHashMap<MetricItemConfig, Long>();
public void addMetric(MetricItemConfig config, long value) {
public void addAlertInfo(MetricItemConfig config, long value) {
m_alerts.putIfAbsent(config, value);
}
......
......@@ -183,7 +183,7 @@ public class MetricAlert extends BaseAlert implements Task, LogEnabled {
if (alert != null && alert.getKey()) {
config.setId(m_metricConfigManager.buildMetricKey(config.getDomain(), config.getType(), config.getMetricKey()));
m_alertInfo.addMetric(config, new Date().getTime());
m_alertInfo.addAlertInfo(config, new Date().getTime());
sendAlertInfo(productLine, config, alert.getValue());
}
}
......
......@@ -124,7 +124,7 @@ public class SwitchAlert extends BaseAlert implements Task, LogEnabled {
if (alert != null && alert.getKey()) {
config.setId(m_metricConfigManager.buildMetricKey(config.getDomain(), config.getType(), config.getMetricKey()));
m_alertInfo.addMetric(config, new Date().getTime());
m_alertInfo.addAlertInfo(config, new Date().getTime());
sendAlertInfo(productLine, config, alert.getValue());
}
}
......
......@@ -73,27 +73,27 @@
<th width="10%">产品线</th>
<th width="10%">标题</th>
<th width="5%">顺序</th>
<th width="5%">错误监控</th>
<th width="5%">业务监控</th>
<th width="5%">外部监控</th>
<th width="5%">应用监控</th>
<th width="5%">网络监控</th>
<th width="5%">系统监控</th>
<th width="5%">外部监控</th>
<th width="40%">项目列表</th>
<th width="10%">操作 <a href="?op=topologyProductLineAdd&type=${type}" class='update btn btn-primary btn-small'>新增</a></th>
</tr>
<c:forEach var="item" items="${listItem.value}" varStatus="status">
<tr><td>${item.id}</td><td>${item.title}</td>
<td>${item.order}</td>
<td><c:if test="${item.dashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.dashboard}"><span><strong></strong></span></c:if> </td>
<td><c:if test="${item.metricDashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.metricDashboard}"><span><strong></strong></span></c:if> </td>
<td><c:if test="${item.userMonitorDashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.userMonitorDashboard}"><span><strong></strong></span></c:if> </td>
<td><c:if test="${item.applicationDashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.applicationDashboard}"><span><strong></strong></span></c:if> </td>
<td><c:if test="${item.networkDashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.networkDashboard}"><span><strong></strong></span></c:if> </td>
<td><c:if test="${item.systemMonitorDashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.systemMonitorDashboard}"><span><strong></strong></span></c:if> </td>
<td><c:if test="${item.userMonitorDashboard}"><span class="text-error"><strong></strong></span></c:if>
<c:if test="${!item.userMonitorDashboard}"><span><strong></strong></span></c:if> </td>
<td>
<c:forEach var="domain" items="${item.domains}">
${domain.key},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册