Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sdk/monitor/azure-monitor-query/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
# Release History

## 1.0.0-beta.2 (Unreleased)
## 1.0.0-beta.2 (2021-07-08)

### Dependency Updates
- Upgraded `azure-core` from `1.17.0` to `1.18.0`.
- Upgraded `azure-core-http-netty` from `1.10.0` to `1.10.1`.

## 1.0.0-beta.1 (2021-06-09)
Version 1.0.0-beta.1 is a preview of our efforts in creating a client library for querying Azure Monitor logs and
metrics that is developer-friendly, idiomatic to the Java ecosystem, and as consistent across different languages
and platforms as possible. The principles that guide our efforts can be found in the
[Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java_introduction.html).

## Features Added
### Features Added
- Initial release. Please see the README and wiki for information on using the new library.
2 changes: 1 addition & 1 deletion sdk/monitor/azure-monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ This client library provides access to query metrics and logs collected by Azure
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-monitor-query</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.azure.monitor.query.models.LogsQueryOptions;
import com.azure.monitor.query.models.LogsQueryResult;
import com.azure.monitor.query.models.LogsQueryStatistics;
import com.azure.monitor.query.models.LogsQueryVisualization;
import com.azure.monitor.query.models.LogsTable;
import com.azure.monitor.query.models.LogsTableCell;
import com.azure.monitor.query.models.LogsTableColumn;
Expand Down Expand Up @@ -179,8 +180,11 @@ private Response<LogsBatchQueryResultCollection> convertToLogQueryBatchResult(Re

for (BatchQueryResponse singleQueryResponse : batchResponse.getResponses()) {

BatchQueryResults queryResults = singleQueryResponse.getBody();
LogsQueryResult logsQueryResult = getLogsQueryResult(queryResults.getTables(),
queryResults.getStatistics(), queryResults.getRender(), queryResults.getError());
LogsBatchQueryResult logsBatchQueryResult = new LogsBatchQueryResult(singleQueryResponse.getId(),
singleQueryResponse.getStatus(), getLogsQueryResult(singleQueryResponse.getBody()));
singleQueryResponse.getStatus(), logsQueryResult);
batchResults.add(logsBatchQueryResult);
}
batchResults.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getId())));
Expand Down Expand Up @@ -243,17 +247,19 @@ Mono<Response<LogsQueryResult>> queryLogsWithResponse(LogsQueryOptions options,

private Response<LogsQueryResult> convertToLogQueryResult(Response<QueryResults> response) {
QueryResults queryResults = response.getValue();
LogsQueryResult logsQueryResult = getLogsQueryResult(queryResults);
LogsQueryResult logsQueryResult = getLogsQueryResult(queryResults.getTables(), queryResults.getStatistics(),
queryResults.getRender(), queryResults.getError());
return new SimpleResponse<>(response.getRequest(), response.getStatusCode(),
response.getHeaders(), logsQueryResult);
}

private LogsQueryResult getLogsQueryResult(QueryResults queryResults) {
private LogsQueryResult getLogsQueryResult(List<Table> innerTables, Object innerStats,
Object innerVisualization, ErrorInfo innerError) {
List<LogsTable> tables = null;

if (queryResults.getTables() != null) {
if (innerTables != null) {
tables = new ArrayList<>();
for (Table table : queryResults.getTables()) {
for (Table table : innerTables) {
List<LogsTableCell> tableCells = new ArrayList<>();
List<LogsTableRow> tableRows = new ArrayList<>();
List<LogsTableColumn> tableColumns = new ArrayList<>();
Expand All @@ -275,52 +281,19 @@ private LogsQueryResult getLogsQueryResult(QueryResults queryResults) {
}
}

LogsQueryStatistics statistics = null;
LogsQueryStatistics queryStatistics = null;

if (queryResults.getStatistics() != null) {
statistics = new LogsQueryStatistics(queryResults.getStatistics());
if (innerStats != null) {
queryStatistics = new LogsQueryStatistics(innerStats);
}

LogsQueryResult logsQueryResult = new LogsQueryResult(tables, statistics,
mapLogsQueryError(queryResults.getError()));
return logsQueryResult;
}

private LogsQueryResult getLogsQueryResult(BatchQueryResults queryResults) {
List<LogsTable> tables = null;

if (queryResults.getTables() != null) {
tables = new ArrayList<>();
for (Table table : queryResults.getTables()) {
List<LogsTableCell> tableCells = new ArrayList<>();
List<LogsTableRow> tableRows = new ArrayList<>();
List<LogsTableColumn> tableColumns = new ArrayList<>();
LogsTable logsTable = new LogsTable(tableCells, tableRows, tableColumns);
tables.add(logsTable);
List<List<Object>> rows = table.getRows();

for (int i = 0; i < rows.size(); i++) {
List<Object> row = rows.get(i);
LogsTableRow tableRow = new LogsTableRow(i, new ArrayList<>());
tableRows.add(tableRow);
for (int j = 0; j < row.size(); j++) {
LogsTableCell cell = new LogsTableCell(table.getColumns().get(j).getName(),
table.getColumns().get(j).getType(), j, i, row.get(j));
tableCells.add(cell);
tableRow.getTableRow().add(cell);
}
}
}
}

LogsQueryStatistics statistics = null;

if (queryResults.getStatistics() != null) {
statistics = new LogsQueryStatistics(queryResults.getStatistics());
LogsQueryVisualization queryVisualization = null;
if (innerVisualization != null) {
queryVisualization = new LogsQueryVisualization(innerVisualization);
}

LogsQueryResult logsQueryResult = new LogsQueryResult(tables, statistics,
mapLogsQueryError(queryResults.getError()));
LogsQueryResult logsQueryResult = new LogsQueryResult(tables, queryStatistics, queryVisualization,
mapLogsQueryError(innerError));
return logsQueryResult;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@ public final class LogsQueryResult {
private final List<LogsTable> logsTables;
private final LogsQueryStatistics statistics;
private final LogsQueryError error;
private final LogsQueryVisualization visualization;

/**
* Creates an instance {@link LogsQueryResult} with a list of {@link LogsTable}.
* @param logsTables The list of {@link LogsTable} returned as query result.
* @param statistics The query execution statistics.
* @param error The error details if there was an error executing the query.
* @param visualization The visualization information for the logs query.
*/
public LogsQueryResult(List<LogsTable> logsTables, LogsQueryStatistics statistics, LogsQueryError error) {
public LogsQueryResult(List<LogsTable> logsTables, LogsQueryStatistics statistics,
LogsQueryVisualization visualization, LogsQueryError error) {
this.logsTables = logsTables;
this.statistics = statistics;
this.error = error;
this.visualization = visualization;
}

/**
Expand All @@ -51,4 +55,12 @@ public LogsQueryStatistics getStatistics() {
public LogsQueryError getError() {
return error;
}

/**
* Returns the visualization information for the logs query.
* @return the visualization information for the logs query.
*/
public LogsQueryVisualization getVisualization() {
return visualization;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.query.models;

/**
* The visualization information related to query execution.
*/
public class LogsQueryVisualization {
private final Object rawVisualization;

/**
* Creates an instance with the visualization information related to query execution.
* @param rawVisualization the visualization information related to query execution.
*/
public LogsQueryVisualization(Object rawVisualization) {
this.rawVisualization = rawVisualization;
}

/**
* Returns the raw statistics information related to query execution as JSON object.
* @return the raw statistics information related to query execution as JSON object.
*/
public Object getRawVisualization() {
return rawVisualization;
}
}