code: private static void dumpHadoopCounters(PigStats pigStats) {
      try {
        if (props.getBoolean(PIG_DUMP_HADOOP_COUNTER_PROPERTY, false)) {
          if (pigStats != null) {
            JobGraph jGraph = pigStats.getJobGraph();
            Iterator<JobStats> iter = jGraph.iterator();
            while (iter.hasNext()) {
              JobStats jobStats = iter.next();
              System.out.println("\n === Counters for job: "
                  + jobStats.getJobId() + " ===");
              Counters counters = jobStats.getHadoopCounters();
              if (counters != null) {
                for (Counters.Group group : counters) {
                  System.out.println(" Counter Group: " + group.getDisplayName()
                      + " (" + group.getName() + ")");
                  System.out.println("  number of counters in this group: "
                      + group.size());
                  for (Counters.Counter counter : group) {
                    System.out.println("  - " + counter.getDisplayName() + ": "
                        + counter.getCounter());
                  }
                }
              } else {
                System.out.println("There are no counters");
              }
            }
          } else {
            System.out.println("pigStats is null, can't dump Hadoop counters");
          }
        }
      } catch (Exception e) {
        System.out.println("Unexpected error: " + e.getMessage());
        e.printStackTrace(System.out);
      }
    }
docs: Dump Hadoop counters for each of the M/R jobs in the given PigStats.