How to Group the Metrics by Label Name

I have pushed the metrics like related to Jenkins builds.I need to show on Grafana total of passed builds and failed builds on Bar chart or Pie chart!