google-cloud-platform - 创建基于日志的指标来跟踪 2 个日志之间的增量

标签 google-cloud-platform metrics stackdriver google-cloud-stackdriver

假设我有 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 无法完成此操作。基于日志的指标管道不会维护两个日志条目之间的状态,因此您无法捕获两个值并制定查询来捕获两者之间的差异。

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

  1. 检测您的应用以保存有关事务延迟的统计信息,并将其输出到日志中并使用基于日志的指标捕获它。
  2. 使用类似 Cloud Datalab 的脚本在查询时执行此类计算与 Stackdriver 集成。

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

关于google-cloud-platform - 创建基于日志的指标来跟踪 2 个日志之间的增量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55761450/

相关文章:

google-cloud-platform - 如何在 GCP Stackdriver 日志记录 UI 中嵌套 LogEntries?

stackdriver - 谷歌 stackdriver 缓慢

java - RESOURCE_EXHAUSTED 池中没有可用的 session

javascript - 使用来自 Electron 的 gRPC 的实时转录 Google Cloud Speech API

google-cloud-platform - stackdriver 请求包含无效参数

metrics - 两个数据子集的 BLEU 平均得分与总体得分不同

metrics - dstat cpu 输出中的 'hiq' 和 'siq' 字段是什么

go - 当使用go客户端部署GCP云功能时,我收到:“错误400:前提条件检查失败。failedPrecondition”

ruby-on-rails - 如何将文件隐私(公共(public)或私有(private))添加到 rails 中具有事件存储的谷歌云存储文件?

javascript - 谷歌分析 : how to use custom dimension on different website to identify intranet users