您可能想要创建计数器类型而不是分布。
Your filter is correct if the list shown in the log viewer matches the criteria by which logs will be counted. The step that you're missing is that you should use items
as labels such that items
values (e.g. cookies
, chips
etc.) become your label values. Additionally, the values become open-ended and, if you subsequently add candies
, these will be automatically included.
See:
https://cloud.google.com/logging/docs/logs-based-metrics/counter-metrics https://cloud.google.com/logging/docs/logs-based-metrics/labels
NB Your regular expression (\d+)
matches +
(one or more) \d
(digits).
您可以考虑的另一种方法是检测您的应用程序以直接发出这些指标|测量值。OpenCensus 是一种通用解决方案,可与 Stackdriver 配合使用。很简单(支持多种语言)来扩充您的代码,例如计算筹码、cookie 等的出现次数。
https://cloud.google.com/monitoring/custom-metrics/open-census
如果您能够编辑应用程序代码,这可能是您问题的更“纯粹”的解决方案。它还允许比日志到指标更多的灵活性。
与日志一样,OpenCensus 在支持 Stackdriver 之外的监控解决方案方面也为您提供了灵活性。与日志不同,[OpenCensus] 指标表示结构丰富的数据,而不是必须解析才能变得有用的文本。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句