code: def _add_default_metric_alarms_args(alarm_parser, clustered=False):
      """Add the default arguments to the metric alarm parsers"""
  
      # Name for this alarm
      def _alarm_name_validator(val):
          if not 1 <= len(val) <= 255:
              raise alarm_parser.error(
                  "alarm name length must be between 1 and 255"
              )
          return val
  
      alarm_parser.add_argument(
          "alarm_name",
          help="Name for the alarm. Each alarm name must be unique within the AWS account.",
          type=_alarm_name_validator,
      )
  
      # get the available metrics to be used
      available_metrics = metrics.MetricLogger.get_available_metrics()
  
      if clustered:
          available_functions = [
              func
              for func, value in available_metrics.items()
              if func in CLUSTERED_FUNCTIONS and value
          ]
      else:
          available_functions = [
              func for func, value in available_metrics.items() if value
          ]
  
      all_metrics = [
          metric
          for func in available_functions
          for metric in available_metrics[func]
      ]
  
      # add metrics for user to pick from. Will be mapped to 'metric_name' in terraform
      alarm_parser.add_argument(
          "-m",
          "--metric",
          choices=all_metrics,
          dest="metric_name",
          metavar="METRIC_NAME",
          help=(
              "One of the following predefined metrics to assign this alarm to for a "
              "given function: {}"
          ).format(", ".join(sorted(all_metrics))),
          required=True,
      )
  
      # Get the function to apply this alarm to
      alarm_parser.add_argument(
          "-f",
          "--function",
          metavar="FUNCTION",
          choices=available_functions,
          help=(
              "One of the following Lambda functions to which to apply this alarm: {}"
          ).format(", ".join(sorted(available_functions))),
          required=True,
      )
  
      operators = sorted(
          [
              "GreaterThanOrEqualToThreshold",
              "GreaterThanThreshold",
              "LessThanThreshold",
              "LessThanOrEqualToThreshold",
          ]
      )
  
      # get the comparison type for this metric
      alarm_parser.add_argument(
          "-co",
          "--comparison-operator",
          metavar="OPERATOR",
          choices=operators,
          help=(
              "One of the following comparison operator to use for this metric: {}"
          ).format(", ".join(operators)),
          required=True,
      )
  
      # get the evaluation period for this alarm
      def _alarm_eval_periods_validator(val):
          error = "evaluation periods must be an integer greater than 0"
          try:
              period = int(val)
          except ValueError:
              raise alarm_parser.error(error)
  
          if period <= 0:
              raise alarm_parser.error(error)
          return period
  
      alarm_parser.add_argument(
          "-e",
          "--evaluation-periods",
          help=(
              "The number of periods over which data is compared to the specified threshold. "
              "The minimum value for this is 1. See the 'Other Constraints' section below for "
              "more information"
          ),
          required=True,
          type=_alarm_eval_periods_validator,
      )
  
      # get the period for this alarm
      def _alarm_period_validator(val):
          error = "period must be an integer in multiples of 60"
          try:
              period = int(val)
          except ValueError:
              raise alarm_parser.error(error)
  
          if period <= 0 or period % 60 != 0:
              raise alarm_parser.error(error)
  
          return period
  
      alarm_parser.add_argument(
          "-p",
          "--period",
          help=(
              "The period, in seconds, over which the specified statistic is applied. "
              "Valid values are any multiple of 60. See the 'Other Constraints' section below for "
              "more information"
          ),
          required=True,
          type=_alarm_period_validator,
      )
  
      # get the threshold for this alarm
      alarm_parser.add_argument(
          "-t",
          "--threshold",
          help=(
              "The value against which the specified statistic is compared. "
              "This value should be a double/float."
          ),
          required=True,
          type=float,
      )
  
      # all other optional flags
      # get the optional alarm description
      def _alarm_description_validator(val):
          if len(val) > 1024:
              raise alarm_parser.error(
                  "alarm description length must be less than 1024"
              )
          return val
  
      alarm_parser.add_argument(
          "-d",
          "--alarm-description",
          help="A description for the alarm",
          type=_alarm_description_validator,
          default="",
      )
  
      statistics = sorted(
          ["SampleCount", "Average", "Sum", "Minimum", "Maximum"]
      )
  
      alarm_parser.add_argument(
          "-s",
          "--statistic",
          metavar="STATISTIC",
          choices=statistics,
          help=(
              "One of the following statistics to use for the metric associated with the alarm: {}"
          ).format(", ".join(statistics)),
          default="Sum",
      )
  
file_path: streamalert/streamalert_cli/metrics_alarms/handler.py
imports: from streamalert.shared import metrics, CLUSTERED_FUNCTIONS
  from streamalert.shared.logger import get_logger
  from streamalert_cli.utils import add_clusters_arg, CLICommand, set_parser_epilog
label_desc: Use image node_id 1 for calling a global function with example usage: _add_default_metric_alarms_args(alarm_parser, clustered) and returns: val, period, period, val