適用於 Node.js 的 Azure 監視器模組Azure Monitor modules for Node.js

雲端應用程式相當複雜,且具有許多移動組件。Cloud applications are complex with many moving parts. 監視會提供資料,以確保應用程式持續運作並以健全的狀態執行。Monitoring provides data to ensure that your application stays up and running in a healthy state. 它也可協助您預防潛在問題,或是針對過去所發生的問題進行疑難排解。It also helps you to stave off potential problems or troubleshoot past ones. 除此之外,您還可以使用監視資料來取得應用程式的深入解析。In addition, you can use monitoring data to gain deep insights about your application. 這些知識可協助您提升應用程式效能或維護性,或是將原本需要手動介入的動作自動化。That knowledge can help you to improve application performance or maintainability, or automate actions that would otherwise require manual intervention.

管理套件Management Package

安裝 npm 模組Install npm module

npm install azure-arm-monitor

範例Example

此程式碼範例會列印與資源群組相關聯的所有警示規則。This code example prints all the alerting rules associated with a resource group.

const msRestAzure = require('ms-rest-azure');
const monitorManagementClient = require('azure-arm-monitor');

const subscriptionId = 'your-subscription-id';
const resourceGroupName = 'your-resource-group-name';

msRestAzure
  .interactiveLogin()
  .then(credentials => {
    const client = new monitorManagementClient(credentials, subscriptionId);
    client.alertRules.listByResourceGroup(resourceGroupName, rules => {
      console.log('List of rules:');
      console.dir(rules, { depth: null, colors: true });
    })
  });

範例Samples

深入探索可在應用程式中使用的 Node.js 程式碼範例Explore more sample Node.js code you can use in your apps.