Metric Filter depends on REST API Log Group

I need to create a metric filter for API Gateway Log Group which is created by serverless restApi true option. I don’t know how to set DependOn option with API Gateway Log group and set a custom log group name. I tried to make the metric filter depending on ApiGatewayRestApi but I get the specified log group does not exist error. I think that at the time the metric filter is created, the log group still does not exist. I should make the metric filter depend on API Gateway Log group but I don’t know its Logical ID.

This is my metric filter:

  ApiMetricFilter:
    DependsOn: ApiGatewayRestApi
    Type: "AWS::Logs::MetricFilter"
    Properties: 
      LogGroupName: 
        Fn::Join:
          - ""
          - - "API-Gateway-Execution-Logs_"
            - Ref: "ApiGatewayRestApi"
            - "/"
            - ${self:custom.stage}
      FilterPattern: '{ ($.status = "5**") && ($.status != "503") }'
      MetricTransformations: 
      - 
        MetricName: 5XX-${self:custom.cloudwatchAlarmName}-${self:custom.stage}
        MetricNamespace: LogMetrics
        MetricValue: 1

I have found the answer in the CloudFormation console. In the Events tab, there is a list of resources including with my metric filter creation attempt and I can see the Logical ID of REST API log group is “ApiLogGroup”.

I have changed my metric filter as follows and it worked:

Resources:
  ApiMetricFilter:
    Type: "AWS::Logs::MetricFilter"
    Properties: 
      LogGroupName: !Ref APILogGroup
      FilterPattern: '{ ($.status = "5**") && ($.status != "503") }'
      MetricTransformations: 
      - 
        MetricName: 5XX-${self:custom.cloudwatchAlarmName}-${self:custom.stage}
        MetricNamespace: LogMetrics
        MetricValue: 1

Another nice thing I have noticed is if one of the properties using !Ref Logical ID notation there is no need to use DependOn option. The resource is created depending on the reference.
This nice feature is explained in CloudFormation documentation