====== Logs and Metrics ====== Often logs and metrics appear to be interchangeable with one another. This page covers differences between them, and when to use them, ===== Logs vs. Metrics ===== * Logs have precise timestamps. To compare the order of events, you need to look at logs. Metrics are usually aggregated locally at seconds or minute granularity, making it challenging to establish an order. Traces are even more precise. * Metrics have natural key-value dimensions. A metric can be aggregated by key, while logs have only the values. Compare ''logger.info("Foo {} happened to user {}.)'' to ''counter("event", "type", "foo", "user", user).record()''. The metric call has named parameters, while the logging call are positional, at lease at the callsite. * Additionally, Metrics usually can only have a limited dimensionality and cardinality. There cannot be too many values, and usually, only a handful of keys per dimension.