Logs are generated by cloud services and collected in Cloud Logging. A log-based metric is created by defining a filter that selects logs based on criteria like resource type and severity. When logs match the filter, the metric increments or measures data accordingly. This metric can then be used for monitoring or alerting. For example, a filter selecting ERROR logs from GCE instances increments a custom metric each time such a log appears. If the filter is updated to include WARNING logs, those logs also increment the metric. Logs from other resource types do not affect the metric if the filter excludes them. This process helps track important events in logs and respond to them automatically.