private Map<String, Long> getCounterValues(final TezCounters dagCounters,
    final List<String> vertexNames, final Map<String, Progress> vertexProgressMap,
    final Set<String> desiredCounters, final boolean done) {
    // DAG specific counters
    Map<String, Long> updatedCounters = new HashMap<>();
    for (CounterGroup counterGroup : dagCounters) {
      for (TezCounter tezCounter : counterGroup) {
        String counterName = tezCounter.getName();
        for (String desiredCounter : desiredCounters) {
          if (counterName.equals(desiredCounter)) {
            updatedCounters.put(counterName, tezCounter.getValue());
          } else if (isDagLevelCounter(desiredCounter)) {
            // by default, we aggregate counters across the entire DAG. Example: SHUFFLE_BYTES would mean SHUFFLE_BYTES
            // of each vertex aggregated together to create DAG level SHUFFLE_BYTES.
            // Use case: If SHUFFLE_BYTES across the entire DAG is > limit perform action
            String prefixRemovedCounterName = getCounterFromDagCounter(desiredCounter);
            aggregateCountersSum(updatedCounters, vertexNames, prefixRemovedCounterName, desiredCounter, tezCounter);
          } else if (isVertexLevelCounter(desiredCounter)) {
            // if counter name starts with VERTEX_ then we just return max value across all vertex since trigger
            // validation is only interested in violation that are greater than limit (*any* vertex violation).
            // Use case: If SHUFFLE_BYTES for any single vertex is > limit perform action
            String prefixRemovedCounterName = getCounterFromVertexCounter(desiredCounter);
            aggregateCountersMax(updatedCounters, vertexNames, prefixRemovedCounterName, desiredCounter, tezCounter);
          } else if (counterName.startsWith(desiredCounter)) {
            // Counters with vertex name as suffix
            // desiredCounter = INPUT_FILES
            // counters: {INPUT_FILES_Map_1 : 5, INPUT_FILES_Map_4 : 10}
            // outcome: INPUT_FILE : 15
            String prefixRemovedCounterName = desiredCounter;
            aggregateCountersSum(updatedCounters, vertexNames, prefixRemovedCounterName, desiredCounter, tezCounter);
          }
        }
      }
    }

    // Process per vertex counters that are available only via vertex Progress
    String counterName = VertexCounterLimit.VertexCounter.VERTEX_TOTAL_TASKS.name();
    if (desiredCounters.contains(counterName) && vertexProgressMap != null) {
      for (Map.Entry<String, Progress> entry : vertexProgressMap.entrySet()) {
        long currentMax = 0;
        if (updatedCounters.containsKey(counterName)) {
          currentMax = updatedCounters.get(counterName);
        }
        long newMax = Math.max(currentMax, entry.getValue().getTotalTaskCount());
        updatedCounters.put(counterName, newMax);
      }
    }

    counterName = VertexCounterLimit.VertexCounter.DAG_TOTAL_TASKS.name();
    if (desiredCounters.contains(counterName) && vertexProgressMap != null) {
      for (Map.Entry<String, Progress> entry : vertexProgressMap.entrySet()) {
        long currentTotal = 0;
        if (updatedCounters.containsKey(counterName)) {
          currentTotal = updatedCounters.get(counterName);
        }
        long newTotal = currentTotal + entry.getValue().getTotalTaskCount();
        updatedCounters.put(counterName, newTotal);
      }
    }

    // Time based counters. If DAG is done already don't update these counters.
    if (!done) {
      counterName = TimeCounterLimit.TimeCounter.EXECUTION_TIME.name();
      if (desiredCounters.contains(counterName) && executionStartTime > 0) {
        updatedCounters.put(counterName, System.currentTimeMillis() - executionStartTime);
      }
    }

    return updatedCounters;
  }
TezJobMonitor keeps track of a tez job while it's being executed. It will
print status to the console and retrieve final status of the job after
completion.
ql/src/java/org/apache/hadoop/hive/ql/exec/tez/monitoring/TezJobMonitor.java