title: Sending data to CloudWatch using the AWS-SDK
body: <p>I want to write data to CloudWatch using the AWS-SDK (or whatever may work).</p>
  
  <p>I see this:</p>
  
  <p><kbd>
  <a href="https://i.stack.imgur.com/iReg5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iReg5.png" alt="enter image description here"></a>
  </kbd></p>
  
  <p>The only method that looks remotely like publishing data to CloudWatch is the <code>putMetricData</code> method..but it's hard to find an example of using this.</p>
  
  <p>Does anyone know how to publish data to CloudWatch?</p>
  
  <p>When I call this:</p>
  
  <pre><code>cw.putMetricData({
    Namespace: 'ec2-memory-usage',
    MetricData: [{
      MetricName:'first',
      Timestamp: new Date()
    }]
  }, (err, result) =&gt; {
    console.log({err, result});
  });
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>{ err:
     { InvalidParameterCombination: At least one of the parameters must be specified.
         at Request.extractError (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/protocol/query.js:50:29)
         at Request.callListeners (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
         at Request.emit (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
         at Request.emit (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/request.js:683:14)
         at Request.transition (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/request.js:22:10)
         at AcceptorStateMachine.runTo (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/state_machine.js:14:12)
         at /Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/state_machine.js:26:10
         at Request.&lt;anonymous&gt; (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/request.js:38:9)
         at Request.&lt;anonymous&gt; (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/request.js:685:12)
         at Request.callListeners (/Users/alex/codes/interos/jenkins-jobs/jobs/check-memory-ec2-instances/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
       message: 'At least one of the parameters must be specified.',
       code: 'InvalidParameterCombination',
       time: 2019-07-08T19:41:41.191Z,
       requestId: '688a4ff3-a1b8-11e9-967e-431915ff0070',
       statusCode: 400,
       retryable: false,
       retryDelay: 7.89360948163893 },
    result: null }
  </code></pre>