월요일, 7월 22, 2024
HomeLinuxGrafana JMeter Dashboard

Grafana JMeter Dashboard

Grafana JMeter Dashboard 설정방법에 대한 포스팅입니다.

1.InfluxDB Dababase 생성
grafana-dashboard-jmeter-001

grafana-dashboard-jmeter-002

2.Grafana DataSource 생성
grafana-dashboard-jmeter-002-1

grafana-dashboard-jmeter-002-2

grafana-dashboard-jmeter-002-3

3.Grafana Dashboard생성
grafana-dashboard-jmeter-003

grafana-dashboard-jmeter-004

JsonFile Download

grafana-dashboard-jmeter-005

grafana-dashboard-jmeter-006

grafana-dashboard-jmeter-007

4.JMeter JMX
apache-jmeter-3.3 기준으로 작성되었습니다.
jmeter-jmx-backendlistener

jmeter-jmx-threadGroup

5.JMeter JMX 화일을 이용한 SpringBoot 설정 및 Source

Jar Download
JMeter-InfluxDB-Writer-plugin-1.2.jar
jmeter-plugins-casutg-2.5.jar
jmeter-plugins-cmn-jmeter-0.4.jar
jmeter-plugins-common-io-0.2.jar

위의 jar화일을 maven install:install-file 을 이용하여 install를 먼저 진행후에
pom.xml에 등록하시면 됩니다.

STS Maven Build에서
install:install-file -Dfile=${basedir}/lib/jmeter-plugins-common-io-0.2.jar -DgroupId=jmeter -DartifactId=jmeter-plugins-common-io-0.2 -Dpackaging=jar -Dversion=0.2

와 같이 추가후 실행하시면 됩니다.

Spingboot pom.xml

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>kr.mynotes</groupId>
	<artifactId>jmeter</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>jmeter</name>
	<description>jmeter project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.4.RELEASE</version>
		<relativePath />
	</parent>
	
	<repositories>
	    <repository>
	       <id>my-local-repo</id>
	       <url>file://${basedir}/lib</url>
	    </repository>
	</repositories>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.7</java.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>


		<dependency>
			<groupId>org.apache.jmeter</groupId>
			<artifactId>ApacheJMeter_core</artifactId>
			<version>3.3</version>
			<exclusions>
				<exclusion>
					<groupId>org.codehaus.groovy</groupId>
					<artifactId>groovy-all</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
		<dependency>
			<groupId>org.apache.jmeter</groupId>
			<artifactId>ApacheJMeter_http</artifactId>
			<version>3.3</version>
			<exclusions>
				<exclusion>
					<groupId>org.codehaus.groovy</groupId>
					<artifactId>groovy-all</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
		    <groupId>jmeter</groupId>
		    <artifactId>InfluxDB-Writer-plugin</artifactId>
		    <version>1.2</version>
		</dependency>
		<dependency>
		    <groupId>jmeter</groupId>
		    <artifactId>jmeter-plugins-casutg</artifactId>
		    <version>2.5</version>
		</dependency>
		<dependency>
		    <groupId>jmeter</groupId>
		    <artifactId>jmeter-plugins-cmn-jmeter-0.4</artifactId>
		    <version>0.4</version>
		</dependency>
		<dependency>
		    <groupId>jmeter</groupId>
		    <artifactId>jmeter-plugins-common-io-0.2</artifactId>
		    <version>0.2</version>
		</dependency>

	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>


</project>
@Scheduled(cron = "0 */10 * * * *")
    public void jmeterScheduler() throws IOException {

        logger.info("JMeter Scheduler :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now()) );
        StandardJMeterEngine jmeter = new StandardJMeterEngine();

        JMeterUtils.loadJMeterProperties(jmeterHomePath + "/bin/" + jmeterPropFile);
        JMeterUtils.setJMeterHome(jmeterHomePath);
        JMeterUtils.initLogging();
        JMeterUtils.initLocale();
        
        File path = new File(jmxFilePath);
		try {
			if (!path.exists()) {
				logger.error(jmxFilePath + "PATH NOT FOUND!");
			}
			
			File[] files = path.listFiles();
			for (File file : files) {
				if (file.isDirectory()) {
				} else {
			        // Load existing .jmx Test Plan
					String fileName = file.getName();
			        File jmxFile = new File(jmxFilePath + "/" + fileName);
			        
			        try {
				        HashTree jmeterHashTree = SaveService.loadTree(jmxFile);
				        
				        logger.info("JMeter Scheduler File Name :: " + fileName );
				        
				        // Run JMeter Test
				        jmeter.configure(jmeterHashTree);
				        jmeter.run();
			        } catch (Exception e) {
				        logger.info("================= JMeter Error =================");
			        	logger.error(e.getMessage());
			        }
				}
			}
		} catch (Exception e) {
	        	logger.error(e.getMessage());
        }
        
        logger.info("JMeter Scheduler End :: Execution Time - {}", dateTimeFormatter.format(LocalDateTime.now()) );
    }
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular