If you think it might be engine knock, you can test it by putting in high octane gas. If it goes away, it’s engine knock, and you might need a new EGR valve or a new knock sensor. If it doesn’t go away, it could be a lot of things. I would guess the fuel pump, but that’s kind of a long shot.