added stats function for ES stats api endpoint