rpm is all over the place when reving up on 2002 Chevrolet Trailblazer

going down the road the rpm gauge go up and down motor runs rough. if the eninge stays below 2000 rmp works fine, I'm thinking it might be the cam or crank senor. it has 178000. am i in the wright area or may it be something elso.

I would check for a vacuum leak and go from there
i would ck for codes to start with, if no codes seek help as to not waste money