How to use the @google-cloud/monitoring.NotificationChannelServiceClient function in @google-cloud/monitoring

To help you get started, we’ve selected a few @google-cloud/monitoring examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleapis / nodejs-monitoring / samples / alerts.js View on Github external
async function deleteChannels(projectId, filter) {
  // [START monitoring_alert_delete_channel]
  // [START monitoring_alert_list_channels]

  // Imports the Google Cloud client library
  const monitoring = require('@google-cloud/monitoring');

  // Creates a client
  const client = new monitoring.NotificationChannelServiceClient();

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'YOUR_PROJECT_ID';
  // const filter = 'A filter for selecting policies, e.g. description:"cloud"';

  const request = {name: client.projectPath(projectId), filter};
  const channels = await client.listNotificationChannels(request);
  console.log(channels);
  for (const channel of channels[0]) {
    console.log(`Deleting channel ${channel.displayName}`);
    try {
      await client.deleteNotificationChannel({
        name: channel.name,
      });
github googleapis / nodejs-monitoring / samples / alerts.js View on Github external
async function replaceChannels(projectId, alertPolicyId, channelIds) {
  // [START monitoring_alert_replace_channels]
  // [START monitoring_alert_enable_channel]
  // [START monitoring_alert_update_channel]
  // [START monitoring_alert_create_channel]

  // Imports the Google Cloud client library
  const monitoring = require('@google-cloud/monitoring');

  // Creates clients
  const alertClient = new monitoring.AlertPolicyServiceClient();
  const notificationClient = new monitoring.NotificationChannelServiceClient();

  /**
   * TODO(developer): Uncomment the following lines before running the sample.
   */
  // const projectId = 'YOUR_PROJECT_ID';
  // const alertPolicyId = '123456789012314';
  // const channelIds = [
  //   'channel-1',
  //   'channel-2',
  //   'channel-3',
  // ];

  const notificationChannels = channelIds.map(id =>
    notificationClient.notificationChannelPath(projectId, id)
  );

@google-cloud/monitoring

Stackdriver Monitoring API client for Node.js

Apache-2.0
Latest version published 3 days ago

Package Health Score

94 / 100
Full package analysis