Skip to content

Commit

Permalink
[MetricsAdvisor][Sample] fix sample runtime errors
Browse files Browse the repository at this point in the history
- detectionConfig

  RestError: Invalid parameter. suppress number should be less than or equal to 14.

- `?.` not supported in NodeJS v12

Fixes Azure#16234
Fixes Azure#16105
  • Loading branch information
jeremymeng committed Jul 6, 2021
1 parent 10af7c9 commit 81c587d
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function createDetectionConfig(
sensitivity: 50,
anomalyDetectorDirection: "Both",
suppressCondition: {
minNumber: 50,
minNumber: 5,
minRatio: 50
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async function getMetricSeriesData(client: MetricsAdvisorClient, metricId: strin

for (const series of result) {
console.log(series.definition);
if (series.timestamps?.length)
if (series.timestamps && series.timestamps.length)
for (let i = 0; i < series.timestamps!.length; i++) {
console.log(` ${series.timestamps![i]}`);
console.log(` ${series.values![i]}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function createDetectionConfig(adminClient, metricId) {
sensitivity: 50,
anomalyDetectorDirection: "Both",
suppressCondition: {
minNumber: 50,
minNumber: 5,
minRatio: 50
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function getMetricSeriesData(client, metricId) {

for (const series of result) {
console.log(series.definition);
if (series.timestamps?.length)
if (series.timestamps && series.timestamps.length)
for (let i = 0; i < series.timestamps.length; i++) {
console.log(` ${series.timestamps[i]}`);
console.log(` ${series.values[i]}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function createDetectionConfig(
sensitivity: 50,
anomalyDetectorDirection: "Both",
suppressCondition: {
minNumber: 50,
minNumber: 5,
minRatio: 50
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function getMetricSeriesData(client: MetricsAdvisorClient, metricId: strin

for (const series of result) {
console.log(series.definition);
if (series.timestamps?.length)
if (series.timestamps && series.timestamps.length)
for (let i = 0; i < series.timestamps!.length; i++) {
console.log(` ${series.timestamps![i]}`);
console.log(` ${series.values![i]}`);
Expand Down

0 comments on commit 81c587d

Please sign in to comment.