创建基于日志的度量标准,以跟踪2个日志之间的增量

问题描述 投票:2回答:2

假设我有3个应用程序一起工作,并使用pub-sub为“管理”发送消息。假设在开始时创建了一个“事务ID”,并通过应用程序传递,并写入日志中。

我将有如下日志:

app1 - transactionIdX - started - timestamp01
app1 - transactionIdX - ended - timestamp02
app2 - transactionIdX - started - timestamp03
app1 - transactionIdY - started - timestamp04
app1 - transactionIdY - ended - timestamp05
app2 - transactionIdX - ended - timestamp06
app3 - transactionIdX - started - timestamp07
app2 - transactionIdY - started - timestamp08
app2 - transactionIdY - ended - timestamp09
app3 - transactionIdX - ended - timestamp10
app3 - transactionIdY - started - timestamp11
app3 - transactionIdY - ended - timestamp12

我希望有一个公开此类信息的指标:

  • transactionIdX - 在时间戳10 在app1中 - 需要(timestamp02-timestamp01)秒 在app2中 - 需要(timestamp06-timestamp03)秒 在app3中 - 需要(timestamp10-timestamp07)秒 总计 - 需要(timestamp10-timestamp01)秒
  • transactionIdY - 在时间戳12 在app1中 - 需要(timestamp05-timestamp04)秒 在app2中 - 需要(timestamp09-timestamp08)秒 在app3中 - 需要(timestamp12-timestamp11)秒 总计 - 需要(timestamp12-timestamp04)秒

有没有办法构建提供此类信息的基于日志的指标?

google-cloud-platform metrics stackdriver google-cloud-stackdriver
2个回答
1
投票

目前,仅使用基于日志的指标API无法做到这一点。基于日志的度量标准管道不会在两个日志条目之间维护状态,因此您无法捕获两个值并制定查询以捕获两者之间的差异。

我看到两种可能的解决方法:

  1. 检测您的应用程序以保留有关事务延迟的统计信息,并将其输出到日志中并使用基于日志的度量标准捕获它。
  2. 使用与堆栈驱动程序集成的Cloud Datalab之类的脚本在查询时执行此类计算。

免责声明:我是Google Stackdriver的工程师。


0
投票

使用GCP现在开箱即用的工具,您只能做下一步:

1)在下拉列表中选择所有应用程序:

enter image description here

2)通过transactionIdX过滤日志,这样您就可以看到来自此交易的所有服务的日志:

enter image description here

3)或者您可以使用高级过滤器并创建更复杂的过滤器:

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.