Skip to content

Commit ffba1ab

Browse files
Perf tests for Azure Monitor Query (Azure#23280)
* Perf tests for Azure Monitor Query * fix docs * add module to version_client.txt * Update sdk/monitor/azure-monitor-query-perf/pom.xml Co-authored-by: Alan Zimmer <[email protected]> * Update sdk/monitor/azure-monitor-query-perf/pom.xml Co-authored-by: Alan Zimmer <[email protected]> Co-authored-by: Alan Zimmer <[email protected]>
1 parent 566badb commit ffba1ab

File tree

12 files changed

+478
-0
lines changed

12 files changed

+478
-0
lines changed

eng/versioning/version_client.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ com.azure:azure-mixedreality-authentication;1.0.0;1.1.0
103103
com.azure:azure-mixedreality-remoterendering;1.0.0;1.1.0-beta.1
104104
com.azure:azure-monitor-opentelemetry-exporter;1.0.0-beta.4;1.0.0-beta.5
105105
com.azure:azure-monitor-query;1.0.0-beta.2;1.0.0-beta.3
106+
com.azure:azure-monitor-query-perf;1.0.0-beta.1;1.0.0-beta.1
106107
com.azure:azure-quantum-jobs;1.0.0-beta.1;1.0.0-beta.2
107108
com.azure:azure-search-documents;11.4.0;11.5.0-beta.2
108109
com.azure:azure-search-perf;1.0.0-beta.1;1.0.0-beta.1
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0-beta.1 (Unreleased)
4+
5+
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Azure Monitor Query Performance test client library for Java
2+
3+
Represents Performance tests for Azure Monitor Query SDK for Java.
4+
5+
## Getting started
6+
7+
### Prerequisites
8+
9+
- A [Java Development Kit (JDK)][jdk_link], version 8 or later.
10+
- [Azure Subscription][azure_subscription]
11+
12+
#### Setup for test resources
13+
14+
You will need the following environment variables for running the tests to access the live resources:
15+
16+
```
17+
AZURE_TENANT_ID=<Tenant ID of Azure subscription>
18+
AZURE_CLIENT_ID=<Client ID of Azure AAD application>
19+
AZURE_CLIENT_SECRET=<Client secret of Azure AAD application>
20+
AZURE_MONITOR_LOGS_WORKSPACE_ID=<Workspace ID of Log Analytics workspace>
21+
AZURE_MONITOR_METRICS_RESOURCE_ID=<Resource ID of an Azure Resource>
22+
```
23+
24+
## Key concepts
25+
26+
## Examples
27+
#### Executing the performance test
28+
1. Compile the performance project into a standalone jar using the command from the root of the perf project folder
29+
```
30+
mvn clean package -f sdk/monitor/azure-monitor-query-perf/pom.xml
31+
```
32+
33+
2. Execute the corresponding perf test in the project using the command.
34+
```
35+
java -jar <path-to-packaged-jar-with-dependencies-from-step-1> <options-for-the-test>
36+
java -jar sdk/monitor/azure-monitor-query-perf/target/azure-monitor-query-perf-1.0.0-beta.1-jar-with-dependencies.jar logsquery --warmup 1 --iterations 1 --parallel 50 --duration 15 --count 1000
37+
java -jar sdk/monitor/azure-monitor-query-perf/target/azure-monitor-query-perf-1.0.0-beta.1-jar-with-dependencies.jar logsbatchquery --warmup 1 --iterations 1 --parallel 50 --duration 15 --count 1000
38+
java -jar sdk/monitor/azure-monitor-query-perf/target/azure-monitor-query-perf-1.0.0-beta.1-jar-with-dependencies.jar logsqueryasmodel --warmup 1 --iterations 1 --parallel 50 --duration 15 --count 1000
39+
java -jar sdk/monitor/azure-monitor-query-perf/target/azure-monitor-query-perf-1.0.0-beta.1-jar-with-dependencies.jar metricsquery --warmup 1 --iterations 1 --parallel 50 --duration 15 --count 1000
40+
```
41+
42+
#### Common perf test command line options for Azure Monitor Query
43+
- `--duration` - Number of seconds to run the main test for. Default is 10.
44+
- `--iterations` - Number of iterations of main test loop.
45+
- `--parallel` - Number of operations to execute in parallel,
46+
- `--warmup` - Duration of test warmup time in seconds before the test attributes are calculated.
47+
48+
Use [PerfStressOptions](https://github.com/Azure/azure-sdk-for-java/blob/main/common/perf-test-core/src/main/java/com/azure/perf/test/core/PerfStressOptions.java)
49+
for the other command line options that could be used.
50+
51+
## Troubleshooting
52+
53+
## Next steps
54+
55+
## Contributing
56+
57+
For details on contributing to this repository, see the [contributing guide](https://github.com/Azure/azure-sdk-for-java/blob/main/CONTRIBUTING.md).
58+
59+
1. Fork it
60+
1. Create your feature branch (`git checkout -b my-new-feature`)
61+
1. Commit your changes (`git commit -am 'Add some feature'`)
62+
1. Push to the branch (`git push origin my-new-feature`)
63+
1. Create new Pull Request
64+
65+
<!-- LINKS -->
66+
[azure_subscription]: https://azure.microsoft.com/free
67+
[jdk_link]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<parent>
8+
<groupId>com.azure</groupId>
9+
<artifactId>azure-client-sdk-parent</artifactId>
10+
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
11+
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
12+
</parent>
13+
14+
<groupId>com.azure</groupId>
15+
<artifactId>azure-monitor-query-perf</artifactId>
16+
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:azure-monitor-query-perf;current} -->
17+
<packaging>jar</packaging>
18+
19+
<name>Microsoft Azure client library for Logs and Metrics query performance tests</name>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>com.azure</groupId>
24+
<artifactId>perf-test-core</artifactId>
25+
<version>1.0.0-beta.1</version> <!-- {x-version-update;com.azure:perf-test-core;current} -->
26+
</dependency>
27+
<dependency>
28+
<groupId>com.azure</groupId>
29+
<artifactId>azure-monitor-query</artifactId>
30+
<version>1.0.0-beta.3</version> <!-- {x-version-update;com.azure:azure-monitor-query;current} -->
31+
</dependency>
32+
<dependency>
33+
<groupId>com.azure</groupId>
34+
<artifactId>azure-identity</artifactId>
35+
<version>1.3.4</version> <!-- {x-version-update;com.azure:azure-identity;dependency} -->
36+
</dependency>
37+
</dependencies>
38+
39+
<build>
40+
<plugins>
41+
<plugin>
42+
<groupId>org.apache.maven.plugins</groupId>
43+
<artifactId>maven-assembly-plugin</artifactId>
44+
<version>3.2.0</version> <!-- {x-version-update;org.apache.maven.plugins:maven-assembly-plugin;external_dependency} -->
45+
<executions>
46+
<execution>
47+
<phase>package</phase>
48+
<goals>
49+
<goal>single</goal>
50+
</goals>
51+
<configuration>
52+
<archive>
53+
<manifest>
54+
<mainClass>
55+
com.azure.monitor.query.perf.App
56+
</mainClass>
57+
</manifest>
58+
</archive>
59+
<descriptorRefs>
60+
<descriptorRef>jar-with-dependencies</descriptorRef>
61+
</descriptorRefs>
62+
</configuration>
63+
</execution>
64+
</executions>
65+
</plugin>
66+
</plugins>
67+
</build>
68+
</project>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.monitor.query.perf;
5+
6+
import com.azure.perf.test.core.PerfStressProgram;
7+
8+
/**
9+
* Runs Azure Monitor Query performance tests.
10+
* <p>
11+
* Test scenarios:
12+
* <ul>
13+
* <li>Query logs from Azure Monitor Log Analytics workspace</li>
14+
* <li>Query metrics from Azure Monitor for an Azure resource</li>
15+
* </ul>
16+
* To run performance tests from the command line, package the project into an uber jar using {@code mvn clean
17+
* package}. Then run the program using {@code java -jar compiled-jar-with-dependencies-path}
18+
* <p>
19+
* To run performance tests in IntelliJ, set all the required environment variables via {@code Run -&gt; Edit
20+
* Configurations} section. Then run the App's main method.
21+
*/
22+
public class App {
23+
/**
24+
* Main method to invoke performance tests
25+
*
26+
* @param args Arguments to the performance tests.
27+
*/
28+
public static void main(String[] args) {
29+
PerfStressProgram.run(new Class<?>[]{LogsQueryTest.class,
30+
LogsBatchQueryTest.class,
31+
LogsQueryAsModelTest.class,
32+
MetricsQueryTest.class}, args);
33+
}
34+
}
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.monitor.query.perf;
5+
6+
import java.time.OffsetDateTime;
7+
8+
/**
9+
* A custom model to read the logs query result.
10+
*/
11+
public final class CustomModel {
12+
private OffsetDateTime timeGenerated;
13+
private String tenantId;
14+
private String id;
15+
private String source;
16+
private Boolean success;
17+
private Double durationMs;
18+
private Object properties;
19+
private String operationName;
20+
private String operationId;
21+
22+
23+
/**
24+
* Returns the time the log event was generated.
25+
* @return the time the log event was generated.
26+
*/
27+
public OffsetDateTime getTimeGenerated() {
28+
return timeGenerated;
29+
}
30+
31+
/**
32+
* Returns the tenant id of the resource for which this log was recorded.
33+
* @return the tenant id of the resource for which this log was recorded.
34+
*/
35+
public String getTenantId() {
36+
return tenantId;
37+
}
38+
39+
/**
40+
* Returns the unique identifier of this log.
41+
* @return the unique identifier of this log.
42+
*/
43+
public String getId() {
44+
return id;
45+
}
46+
47+
/**
48+
* Returns the source of this log.
49+
* @return the source of this log.
50+
*/
51+
public String getSource() {
52+
return source;
53+
}
54+
55+
/**
56+
* Returns {@code true} if the logged request returned a successful response.
57+
* @return {@code true} if the logged request returned a successful response.
58+
*/
59+
public Boolean getSuccess() {
60+
return success;
61+
}
62+
63+
/**
64+
* Returns the time duration the service took to process the request.
65+
* @return the time duration the service took to process the request.
66+
*/
67+
public Double getDurationMs() {
68+
return durationMs;
69+
}
70+
71+
/**
72+
* Returns additional properties of the request.
73+
* @return additional properties of the request.
74+
*/
75+
public Object getProperties() {
76+
return properties;
77+
}
78+
79+
/**
80+
* Returns the name of the operation.
81+
* @return the name of the operation.
82+
*/
83+
public String getOperationName() {
84+
return operationName;
85+
}
86+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.azure.monitor.query.perf;
2+
3+
import com.azure.core.util.Configuration;
4+
import com.azure.monitor.query.LogsQueryClient;
5+
import com.azure.monitor.query.perf.core.ServiceTest;
6+
import com.azure.perf.test.core.PerfStressOptions;
7+
import reactor.core.publisher.Mono;
8+
9+
import java.util.Arrays;
10+
import java.util.List;
11+
12+
/**
13+
* This class tests the performance of a batch of logs queries using the {@link LogsQueryClient}.
14+
*/
15+
public class LogsBatchQueryTest extends ServiceTest<PerfStressOptions> {
16+
17+
private static final List<String> LOGS_BATCH_QUERIES = Arrays
18+
.asList("AppRequests | take 100", "AzureActivity | take 100", "AppPerformanceCounters | take 100");
19+
private final String workspaceId;
20+
21+
/**
22+
* Creates an instance of logs batch query perf test.
23+
* @param options the configurable options for perf testing this class
24+
*/
25+
public LogsBatchQueryTest(PerfStressOptions options) {
26+
super(options);
27+
workspaceId = Configuration.getGlobalConfiguration().get("AZURE_MONITOR_LOGS_WORKSPACE_ID");
28+
if (workspaceId == null) {
29+
throw new IllegalStateException(String.format(CONFIGURATION_ERROR, "AZURE_MONITOR_LOGS_WORKSPACE_ID"));
30+
}
31+
}
32+
33+
@Override
34+
public void run() {
35+
logsQueryClient.queryLogsBatch(workspaceId, LOGS_BATCH_QUERIES, null);
36+
}
37+
38+
@Override
39+
public Mono<Void> runAsync() {
40+
return logsQueryAsyncClient.queryLogsBatch(workspaceId, LOGS_BATCH_QUERIES, null).then();
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.azure.monitor.query.perf;
2+
3+
import com.azure.core.util.Configuration;
4+
import com.azure.monitor.query.LogsQueryClient;
5+
import com.azure.monitor.query.perf.core.ServiceTest;
6+
import com.azure.perf.test.core.PerfStressOptions;
7+
import reactor.core.publisher.Mono;
8+
9+
/**
10+
* This class tests the performance of a single logs query that maps the response to a custom model type using the
11+
* {@link LogsQueryClient}.
12+
*/
13+
public class LogsQueryAsModelTest extends ServiceTest<PerfStressOptions> {
14+
15+
private static final String LOGS_QUERY = "AppRequests | take 100";
16+
private final String workspaceId;
17+
18+
/**
19+
* Creates an instance of logs query perf test.
20+
* @param options the configurable options for perf testing this class
21+
*/
22+
public LogsQueryAsModelTest(PerfStressOptions options) {
23+
super(options);
24+
workspaceId = Configuration.getGlobalConfiguration().get("AZURE_MONITOR_LOGS_WORKSPACE_ID");
25+
if (workspaceId == null) {
26+
throw new IllegalStateException(String.format(CONFIGURATION_ERROR, "AZURE_MONITOR_LOGS_WORKSPACE_ID"));
27+
}
28+
}
29+
30+
@Override
31+
public void run() {
32+
logsQueryClient.queryLogs(workspaceId, LOGS_QUERY, null).getResultAsObject(CustomModel.class);
33+
}
34+
35+
@Override
36+
public Mono<Void> runAsync() {
37+
return logsQueryAsyncClient.queryLogs(workspaceId, LOGS_QUERY, null)
38+
.map(response -> response.getResultAsObject(CustomModel.class))
39+
.then();
40+
}
41+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.monitor.query.perf;
5+
6+
import com.azure.core.util.Configuration;
7+
import com.azure.monitor.query.LogsQueryClient;
8+
import com.azure.monitor.query.perf.core.ServiceTest;
9+
import com.azure.perf.test.core.PerfStressOptions;
10+
import reactor.core.publisher.Mono;
11+
12+
/**
13+
* This class tests the performance of a single logs query using the {@link LogsQueryClient}.
14+
*/
15+
public class LogsQueryTest extends ServiceTest<PerfStressOptions> {
16+
private static final String LOGS_QUERY = "AppRequests | take 100";
17+
private final String workspaceId;
18+
19+
/**
20+
* Creates an instance of logs query perf test.
21+
* @param options the configurable options for perf testing this class
22+
*/
23+
public LogsQueryTest(PerfStressOptions options) {
24+
super(options);
25+
workspaceId = Configuration.getGlobalConfiguration().get("AZURE_MONITOR_LOGS_WORKSPACE_ID");
26+
if (workspaceId == null) {
27+
throw new IllegalStateException(String.format(CONFIGURATION_ERROR, "AZURE_MONITOR_LOGS_WORKSPACE_ID"));
28+
}
29+
}
30+
31+
@Override
32+
public void run() {
33+
logsQueryClient.queryLogs(workspaceId, LOGS_QUERY, null);
34+
}
35+
36+
@Override
37+
public Mono<Void> runAsync() {
38+
return logsQueryAsyncClient.queryLogs(workspaceId, LOGS_QUERY, null).then();
39+
}
40+
}

0 commit comments

Comments
 (0)