Retrieve custom metrics with collectd (original) (raw)

You can retrieve additional metrics from your applications or services using the CloudWatch agent with the collectd protocol, which is supported only on Linux servers. collectd is a popular open-source solution with plugins that can gather system statistics for a wide variety of applications. By combining the system metrics that the CloudWatch agent can already collect with the additional metrics from collectd, you can better monitor, analyze, and troubleshoot your systems and applications. For more information about collectd, see collectd - The system statistics collection daemon.

You use the collectd software to send the metrics to the CloudWatch agent. For the collectd metrics, the CloudWatch agent acts as the server while the collectd plugin acts as the client.

The collectd software is not installed automatically on every server. On a server running Amazon Linux 2, follow these steps to install collectd

sudo amazon-linux-extras install collectd

For information about installing collectd on other systems, see the Download page for collectd.

To collect these custom metrics, add a "collectd": {} line to themetrics_collected section of the agent configuration file. You can add this line manually. If you use the wizard to create the configuration file, it is done for you. For more information, see Create the CloudWatch agent configuration file.

Optional parameters are also available. If you are using collectd and you do not use/etc/collectd/auth_file as your collectd_auth_file, you must set some of these options.

The following is an example of the collectd section of the agent configuration file.

{
   "metrics":{
      "metrics_collected":{
         "collectd":{
            "name_prefix":"My_collectd_metrics_",
            "metrics_aggregation_interval":120
         }
      }
   }
}

Viewing collectd metrics imported by the CloudWatch agent

After importing collectd metrics into CloudWatch, you can view these metrics as time series graphs, and create alarms that can watch these metrics and notify you if they breach a threshold that you specify. The following procedure shows how to view collectd metrics as a time series graph. For more information about setting alarms, see Using Amazon CloudWatch alarms.

To view collectd metrics in the CloudWatch console
  1. Open the CloudWatch console athttps://console.aws.amazon.com/cloudwatch/.
  2. In the navigation pane, choose Metrics.
  3. Choose the namespace for the metrics collected by the agent. By default, this is CWAgent, but you may have specified a different namespace in the CloudWatch agent configuration file.
  4. Choose a metric dimension (for example, Per-Instance Metrics).
  5. The All metrics tab displays all metrics for that dimension in the namespace. You can do the following:
    1. To graph a metric, select the check box next to the metric. To select all metrics, select the check box in the heading row of the table.
    2. To sort the table, use the column heading.
    3. To filter by resource, choose the resource ID and then choose Add to search.
    4. To filter by metric, choose the metric name and then choose Add to search.
  6. (Optional) To add this graph to a CloudWatch dashboard, choose Actions,Add to dashboard.