Skip to content

Commit 63c920f

Browse files
- Fixing issues in the readme where the links to the documentation weren't active. (Azure#15756)
Some tidying of the readme and samples: - Fix all the documentation links to point to docs.microsoft.com, now that it's active. - Fixing the .ts samples so they don't use "advanced" JS features (currently we're targeting node 14 when doing transpilation in devtool).
1 parent cf5466d commit 63c920f

File tree

7 files changed

+41
-25
lines changed

7 files changed

+41
-25
lines changed

sdk/monitor/monitor-query/README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Use the client library for Azure Monitor to:
99

1010
[Source code](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/monitor/monitor-query/) |
1111
[Package (NPM)](https://www.npmjs.com/package/@azure/monitor-query) |
12-
[API reference documentation]<!--(https://docs.microsoft.com/javascript/api/@azure/monitor-query)--> |
12+
[API reference documentation][msdocs_apiref]|
1313
[Product documentation][azure_monitor_product_documentation]
1414
[Samples][samples]
1515

@@ -37,7 +37,7 @@ Instructions:
3737

3838
### Authenticate the client
3939

40-
[LogsQueryClient]<!--[msdocs_logs_client]--> and [MetricsQueryClient]<!--[msdocs_metrics_client]--> authenticate using a [service principal](#authenticating-with-a-service-principal).
40+
[LogsQueryClient][msdocs_logs_client] and [MetricsQueryClient][msdocs_metrics_client] authenticate using a [service principal](#authenticating-with-a-service-principal).
4141

4242
#### Authenticating with a service principal
4343

@@ -64,10 +64,10 @@ More information about `@azure/identity` can be found [here](https://github.com/
6464

6565
## Key concepts
6666

67-
The [`LogsQueryClient`]<!--[msdocs_logs_client]--> allows you to query logs, using the [Kusto query language][kusto_query_language]. This data can be queried in the
67+
The [`LogsQueryClient`][msdocs_logs_client] allows you to query logs, using the [Kusto query language][kusto_query_language]. This data can be queried in the
6868
portal using tables like `AppEvents`, `AppDependencies` and others.
6969

70-
The [`MetricsQueryClient`]<!--[msdocs_metrics_client]--> allows you to query metrics.
70+
The [`MetricsQueryClient`][msdocs_metrics_client] allows you to query metrics.
7171

7272
## Examples
7373

@@ -129,9 +129,9 @@ For more detailed instructions on how to enable logs, you can look at the [@azur
129129

130130
The following samples show you the various ways you can query your Log Analytics workspace:
131131

132-
- [`logsQuery.ts`]<!--[samples_logsquery_ts]--> - Query logs in a Monitor workspace
133-
- [`logsQueryBatchSample.ts`]<!--[samples_logquerybatch_ts]--> - Run multiple queries, simultaneously, with a batch in a Monitor workspace
134-
- [`metricsQuerySample.ts`]<!--[samples_metricsquery_ts]--> - Query metrics in a Monitor workspace
132+
- [`logsQuery.ts`][samples_logsquery_ts] - Query logs in a Monitor workspace
133+
- [`logsQueryBatchSample.ts`][samples_logquerybatch_ts] - Run multiple queries, simultaneously, with a batch in a Monitor workspace
134+
- [`metricsQuerySample.ts`][samples_metricsquery_ts] - Query metrics in a Monitor workspace
135135

136136
More in-depth examples can be found in the [samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/monitor/monitor-query/samples/v1/) folder on GitHub.
137137

@@ -168,7 +168,8 @@ folder for more details.
168168
[kusto_query_language]: https://docs.microsoft.com/azure/data-explorer/kusto/query/
169169
[msdocs_metrics_client]: https://docs.microsoft.com/javascript/api/@azure/monitor-query/metricsqueryclient
170170
[msdocs_logs_client]: https://docs.microsoft.com/javascript/api/@azure/monitor-query/logsqueryclient
171+
[msdocs_apiref]: https://docs.microsoft.com/javascript/api/@azure/monitor-query
171172
[samples]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/monitor/monitor-query/samples
172-
[samples_logsquery_ts]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/monitor/monitor-query/samples/v1/typescript/src/logQuery.ts
173-
[samples_logquerybatch_ts]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/monitor/monitor-query/samples/v1/typescript/src/logQueryBatch.ts
174-
[samples_metricsquery_ts]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/monitor/monitor-query/samples/v1/typescript/src/metricsQuery.ts
173+
[samples_logsquery_ts]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/monitor/monitor-query/samples/v1/typescript/src/logsQuery.ts
174+
[samples_logquerybatch_ts]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/monitor/monitor-query/samples/v1/typescript/src/logsQueryBatch.ts
175+
[samples_metricsquery_ts]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/monitor/monitor-query/samples/v1/typescript/src/metricsQuery.ts

sdk/monitor/monitor-query/samples-dev/logsQuery.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ export async function main() {
4848
return;
4949
}
5050

51+
const executionTime =
52+
result.statistics && result.statistics.query && result.statistics.query.executionTime;
53+
5154
console.log(
52-
`Results for query '${kustoQuery}', execution time: ${result.statistics?.query?.executionTime}`
55+
`Results for query '${kustoQuery}', execution time: ${
56+
executionTime == null ? "unknown" : executionTime
57+
}`
5358
);
5459

5560
for (const table of tablesFromResult) {

sdk/monitor/monitor-query/samples-dev/logsQueryBatch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ export async function main() {
3939
for (const response of result.results) {
4040
console.log(`Results for query with id: ${response.id}`);
4141

42-
if (response?.error) {
43-
console.log(` Query had errors:`, response?.error);
42+
if (response.error) {
43+
console.log(` Query had errors:`, response.error);
4444
} else {
45-
if (response?.tables == null) {
45+
if (response.tables == null) {
4646
console.log(`No results for query`);
4747
} else {
4848
console.log(`Printing results from query '${kqlQuery}' for 1 day.`);
4949

50-
for (const table of response?.tables) {
50+
for (const table of response.tables) {
5151
const columnHeaderString = table.columns
5252
.map((column) => `${column.name}(${column.type}) `)
5353
.join("| ");

sdk/monitor/monitor-query/samples/v1/javascript/logsQuery.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ async function main() {
4848
return;
4949
}
5050

51+
const executionTime =
52+
result.statistics && result.statistics.query && result.statistics.query.executionTime;
53+
5154
console.log(
52-
`Results for query '${kustoQuery}', execution time: ${result.statistics?.query?.executionTime}`
55+
`Results for query '${kustoQuery}', execution time: ${
56+
executionTime == null ? "unknown" : executionTime
57+
}`
5358
);
5459

5560
for (const table of tablesFromResult) {

sdk/monitor/monitor-query/samples/v1/javascript/logsQueryBatch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ async function main() {
3939
for (const response of result.results) {
4040
console.log(`Results for query with id: ${response.id}`);
4141

42-
if (response?.error) {
43-
console.log(` Query had errors:`, response?.error);
42+
if (response.error) {
43+
console.log(` Query had errors:`, response.error);
4444
} else {
45-
if (response?.tables == null) {
45+
if (response.tables == null) {
4646
console.log(`No results for query`);
4747
} else {
4848
console.log(`Printing results from query '${kqlQuery}' for 1 day.`);
4949

50-
for (const table of response?.tables) {
50+
for (const table of response.tables) {
5151
const columnHeaderString = table.columns
5252
.map((column) => `${column.name}(${column.type}) `)
5353
.join("| ");

sdk/monitor/monitor-query/samples/v1/typescript/src/logsQuery.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ export async function main() {
4848
return;
4949
}
5050

51+
const executionTime =
52+
result.statistics && result.statistics.query && result.statistics.query.executionTime;
53+
5154
console.log(
52-
`Results for query '${kustoQuery}', execution time: ${result.statistics?.query?.executionTime}`
55+
`Results for query '${kustoQuery}', execution time: ${
56+
executionTime == null ? "unknown" : executionTime
57+
}`
5358
);
5459

5560
for (const table of tablesFromResult) {

sdk/monitor/monitor-query/samples/v1/typescript/src/logsQueryBatch.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ export async function main() {
3939
for (const response of result.results) {
4040
console.log(`Results for query with id: ${response.id}`);
4141

42-
if (response?.error) {
43-
console.log(` Query had errors:`, response?.error);
42+
if (response.error) {
43+
console.log(` Query had errors:`, response.error);
4444
} else {
45-
if (response?.tables == null) {
45+
if (response.tables == null) {
4646
console.log(`No results for query`);
4747
} else {
4848
console.log(`Printing results from query '${kqlQuery}' for 1 day.`);
4949

50-
for (const table of response?.tables) {
50+
for (const table of response.tables) {
5151
const columnHeaderString = table.columns
5252
.map((column) => `${column.name}(${column.type}) `)
5353
.join("| ");

0 commit comments

Comments
 (0)