def query_metadata_agent_for_monitored_resource(local_resource_id)
      response = query_metadata_agent("monitoredResource/#{local_resource_id}")
      return nil if response.nil?
      begin
        resource = Google::Api::MonitoredResource.decode_json(response.to_json)
      rescue Google::Protobuf::ParseError, ArgumentError => e
        @log.error 'Error parsing monitored resource from Metadata Agent. ' \
                   "response: #{response.inspect}", error: e
        return nil
      end

      # TODO(qingling128): Use Google::Api::MonitoredResource directly after we
      # upgrade gRPC version to include the fix for the protobuf map
      # corruption issue.
      Google::Apis::LoggingV2::MonitoredResource.new(
        type: resource.type,
        labels: resource.labels.to_h
      )
    end
def query_metadata_agent_for_monitored_resource(local_resource_id)
      response = query_metadata_agent("monitoredResource/#{local_resource_id}")
      return nil if response.nil?
      begin
        resource = Google::Api::MonitoredResource.decode_json(response.to_json)
      rescue Google::Protobuf::ParseError, ArgumentError => e
        @log.error 'Error parsing monitored resource from Metadata Agent. ' \
                   "response: #{response.inspect}", error: e
        return nil
      end

      # TODO(qingling128): Use Google::Api::MonitoredResource directly after we
      # upgrade gRPC version to include the fix for the protobuf map
      # corruption issue.
      Google::Apis::LoggingV2::MonitoredResource.new(
        type: resource.type,
        labels: resource.labels.to_h
      )
    end
Call Metadata Agent to get monitored resource information and parse
 response to Google::Api::MonitoredResource.