Logging and Observability
Metric Counter
Emit a Count
Scripts can emit small metric lines after work completes. A counter is simple to graph when the metric name and value shape stay fixed.
Program
Play the script to choose the count and see the metric line.
metric_counter_line.sh
#!/usr/bin/env bash
count=
metric="jobs_processed"
line="$metric=$count"
echo "$line"
#!/usr/bin/env bash
count=
metric="jobs_processed"
line="$metric=$count"
echo "$line"
metric
A metric is a named measurement emitted by a script.
counter
A counter records how many things were processed.
fixed name
Keeping the metric name stable lets later tools compare values over time.