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

fix sample on readme #18022

Merged
merged 4 commits into from
Oct 5, 2021
Merged
Changes from 2 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
20 changes: 12 additions & 8 deletions sdk/monitor/monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ QueryMetricsResult

```ts
import { DefaultAzureCredential } from "@azure/identity";
import { Durations, Metric, MetricsQueryClient } from "@azure/monitor-query";
import { Durations, Metric, MetricsQueryClient } from "../src/index";
KarishmaGhiya marked this conversation as resolved.
Show resolved Hide resolved
import * as dotenv from "dotenv";
dotenv.config();

Expand All @@ -551,23 +551,27 @@ export async function main() {
const metricsQueryClient = new MetricsQueryClient(tokenCredential);

if (!metricsResourceId) {
throw new Error("METRICS_RESOURCE_ID must be set in the environment for this sample");
throw new Error(
"METRICS_RESOURCE_ID for an Azure Metrics Advisor subscription must be set in the environment for this sample"
);
}

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

const metricsResponse = await metricsQueryClient.queryResource(
metricsResourceId,
{ duration: Durations.fiveMinutes },
["MatchedEventCount"],
{
metricNames: ["MatchedEventCount"],
interval: "PT1M",
aggregations: [AggregationType.Count]
timespan: {
duration: Durations.fiveMinutes
},
granularity: "PT1M",
aggregations: ["Count"]
}
);

console.log(
`Query cost: ${metricsResponse.cost}, interval: ${metricsResponse.interval}, time span: ${metricsResponse.timespan}`
`Query cost: ${metricsResponse.cost}, interval: ${metricsResponse.granularity}, time span: ${metricsResponse.timespan}`
KarishmaGhiya marked this conversation as resolved.
Show resolved Hide resolved
);

const metrics: Metric[] = metricsResponse.metrics;
Expand Down