Skip to content

Commit

Permalink
fix sample on readme (#18022)
Browse files Browse the repository at this point in the history
  • Loading branch information
KarishmaGhiya authored Oct 5, 2021
1 parent 927f225 commit d38c812
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions sdk/monitor/monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}, granularity: ${metricsResponse.granularity}, time span: ${metricsResponse.timespan}`
);

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

0 comments on commit d38c812

Please sign in to comment.