假设我有 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) 秒
有没有办法构建提供此类信息的基于日志的指标?
最佳答案
目前,仅使用基于日志的指标 API 无法完成此操作。基于日志的指标管道不会维护两个日志条目之间的状态,因此您无法捕获两个值并制定查询来捕获两者之间的差异。
我看到两种可能的解决方法:
- 检测您的应用以保存有关事务延迟的统计信息,并将其输出到日志中并使用基于日志的指标捕获它。
- 使用类似 Cloud Datalab 的脚本在查询时执行此类计算与 Stackdriver 集成。
免责声明:我是 Google Stackdriver 的工程师。
关于google-cloud-platform - 创建基于日志的指标来跟踪 2 个日志之间的增量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55761450/