我有以下业务用例:一个工作流(WorkflowId 列)有多个正在运行的实例(InstanceId 列),每个正在运行的实例都有多个步骤(步骤列),每个步骤都有多个事件(事件列)。我正在使用 Loki (Grafana) 存储以下时间序列:
Created (Date), WorkflowId (uuid), InstanceId (uuid), Step (text), Event (text)
2021-11-04 16:40 fafcad98-f245-4658-ba8b-526c60e3eba6 fe8a9704-eeb7-4b75-b29f-ff638e991964 UploadDocuments DocumentsUploaded
2021-11-04 19:40 fafcad98-f245-4658-ba8b-526c60e3eba6 4fcbfcdb-1c22-4940-886b-c236a624ac2c VerifyDocumentsBackOffice Approve
2021-11-04 23:40 fafcad98-f245-4658-ba8b-526c60e3eba6 a7b245f7-98b1-4166-97e0-f3cba9cba87e Offer OfferRejected
2021-11-05 01:40 fafcad98-f245-4658-ba8b-526c60e3eba6 cb024966-ddab-4031-867f-772e221c0059 Offer OfferRejected
2021-11-05 01:40 fafcad98-f245-4658-ba8b-526c60e3eba6 a56b82fa-3ddb-431e-bd7d-3a5df101f269 VerifyDocumentsBackOffice Rejected
2021-11-04 21:40 fafcad98-f245-4658-ba8b-526c60e3eba6 05b2798d-a6f2-4b82-b34b-ba469637b026 VerifyDocumentsBackOffice Rejected
2021-11-04 19:40 fafcad98-f245-4658-ba8b-526c60e3eba6 fe8a9704-eeb7-4b75-b29f-ff638e991964 VerifyDocumentsBackOffice Rejected
我想计算每个 WorkflowId 的 Step(UploadDocuments) 的平均持续时间,这意味着首先计算每个 InstanceId 的步骤持续时间 (UploadDocuments)
{ First_Occurrence_Of_Step (VerifyDocumentsBackOffice) - First_Occurrence_Of_Step(UploadDocuments) }
然后为每个 WorkflowId 平均此持续时间。
我尝试通过 InstanceId 计算 First_Occurrence_Of_Step(UploadDocuments)
first_over_time({JourneyId="fafcad98-f245-4658-ba8b-526c60e3eba6", Step="UploadDocuments"} | unwrap Created [1d]) by (InstanceId)
但没有结果...
哪个是计算每个 WorkflowId 的 Step(UploadDocuments) 平均值的正确 LogQL 查询?
谢谢,