Skip to content

Commit

Permalink
Apply Monitor Query READMEfile updates (#17933)
Browse files Browse the repository at this point in the history
  • Loading branch information
scottaddie authored Sep 29, 2021
1 parent 576f2b2 commit af719ec
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions sdk/monitor/monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ const logsQueryClient = new LogsQueryClient(new DefaultAzureCredential());

async function run() {
const kustoQuery = "AppEvents | limit 1";
const result = await logsQueryClient.query(azureLogAnalyticsWorkspaceId, kustoQuery, {
duration: Durations.TwentyFourHours
const result = await logsQueryClient.queryWorkspace(azureLogAnalyticsWorkspaceId, kustoQuery, {
duration: Durations.twentyFourHours
});
const tablesFromResult = result.tables;

Expand Down Expand Up @@ -128,14 +128,14 @@ run().catch((err) => console.log("ERROR:", err));

#### Handle logs query response

The `query` function of `LogsQueryClient` returns the `LogsQueryResult`. Here's a hierarchy of the response:
The `queryWorkspace` function of `LogsQueryClient` returns the `LogsQueryResult`. Here's a hierarchy of the response:

```
LogsQueryResult
|---statistics
|---visualization
|---error
|---status ("Partial" | "Success" | "Failed")
|---status ("PartialFailure" | "Success" | "Failure")
|---tables (list of `LogsTable` objects)
|---name
|---rows
Expand Down Expand Up @@ -252,7 +252,7 @@ LogsQueryBatchResult
|---statistics
|---visualization
|---error
|---status ("Partial" | "Success" | "Failed")
|---status ("PartialFailure" | "Success" | "Failure")
|---tables (list of `LogsTable` objects)
|---name
|---rows
Expand Down Expand Up @@ -313,10 +313,10 @@ const queryLogsOptions: LogsQueryOptions = {
serverTimeoutInSeconds: 60
};

const result = await logsQueryClient.query(
const result = await logsQueryClient.queryWorkspace(
azureLogAnalyticsWorkspaceId,
kustoQuery,
{ duration: Durations.TwentyFourHours },
{ duration: Durations.twentyFourHours },
queryLogsOptions
);

Expand All @@ -341,10 +341,10 @@ const queryLogsOptions: LogsQueryOptions = {
};

const kustoQuery = "AppEvents | limit 10";
const result = await logsQueryClient.queryLogs(
const result = await logsQueryClient.queryWorkspace(
azureLogAnalyticsWorkspaceId,
kustoQuery,
{ duration: Durations.TwentyFourHours },
{ duration: Durations.twentyFourHours },
queryLogsOptions
);
```
Expand Down Expand Up @@ -406,12 +406,12 @@ export async function main() {
const secondMetricName = metricNames[1];
if (firstMetricName && secondMetricName) {
console.log(`Picking an example metric to query: ${firstMetricName} and ${secondMetricName}`);
const metricsResponse = await metricsQueryClient.query(
const metricsResponse = await metricsQueryClient.queryResource(
metricsResourceId,
[firstMetricName, secondMetricName],
{
granularity: "PT1M",
timespan: { duration: Durations.FiveMinutes }
timespan: { duration: Durations.fiveMinutes }
}
);

Expand All @@ -434,16 +434,16 @@ main().catch((err) => {
});
```

In the preceding sample, metric results in `metricsResponse` are ordered according to the order in which the user specifies the metric names in the `metricNames` array argument for the `query` function. If the user specifies `[firstMetricName,secondMetricName]`, the result for `firstMetricName` will appear before the result for `secondMetricName` in the `metricResponse`.
In the preceding sample, metric results in `metricsResponse` are ordered according to the order in which the user specifies the metric names in the `metricNames` array argument for the `queryResource` function. If the user specifies `[firstMetricName, secondMetricName]`, the result for `firstMetricName` will appear before the result for `secondMetricName` in the `metricResponse`.

#### Handle metrics query response

The metrics `query` function returns a `QueryMetricsResult` object. The `QueryMetricsResult` object contains properties such as a list of `Metric`-typed objects, `interval`, `namespace`, and `timespan`. The `Metric` objects list can be accessed using the `metrics` property. Each `Metric` object in this list contains a list of `TimeSeriesElement` objects. Each `TimeSeriesElement` contains `data` and `metadataValues` properties. In visual form, the object hierarchy of the response resembles the following structure:
The metrics `queryResource` function returns a `QueryMetricsResult` object. The `QueryMetricsResult` object contains properties such as a list of `Metric`-typed objects, `interval`, `namespace`, and `timespan`. The `Metric` objects list can be accessed using the `metrics` property. Each `Metric` object in this list contains a list of `TimeSeriesElement` objects. Each `TimeSeriesElement` contains `data` and `metadataValues` properties. In visual form, the object hierarchy of the response resembles the following structure:

```
QueryMetricsResult
|---cost
|---timespan (of type `TimeInterval`)
|---timespan (of type `QueryTimeInterval`)
|---granularity
|---namespace
|---resourceRegion
Expand Down Expand Up @@ -485,9 +485,9 @@ export async function main() {

console.log(`Picking an example metric to query: ${firstMetricName}`);

const metricsResponse = await metricsQueryClient.queryMetrics(
const metricsResponse = await metricsQueryClient.queryResource(
metricsResourceId,
{ duration: Durations.FiveMinutes },
{ duration: Durations.fiveMinutes },
{
metricNames: ["MatchedEventCount"],
interval: "PT1M",
Expand Down

0 comments on commit af719ec

Please sign in to comment.