Publishing Custom Metric Data
A number of AWS services publish :cw-ug:`their own metrics <aws-namespaces>` in namespaces beginning with "AWS/" You can also publish custom metric data using your own namespace (as long as it doesn't begin with "AWS/").
Publish Custom Metric Data
To publish your own metric data, call the |cwclient|'s :methodname:`putMetricData` method with a :aws-java-class:`PutMetricDataRequest <services/cloudwatch/model/PutMetricDataRequest>`. The :classname:`PutMetricDataRequest` must include the custom namespace to use for the data, and information about the data point itself in a :aws-java-class:`MetricDatum <services/cloudwatch/model/MetricDatum>` object.
You cannot specify a namespace that begins with "AWS/". Namespaces that begin with "AWS/" are reserved for use by Amazon Web Services products.
.. literalinclude:: example_code/cloudwatch/src/main/java/aws/example/cloudwatch/PutMetricData.java :lines: 16-22 :language: java
.. literalinclude:: example_code/cloudwatch/src/main/java/aws/example/cloudwatch/PutMetricData.java :lines: 41-58 :dedent: 8 :language: java