Skip to content

Commit

Permalink
[pinpoint-apm#10704] Improved the use of inspector data in pinot duri…
Browse files Browse the repository at this point in the history
…ng alarm batch operation.
  • Loading branch information
minwoo-jung committed Mar 4, 2024
1 parent 6be46bc commit be84305
Show file tree
Hide file tree
Showing 55 changed files with 1,813 additions and 123 deletions.
8 changes: 8 additions & 0 deletions batch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-batch-alarmsender</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-metric-commons</artifactId>
</dependency>
<dependency>
<groupId>com.navercorp.pinpoint</groupId>
<artifactId>pinpoint-inspector-commons</artifactId>
</dependency>

<dependency>
<groupId>org.apache.thrift</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,15 @@
import com.navercorp.pinpoint.batch.alarm.collector.AgentEventDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.AgentStatDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.DataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.DataSourceDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.FileDescriptorDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.MapStatisticsCallerDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.ResponseTimeDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.pinot.DataSourceDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.pinot.HeapDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.pinot.JvmCpuDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.pinot.SystemCpuDataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.pinot.FileDescriptorDataCollector;
import com.navercorp.pinpoint.batch.alarm.dao.AlarmDao;
import com.navercorp.pinpoint.batch.common.BatchProperties;
import com.navercorp.pinpoint.common.server.bo.stat.CpuLoadBo;
import com.navercorp.pinpoint.common.server.bo.stat.DataSourceListBo;
import com.navercorp.pinpoint.common.server.bo.stat.FileDescriptorBo;
Expand Down Expand Up @@ -64,38 +69,77 @@ public class DataCollectorFactory {

private final MapStatisticsCallerDao callerDao;

private final AlarmDao alarmDao;

private final int collectorVersion;

public DataCollectorFactory(MapResponseDao mapResponseDao,
AgentStatDao<JvmGcBo> jvmGcDao,
AgentStatDao<CpuLoadBo> cpuLoadDao,
AgentStatDao<DataSourceListBo> dataSourceDao,
AgentStatDao<FileDescriptorBo> fileDescriptorDao,
AgentEventDao agentEventDao,
MapStatisticsCallerDao callerDao) {
MapStatisticsCallerDao callerDao,
AlarmDao alarmDao,
BatchProperties batchProperties) {
this.mapResponseDao = Objects.requireNonNull(mapResponseDao, "mapResponseDao");
this.jvmGcDao = Objects.requireNonNull(jvmGcDao, "jvmGcDao");
this.cpuLoadDao = Objects.requireNonNull(cpuLoadDao, "cpuLoadDao");
this.dataSourceDao = Objects.requireNonNull(dataSourceDao, "dataSourceDao");
this.fileDescriptorDao = Objects.requireNonNull(fileDescriptorDao, "fileDescriptorDao");
this.agentEventDao = Objects.requireNonNull(agentEventDao, "agentEventDao");
this.callerDao = Objects.requireNonNull(callerDao, "callerDao");
this.alarmDao = Objects.requireNonNull(alarmDao, "alarmDao");
this.collectorVersion = batchProperties.getCollectorVersion();
}

public DataCollector createDataCollector(CheckerCategory checker, Application application, Supplier<List<String>> agentIds, long timeSlotEndTime) {
if (collectorVersion == 1) {
return createDataCollectorV1(checker, application, agentIds, timeSlotEndTime);
} else {
return createDataCollectorV2(checker, application, agentIds, timeSlotEndTime);
}

}

private DataCollector createDataCollectorV1(CheckerCategory checker, Application application, Supplier<List<String>> agentIds, long timeSlotEndTime) {
return switch (checker.getDataCollectorCategory()) {
case RESPONSE_TIME ->
new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mapResponseDao, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case AGENT_STAT ->
case AGENT_STAT, HEAP_USAGE_RATE, JVM_CPU_USAGE_RATE, SYSTEM_CPU_USAGE_RATE ->
new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, jvmGcDao, cpuLoadDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case AGENT_EVENT ->
new AgentEventDataCollector(DataCollectorCategory.AGENT_EVENT, agentEventDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case CALLER_STAT ->
new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, callerDao, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case DATA_SOURCE_STAT ->
new DataSourceDataCollector(DataCollectorCategory.DATA_SOURCE_STAT, dataSourceDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
new com.navercorp.pinpoint.batch.alarm.collector.DataSourceDataCollector(DataCollectorCategory.DATA_SOURCE_STAT, dataSourceDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case FILE_DESCRIPTOR ->
new FileDescriptorDataCollector(DataCollectorCategory.FILE_DESCRIPTOR, fileDescriptorDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
new com.navercorp.pinpoint.batch.alarm.collector.FileDescriptorDataCollector(DataCollectorCategory.FILE_DESCRIPTOR, fileDescriptorDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
};
}

private DataCollector createDataCollectorV2(CheckerCategory checker, Application application, Supplier<List<String>> agentIds, long timeSlotEndTime) {
return switch (checker.getDataCollectorCategory()) {
case RESPONSE_TIME ->
new ResponseTimeDataCollector(DataCollectorCategory.RESPONSE_TIME, application, mapResponseDao, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case AGENT_STAT ->
new AgentStatDataCollector(DataCollectorCategory.AGENT_STAT, jvmGcDao, cpuLoadDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case AGENT_EVENT ->
new AgentEventDataCollector(DataCollectorCategory.AGENT_EVENT, agentEventDao, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case CALLER_STAT ->
new MapStatisticsCallerDataCollector(DataCollectorCategory.CALLER_STAT, application, callerDao, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case DATA_SOURCE_STAT ->
new DataSourceDataCollector(DataCollectorCategory.DATA_SOURCE_STAT, alarmDao, application, agentIds.get(), timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case FILE_DESCRIPTOR ->
new FileDescriptorDataCollector(DataCollectorCategory.FILE_DESCRIPTOR, alarmDao, application, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case HEAP_USAGE_RATE ->
new HeapDataCollector(DataCollectorCategory.HEAP_USAGE_RATE, alarmDao, application, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case JVM_CPU_USAGE_RATE ->
new JvmCpuDataCollector(DataCollectorCategory.JVM_CPU_USAGE_RATE, alarmDao, application, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
case SYSTEM_CPU_USAGE_RATE ->
new SystemCpuDataCollector(DataCollectorCategory.SYSTEM_CPU_USAGE_RATE, alarmDao, application, timeSlotEndTime, SLOT_INTERVAL_FIVE_MIN);
};
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package com.navercorp.pinpoint.batch.alarm.checker;

import com.navercorp.pinpoint.batch.alarm.collector.DataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.DataSourceDataCollector;
import com.navercorp.pinpoint.batch.alarm.vo.DataSourceAlarmVO;
import com.navercorp.pinpoint.web.alarm.vo.Rule;
Expand All @@ -33,7 +34,7 @@ public class DataSourceConnectionUsageRateChecker extends DataSourceAlarmListVal
private static final String SMS_MESSAGE_FORMAT = "[PINPOINT Alarm - %s] DataSource %s connection pool usage %s%s (Threshold : %s%s, Raw : %s/%s)";
private static final String EMAIL_MESSAGE_FORMAT = " Value of agent(%s) has %s%s(DataSource %s connection pool usage) during the past 5 mins.(Threshold : %s%s, Raw : %s/%s)";

public DataSourceConnectionUsageRateChecker(DataSourceDataCollector dataSourceDataCollector, Rule rule) {
public DataSourceConnectionUsageRateChecker(DataCollector dataSourceDataCollector, Rule rule) {
super(rule, "%", dataSourceDataCollector);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* * Copyright 2024 NAVER Corp.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/

package com.navercorp.pinpoint.batch.alarm.checker;

import com.navercorp.pinpoint.batch.alarm.collector.DataCollector;
import com.navercorp.pinpoint.batch.alarm.collector.pinot.DataSourceDataCollector;
import com.navercorp.pinpoint.batch.alarm.vo.DataSourceAlarmVO;
import com.navercorp.pinpoint.web.alarm.vo.Rule;

import java.util.List;
import java.util.Map;

/**
* @author minwoo-jung
*/
public class DataSourceConnectionUsageRateCheckerV2 extends DataSourceConnectionUsageRateChecker{
public DataSourceConnectionUsageRateCheckerV2(DataCollector dataSourceDataCollector, Rule rule) {
super(dataSourceDataCollector, rule);
}

@Override
protected Map<String, List<DataSourceAlarmVO>> getAgentValues() {
return ((DataSourceDataCollector)dataCollector).getDataSourceConnectionUsageRate();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
*
* * Copyright 2024 NAVER Corp.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/

package com.navercorp.pinpoint.batch.alarm.checker;

import com.navercorp.pinpoint.batch.alarm.collector.pinot.FileDescriptorDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;

import java.util.Map;

/**
* @author minwoo-jung
*/
public class FileDescriptorCheckerV2 extends LongValueAgentChecker {

public FileDescriptorCheckerV2(FileDescriptorDataCollector dataCollector, Rule rule) {
super(rule, "", dataCollector);
}

@Override
protected Map<String, Long> getAgentValues() {
return ((FileDescriptorDataCollector)dataCollector).getFileDescriptorCount();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2014 NAVER Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.navercorp.pinpoint.batch.alarm.checker;

import com.navercorp.pinpoint.batch.alarm.collector.pinot.HeapDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;

import java.util.Map;

/**
* @author minwoo.jung
* @author Jongjin.Bae
*/
public class HeapUsageRateCheckerV2 extends LongValueAgentChecker {

public HeapUsageRateCheckerV2(HeapDataCollector dataCollector, Rule rule) {
super(rule, "%", dataCollector);
}

@Override
protected Map<String, Long> getAgentValues() {
return ((HeapDataCollector)dataCollector).getAgentHeapUsageRate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
*
* * Copyright 2024 NAVER Corp.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/

package com.navercorp.pinpoint.batch.alarm.checker;

import com.navercorp.pinpoint.batch.alarm.collector.pinot.JvmCpuDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;

import java.util.Map;

/**
* @author minwoo-jung
*/
public class JvmCpuUsageRateCheckerV2 extends LongValueAgentChecker {

public JvmCpuUsageRateCheckerV2(JvmCpuDataCollector dataCollector, Rule rule) {
super(rule, "%", dataCollector);
}

@Override
protected Map<String, Long> getAgentValues() {
return ((JvmCpuDataCollector)dataCollector).getJvmCpuUsageRate();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
*
* * Copyright 2024 NAVER Corp.
* *
* * Licensed under the Apache License, Version 2.0 (the "License");
* * you may not use this file except in compliance with the License.
* * You may obtain a copy of the License at
* *
* * http://www.apache.org/licenses/LICENSE-2.0
* *
* * Unless required by applicable law or agreed to in writing, software
* * distributed under the License is distributed on an "AS IS" BASIS,
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* * See the License for the specific language governing permissions and
* * limitations under the License.
*
*
*/

package com.navercorp.pinpoint.batch.alarm.checker;

import com.navercorp.pinpoint.batch.alarm.collector.pinot.SystemCpuDataCollector;
import com.navercorp.pinpoint.web.alarm.vo.Rule;

import java.util.Map;

/**
* @author minwoo-jung
*/
public class SystemCpuUsageRateCheckerV2 extends LongValueAgentChecker {

public SystemCpuUsageRateCheckerV2(SystemCpuDataCollector dataCollector, Rule rule) {
super(rule, "%", dataCollector);
}

@Override
protected Map<String, Long> getAgentValues() {
return ((SystemCpuDataCollector)dataCollector).getSystemCpuUsageRate();
}
}

0 comments on commit be84305

Please sign in to comment.