title: Can a CloudWatch Custom Metric be a variable instead of a hard-coded string
body: <p>I have created a AWS custom metric in CloudWatch. I am using NodeJs Lambda function to create a custom metric along with dimensions. I would like to know if we can pass variable value to dimensions instead of string (hardcoded strings). Does dimension values accept anything other then string value?</p>
  <p><strong>This works:</strong></p>
  <pre><code>var params = {
      MetricData: [
        {
          MetricName: 'PAGES_VISITED',
          Dimensions: [
            {
              Name: 'UNIQUE_PAGES',
              Value: '**URLS**'
            },
          ],
          Unit: 'None',
          Value: 1.0
        },
      ],
      Namespace: 'SITE/TRAFFIC'
    }
  </code></pre>
  <p><strong>But I want to pass something like this:</strong></p>
  <pre><code>MetricData: [
      {
        MetricName: 'PAGES_VISITED',
        Dimensions: [
          {
            Name: 'MessageAttributes',
            Value: msgattr
          },
          {
            Name: 'CompanyName',
            Value: process.env.CompanyName
          },
          {
            Name: 'short_description',
            Value: message
          },
        ],
        Unit: 'None',
        Value: 10.0
      },
    ],
  </code></pre>