The Hebrew prelude for this psalm states that it is one which was written by David while he was in a cave hiding from King Saul who looked to kill him. It is a pretty specific and bleak description of a time in David’s life when he was conflicted by his loyalty to the king and his duty as a servant of the Lord most high. He did not kill Saul, as he could have, because of his respect for the office which he knew God had instituted. But in this Psalm he does cry out to the Lord for deliverance. In vs. 2 we read that he pours out his complaint before the Lord. He makes a supplication to the Lord.
Is it okay to complain to God? Job complains to God and God responds by saying: don’t forget who created you and all the things of this earth. Jonah complains to God about his grace toward the Ninevites and God produces a plant which gives shade to Jonah and then dies leaving him in the scorching sun. The lesson is the same as it was for Job. Don’t forget who created you and all the things that you see around you, including the Ninevites.
David complains to God and asks that God will heed his cry. It is a cry of protection. It is not a complaint of the unfairness of God, which is what Jonah spoke out against, and which is what Job could have been alluding to. It is simply a call for protection against those who were seeking his life. It is a complaint of survival. I guess that does sound a lot like Job and less like Jonah.
The end of this psalm provides us with a type of answer to the complaint when David states: “The righteous will surround me, for you will deal bountifully with me.” It is an affirmation of what God is able to do for us. In the midst of our complaint if we can affirm what God is able to do, then that will put us in a very different place when we face those things which we consider difficulties in our life.