Yes, it is godly grief that we find in Psalm 51:1–19. That sadness is focused on God and not only on the person himself. David confesses in Psalm 51:4: Against you, you only, have I sinned.
Only against God? Sin hurts other people too, doesn’t it? Imagine what Bathsheba has been through. She has been abused. She lost her husband and her child! We can really hurt other people and cause harm by our behaviour. Yes, that is true, but the core of sin is rebellion against God.
4 Against you, you only, have I sinned and done what is evil in your sight, so that you may be justified in your words and blameless in your judgment.