code: def generate_aggregate_cloudwatch_metric_filters(config):
      """Return the CloudWatch Metric Filters information for aggregate metrics
  
      Args:
          config (dict): The loaded config from the 'conf/' directory
      """
      functions = {
          cluster: [
              func.replace("_config", "")
              for func in CLUSTERED_FUNCTIONS
              if cluster_config["{}_config".format(func)].get(
                  "enable_custom_metrics"
              )
          ]
          for cluster, cluster_config in config["clusters"].items()
      }
  
      functions["global"] = {
          func.replace("_config", "")
          for func, func_config in config["lambda"].items()
          if func_config.get("enable_custom_metrics")
      }
  
      if not any(funcs for funcs in list(functions.values())):
          return  # Nothing to add if no funcs have metrics enabled
  
      result = infinitedict()
  
      current_metrics = metrics.MetricLogger.get_available_metrics()
  
      for cluster, functions in functions.items():
          is_global = cluster == "global"
  
          for function in functions:
              # This function may not actually support any custom metrics
              if function not in current_metrics:
                  continue
  
              metric_prefix = metrics.FUNC_PREFIXES.get(function)
              if not metric_prefix:
                  continue
  
              log_group_name = (
                  "${{module.{}_{}_lambda.log_group_name}}".format(
                      function, cluster
                  )
                  if not is_global
                  else "${{module.{}_lambda.log_group_name}}".format(
                      function
                  )
              )
  
              cluster = cluster.upper()
              if not is_global:
                  cluster = "{}_AGGREGATE".format(cluster)
  
              # Add filters for the cluster and aggregate
              for metric, filter_settings in current_metrics[
                  function
              ].items():
                  module_name = "metric_filters_{}_{}_{}".format(
                      metric_prefix, metric, cluster
                  )
                  result["module"][module_name] = {
                      "source": "./modules/tf_metric_filters",
                      "log_group_name": log_group_name,
                      "metric_name": "{}-{}".format(
                          metric_prefix, metric
                      ),
                      "metric_pattern": filter_settings[0],
                      "metric_value": filter_settings[1],
                  }
  
      return result
  
file_path: streamalert/streamalert_cli/terraform/metrics.py
imports: from streamalert.shared import metrics
  from streamalert.shared import CLUSTERED_FUNCTIONS
  from streamalert.shared.logger import get_logger
  from streamalert_cli.terraform.common import infinitedict, monitoring_topic_arn
label_desc: Use image node_id 1 for calling a global function with example usage: generate_aggregate_cloudwatch_metric_filters(config) and returns: result