Skip to content

Commit

Permalink
[#8004] Change applicationName to hostGroupId, change schema to add s…
Browse files Browse the repository at this point in the history
…erviceId
  • Loading branch information
minwoo-jung committed Aug 30, 2021
1 parent 906b98b commit 7ba13a9
Show file tree
Hide file tree
Showing 12 changed files with 48 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.navercorp.pinpoint.metric.collector.service.SystemMetricService;
import com.navercorp.pinpoint.metric.collector.service.SystemMetricTagService;
import com.navercorp.pinpoint.metric.common.model.DoubleMetric;
import com.navercorp.pinpoint.metric.common.model.LongMetric;
import com.navercorp.pinpoint.metric.common.model.Metrics;
import com.navercorp.pinpoint.metric.common.model.SystemMetric;
import com.navercorp.pinpoint.metric.common.model.Tag;
Expand Down Expand Up @@ -70,22 +69,22 @@ public TelegrafMetricController(SystemMetricService systemMetricService,

@PostMapping(value = "/telegraf")
public ResponseEntity<Void> saveSystemMetric(
@RequestHeader(value = "Application-Name") String applicationName,
@RequestHeader(value = "hostGroupId") String hostGroupId,
@RequestBody TelegrafMetrics telegrafMetrics, BindingResult bindingResult
) throws BindException {
if (bindingResult.hasErrors()) {
SimpleErrorMessage simpleErrorMessage = new SimpleErrorMessage(bindingResult);
logger.warn("metric binding error. header=Application-Name:{} errorCount:{} {}", applicationName, bindingResult.getErrorCount(), simpleErrorMessage);
logger.warn("metric binding error. header=hostGroupId:{} errorCount:{} {}", hostGroupId, bindingResult.getErrorCount(), simpleErrorMessage);
throw new BindException(bindingResult);
}

if (logger.isInfoEnabled()) {
String host = getHost(telegrafMetrics);
logger.info("Application-Name:{} host:{} size:{}", applicationName, host, telegrafMetrics.size());
logger.info("hostGroupId:{} host:{} size:{}", hostGroupId, host, telegrafMetrics.size());
}
logger.info("telegrafMetrics:{}", telegrafMetrics);

Metrics systemMetric = toMetrics(applicationName, telegrafMetrics);
Metrics systemMetric = toMetrics(hostGroupId, telegrafMetrics);

updateMetadata(systemMetric);
systemMetricService.insert(systemMetric);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public PinotSystemMetricDoubleDao(KafkaTemplate<String, SystemMetricView> kafkaD
}

@Override
public void insert(String applicationName, List<DoubleMetric> systemMetrics) {
Objects.requireNonNull(applicationName, "applicationName");
public void insert(String hostGroupId, List<DoubleMetric> systemMetrics) {
Objects.requireNonNull(hostGroupId, "hostGroupId");
Objects.requireNonNull(systemMetrics, "systemMetrics");

for (DoubleMetric doubleMetric : systemMetrics) {
SystemMetricView systemMetricView = new SystemMetricView(applicationName, doubleMetric);
SystemMetricView systemMetricView = new SystemMetricView(hostGroupId, doubleMetric);
this.kafkaDoubleTemplate.send(topic, systemMetricView);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public PinotSystemMetricLongDao(KafkaTemplate<String, SystemMetricView> kafkaLon
}

@Override
public void insert(String applicationName, List<LongMetric> systemMetrics) {
Objects.requireNonNull(applicationName, "applicationName");
public void insert(String hostGroupId, List<LongMetric> systemMetrics) {
Objects.requireNonNull(hostGroupId, "hostGroupId");
Objects.requireNonNull(systemMetrics, "systemMetrics");

for (LongMetric longMetric : systemMetrics) {
SystemMetricView systemMetricView = new SystemMetricView(applicationName, longMetric);
SystemMetricView systemMetricView = new SystemMetricView(hostGroupId, longMetric);
this.kafkaLongTemplate.send(topic, systemMetricView);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
import java.util.Objects;

public class SystemMetricView {
private final String applicationName;
private final String hostGroupId;
private final SystemMetric metric;

public SystemMetricView(String applicationName, SystemMetric metric) {
this.applicationName = Objects.requireNonNull(applicationName, "applicationName");
public SystemMetricView(String hostGroupId, SystemMetric metric) {
this.hostGroupId = Objects.requireNonNull(hostGroupId, "hostGroupId");
this.metric = Objects.requireNonNull(metric, "metric");
}

public String getApplicationName() {
return applicationName;
public String getHostGroupId() {
return hostGroupId;
}

@JsonUnwrapped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public SystemMetricController(SystemMetricDataService systemMetricDataService, S
@Deprecated
@GetMapping(value = "/list")
public List<SystemMetric> getSystemMetricBoList(
@RequestParam("applicationName") String applicationName,
@RequestParam("hostGroupId") String hostGroupId,
@RequestParam("hostName") String hostName,
@RequestParam("metricName") String metricName,
@RequestParam("fieldName") String fieldName,
Expand All @@ -71,7 +71,7 @@ public List<SystemMetric> getSystemMetricBoList(
@RequestParam("to") long to) {

QueryParameter.Builder builder = new QueryParameter.Builder();
builder.setApplicationName(applicationName);
builder.setHostGroupId(hostGroupId);
builder.setHostName(hostName);
builder.setMetricName(metricName);
builder.setFieldName(fieldName);
Expand All @@ -85,15 +85,15 @@ public List<SystemMetric> getSystemMetricBoList(
@Deprecated
@GetMapping(value = "/chart")
public SystemMetricChart getSystemMetricChart(
@RequestParam("applicationName") String applicationName,
@RequestParam("hostGroupId") String hostGroupId,
@RequestParam("hostName") String hostName,
@RequestParam("metricName") String metricName,
@RequestParam("fieldName") String fieldName,
@RequestParam(value = "tags", required = false) List<String> tags,
@RequestParam("from") long from,
@RequestParam("to") long to) {
QueryParameter.Builder builder = new QueryParameter.Builder();
builder.setApplicationName(applicationName);
builder.setHostGroupId(hostGroupId);
builder.setHostName(hostName);
builder.setMetricName(metricName);
builder.setFieldName(fieldName);
Expand All @@ -111,7 +111,7 @@ public SystemMetricChart getSystemMetricChart(
@Deprecated
@GetMapping(value = "/chart", params = {"timeUnit", "timeSize"})
public SystemMetricChart getSystemMetricChart(
@RequestParam("applicationName") String applicationName,
@RequestParam("hostGroupId") String hostGroupId,
@RequestParam("hostName") String hostName,
@RequestParam("metricName") String metricName,
@RequestParam("fieldName") String fieldName,
Expand All @@ -123,7 +123,7 @@ public SystemMetricChart getSystemMetricChart(
TimePrecision timePrecision = TimePrecision.newTimePrecision(TimeUnit.valueOf(timeUnit.toUpperCase()), timeSize);

QueryParameter.Builder builder = new QueryParameter.Builder();
builder.setApplicationName(applicationName);
builder.setHostGroupId(hostGroupId);
builder.setHostName(hostName);
builder.setMetricName(metricName);
builder.setFieldName(fieldName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class QueryParameter {
private static final int TAG_SET_COUNT = 10;

private final String applicationName;
private final String hostGroupId;
private final String hostName;
private final String metricName;
private final String fieldName;
Expand All @@ -39,7 +39,7 @@ public class QueryParameter {
private final long limit;

public QueryParameter(Builder builder) {
this.applicationName = builder.applicationName;
this.hostGroupId = builder.hostGroupId;
this.hostName = builder.hostName;
this.metricName = builder.metricName;
this.fieldName = builder.fieldName;
Expand All @@ -49,8 +49,8 @@ public QueryParameter(Builder builder) {
this.limit = builder.limit;
}

public String getApplicationName() {
return applicationName;
public String getHostGroupId() {
return hostGroupId;
}

public String getHostName() {
Expand Down Expand Up @@ -82,7 +82,7 @@ public long getLimit() {
}

public static class Builder {
private String applicationName;
private String hostGroupId;
private String hostName;
private String metricName;
private String fieldName;
Expand All @@ -91,8 +91,8 @@ public static class Builder {
private TimePrecision timePrecision;
private long limit;

public void setApplicationName(String applicationName) {
this.applicationName = Objects.requireNonNull(applicationName, "applicationName");
public void setHostGroupId(String hostGroupId) {
this.hostGroupId = Objects.requireNonNull(hostGroupId, "applicationName");
}

public void setHostName(String hostName) {
Expand Down
7 changes: 6 additions & 1 deletion metric-module/metric/src/main/pinot/pinot-double-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"schemaName": "systemMetricDouble",
"dimensionFieldSpecs": [
{
"name": "applicationName",
"name": "serviceId",
"dataType": "STRING",
"defaultNullValue": ""
},
{
"name": "hostGroupId",
"dataType": "STRING"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"tenants": {},
"tableIndexConfig": {
"invertedIndexColumns": ["tags"],
"sortedColumn": ["applicationName"],
"sortedColumn": ["hostGroupId"],
"rangeIndexColumns": ["timestampInEpoch"],
"loadMode": "MMAP",
"nullHandlingEnabled": true,
Expand Down
7 changes: 6 additions & 1 deletion metric-module/metric/src/main/pinot/pinot-long-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
"schemaName": "systemMetricLong",
"dimensionFieldSpecs": [
{
"name": "applicationName",
"name": "serviceId",
"dataType": "STRING",
"defaultNullValue": ""
},
{
"name": "hostGroupId",
"dataType": "STRING"
},
{
Expand Down
2 changes: 1 addition & 1 deletion metric-module/metric/src/main/pinot/pinot-long-table.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"tenants": {},
"tableIndexConfig": {
"invertedIndexColumns": ["tags"],
"sortedColumn": ["applicationName"],
"sortedColumn": ["hostGroupId"],
"rangeIndexColumns": ["timestampInEpoch"],
"loadMode": "MMAP",
"nullHandlingEnabled": true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
tags,
timestampInEpoch
FROM systemMetricDouble
WHERE applicationName = #{applicationName}
WHERE hostGroupId = #{hostGroupId}
AND hostName = #{hostName}
AND metricName = #{metricName}
AND fieldName = #{fieldName}
Expand Down Expand Up @@ -53,7 +53,7 @@
DATETIME_CONVERT(timestampInEpoch, '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') AS avgTime,
tags
FROM systemMetricDouble
WHERE applicationName = #{applicationName}
WHERE hostGroupId = #{hostGroupId}
AND metricName = #{metricName}
AND hostName = #{hostName}
AND fieldName = #{fieldName}
Expand All @@ -71,7 +71,7 @@
AVG(fieldValue) AS avgValue,
DATETIME_CONVERT(timestampInEpoch, '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') AS avgTime
FROM systemMetricDouble
WHERE applicationName = #{hostGroupId}
WHERE hostGroupId = #{hostGroupId}
AND metricName = #{metricName}
AND hostName = #{hostName}
AND fieldName = #{fieldName}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
tags,
timestampInEpoch
FROM systemMetricLong
WHERE applicationName = #{applicationName}
WHERE hostGroupId = #{hostGroupId}
AND metricName = #{metricName}
AND hostName = #{hostName}
AND fieldName = #{fieldName}
Expand Down Expand Up @@ -54,7 +54,7 @@
DATETIME_CONVERT(timestampInEpoch, '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') AS avgTime,
tags
FROM systemMetricLong
WHERE applicationName = #{applicationName}
WHERE hostGroupId = #{hostGroupId}
AND metricName = #{metricName}
AND hostName = #{hostName}
AND fieldName = #{fieldName}
Expand All @@ -72,7 +72,7 @@
AVG(fieldValue) AS avgValue,
DATETIME_CONVERT(timestampInEpoch, '1:MILLISECONDS:EPOCH', '1:MILLISECONDS:EPOCH', '#{timePrecision.timeSize}:${timePrecision.timeUnit}') AS avgTime
FROM systemMetricLong
WHERE applicationName = #{hostGroupId}
WHERE hostGroupId = #{hostGroupId}
AND metricName = #{metricName}
AND hostName = #{hostName}
AND fieldName = #{fieldName}
Expand Down

0 comments on commit 7ba13a9

Please sign in to comment.