How to use the CloudWatch function from aws-sdk

Find comprehensive JavaScript aws-sdk.CloudWatch code examples handpicked from public code repositorys.

52
53
54
55
56
57
58
59
60
61
var AWS = require('aws-sdk');
// Set the region 
AWS.config.update({region: 'REGION'});

// Create CloudWatch service object
var cw = new AWS.CloudWatch({apiVersion: '2010-08-01'});

cw.describeAlarms({StateValue: 'INSUFFICIENT_DATA'}, function(err, data) {
  if (err) {
    console.log("Error", err);
fork icon181
star icon91
watch icon36

4
5
6
7
8
9
10
11
12
13
    getNumberOfMentionsPast7Days,
};

const { SUCCESS, UNCERTAIN } = require('./../utils');
const AWS = require('aws-sdk');
const cloudwatch = new AWS.CloudWatch();

function logResults(results) {
    const all = results.length;
    if (!all) return;
fork icon85
star icon662
watch icon16

5
6
7
8
9
10
11
12
13
14

this.config = config || {};
AWS.config = this.config;

function setEmitter() {
  self.cloudwatch = new AWS.CloudWatch(self.config);
  emitter.on('flush', function(timestamp, metrics) { self.flush(timestamp, metrics); });
}

// if iamRole is set attempt to fetch credentials from the Metadata Service
fork icon53
star icon80
watch icon5

0
1
2
3
4
5
6
7
8
9
'use strict';

const AWS = require('aws-sdk');
const CodeDeploy = new AWS.CodeDeploy();
const Lambda = new AWS.Lambda();
const CloudWatch = new AWS.CloudWatch();
const CloudFormation = new AWS.CloudFormation();
const DynamoDB = new AWS.DynamoDB();
const S3 = new AWS.S3();
const ConfigService = new AWS.ConfigService();
fork icon3
star icon37
watch icon2

0
1
2
3
4
5
6
7
8
9
var AWS = require('aws-sdk');
var async = require('async');
var helpers = require(__dirname + '/../../../helpers/aws');

module.exports = function(AWSConfig, collection, retries, callback) {
    var cloudwatch = new AWS.CloudWatch(AWSConfig);
   
    async.eachLimit(collection.opensearch.listDomainNames[AWSConfig.region].data, 10, function(domain, cb){        
        collection.cloudwatch.getEsMetricStatistics[AWSConfig.region][domain.DomainName] = {};
        var endTime = new Date();
fork icon593
star icon0
watch icon71

15
16
17
18
19
20
21
22
23
24

// Required libraries
var AWS = require('aws-sdk');
// TODO, set the region automatically
var lambda = new AWS.Lambda();
var cloudwatch = new AWS.CloudWatch({apiVersion: '2010-08-01'});

// Lambda Handler
console.log("Started up, waiting for someone to call the exports.handler...");
exports.handler = function(event, context, callback) {
fork icon10
star icon42
watch icon2

2
3
4
5
6
7
8
9
10
11
var AWS = require('aws-sdk');
var memoize = require('./lib/util/memoizeWithOptions');
var promisifyAll = require('./lib/util/promisifyAll');

function cloudWatch(options) {
  return promisifyAll(new AWS.CloudWatch(options));
}

/**
 * Returns an instance of AWS.CloudWatch which has Promise methods
fork icon10
star icon26
watch icon8

0
1
2
3
4
5
6
7
8
9
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

var AWS = require('aws-sdk');
AWS.config.update({region: process.env.REGION});
var cloudWatch = new AWS.CloudWatch();

/**
 * Records a cloud watch custom metric
 */
fork icon3
star icon13
watch icon4

25
26
27
28
29
30
31
32
33
34
        region: params.region || DEFAULT_REGION
    };

    if (params.proxy) config.httpOptions = { agent: proxy(params.proxy) };

    this._cloudwatch = new AWS.CloudWatch(config);
}

static get name() {
    return DATASOURCE_NAME;
fork icon2
star icon10
watch icon12

62
63
64
65
66
67
68
69
70
71

var autoscaling = new AWS.AutoScaling()
const dynamodb = new AWS.DynamoDB()
var docClient = new AWS.DynamoDB.DocumentClient()
var SSM = new AWS.SSM()
var cloudwatch = new AWS.CloudWatch()
var message = 'ok'
var RequestType = 'events'

if ((Object.keys(event).length === 0) || (event.source === 'aws.events')) {
fork icon0
star icon1
watch icon0

153
154
155
156
157
158
159
160
161
162
	httpOptions: { timeout: 10000 },
};
if (this.region) {
	clientOpt.region = this.region;
}
this.cloudwatch = new AWS.CloudWatch(clientOpt);

if (config.metrics) {
	for (const k in config.metrics) {
		this.addMetric(config.metrics[k]);
fork icon0
star icon0
watch icon0

12
13
14
15
16
17
18
19
20
21
/**
 * @param {Object} config
 */
constructor (config = {}) {
    this._config = config;
    this._cloudwatch = new AWS.CloudWatch(this._config.aws || {});
    this._instanceId = 'Local';
    this._appName = 'unknown';

    // Try to get Instance ID if possible using AWS Meta Service
fork icon0
star icon0
watch icon5