Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply Monitor Query README file updates #17933

Merged
merged 1 commit into from
Sep 29, 2021
Merged
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
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