我们有很多触发的任务在相同的管道上运行,但参数不同。
我对此的问题 - 是否有可能的方法,如函数或表达式来捕获触发任务的名称,以便我们可以在编写任务启动错误管道的报告和电子邮件时使用这些信息。我什至找不到任何靠近它的东西。
先感谢您。
我将此添加为单独的答案,因为它解决了将执行的触发任务与管道分开记录的特定要求。该解决方案必须是一个单独的进程(或管道),而不是触发管道本身的一部分。
Pipeline Monitoring API没有针对触发任务的任务名称的任何显式日志条目。invoker
是你必须使用的。
但是,SnapLogic 用于填充仪表板的主要 API 更为冗长。以下是响应在 Google Chrome 开发者工具上的样子的屏幕截图。
您可以使用invoker_name
和pipe_invoker
字段来识别触发的任务。
以下是正在使用的 API。
POST https://elastic.snaplogic.com/api/2/ < org snode id >/rest/pm/runtime
身体:
{ "state": "Completed,Stopped,Failed,Queued,Started,Prepared,Stopping,Failing,Suspending,Suspended,Resuming", "offset": 0, "limit": 25, "include_subpipelines": false, "sort": { "create_time": -1 }, "start_ts": null, "end_ts": null, "last_hours": 1 }
您可以有一个管道定期触发此 API,然后解析响应并填充日志表(或创建日志文件)。
This answer addresses the requirement of uniquely identify the invoker task in the invoked pipeline
For triggered tasks, there isn't anything provided out of the box by SnapLogic. Although, in case of ULTRA tasks you can get $['task_name']
from the input to the pipeline.
Out of the box, SnapLogic provides the following headers that can be captured and used in the pipeline being initiated by the triggered task. These are as follows.
None of these contains the task-name.
In your case, as a workaround, to uniquely identify the invoker task in the invoked pipeline you could do one of the following three things.
https://elastic.snaplogic.com/.../task-name
All the three above methods can help you capture the task-name in the invoked pipeline.
In your case, I would suggest you go for a custom header because the parameters you pass in the pipeline could be task-specific and it is redundant to add the task-name again in the URL.
Following is how you can add a custom header in your triggered task.
From SnapLogic Docs -
Custom Headers To pass a custom HTTP header, specify a header and its value through the parameter fields in Pipeline Settings. The request matches any header with Pipeline arguments and passes those to the Task, while the Authorization header is never passed to the Pipeline.
Guidelines
- The header must be capitalized in its entirety. Headers are case-sensitive.
- Hyphens must be changed to underscores.
- The HTTP custom headers override both the Task and Pipeline parameters, but the query string parameter has the highest precedence.
For example, if you want to pass a tenant ID (X-TENANT-ID) in a header, add the parameter X_TENANT_ID and provide a default or leave it blank. When you configure the expression, refer to the Pipeline argument following standard convention: _X_TENANT_ID. In the HTTP request, you add the header X-TENANT-ID: 123abc, which results in the value 123abc being substituted for the Pipeline argument X_TENANT_ID.
Creating a task-name parameter in the pipeline settings
Using the task-name parameter in the pipeline
Calling the triggered task
Note: Hyphens must be changed to underscores.
References: