Viscosity is defined as the ratio of shear stress to the rate of shear strain. Shear stress is that component of stress that acts tangential to a plane through any given point in a body. Shear strain is a measure of the amount by which parallel lines have been sheared past each other by deformation. Thinking of a stack of cards on an inclined plane might clarify your thoughts. Shear stress will be caused by gravity pulling on the cards.
Shear strain is how much they slide past each other.
Things get more complicated because lavas do not always behave as ideal Newtonian fluids. Stress and strain rate by not be related in a linear manner or yield strength might need to be considered. I suggest you see the descriptions in a few volcanology books like in Williams and McBirney and Francis. I did not find any formulas that include lithostatic pressure.