kibana-workflows
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuthor Elastic Workflows
编写Elastic Workflows
Create and iterate on Elastic Workflow YAML definitions. Workflows are declarative automations that run inside Kibana:
they query Elasticsearch, set data, branch, loop, call connectors, create cases, notify external systems, and invoke AI
steps.
<!-- begin-partial: preamble -->创建并迭代Elastic Workflow YAML定义。工作流是运行在Kibana内部的声明式自动化程序:它们可以查询Elasticsearch、设置数据、分支、循环、调用连接器、创建案例、通知外部系统以及调用AI步骤。
<!-- begin-partial: preamble -->Environment Configuration
环境配置
This skill executes Elasticsearch operations through the CLI. Before running any other step, confirm the
CLI is installed and available. If it is not installed, ask the user:
elasticelastic"TheCLI is not available. You must install theelasticCLI before continuing?"elastic
Wait for the user's response. Do not guess credentials, call the HTTP API directly, or attempt other workarounds.
This skill references operations in HTTP-shorthand form (e.g., , , ,
, ). The Operations table at the end of this document
maps each shorthand to the equivalent CLI command — always use the CLI rather than calling the HTTP API
directly.
GET /GET /_cat/indicesGET /{index}/_mappingGET /{index}/_settings/index.modePOST /_queryelasticVerify the connection by calling . If verification fails, point the user to the
CLI configuration instructions.
<!-- end-partial: preamble -->
GET /If the user asks only for a draft or explanation and explicitly forbids live access, skip connection verification and do
not call the CLI or APIs. State that the draft was not validated against a target deployment.
If workflow APIs are unavailable, report the returned status and message. Common causes are an unsupported Kibana
version, insufficient license or feature privileges, or Workflows not being offered on the target project. The
setting controls the Kibana UI; it does not remove the public Workflows APIs.
workflows:ui:enabled该技能通过 CLI执行Elasticsearch操作。在运行任何其他步骤之前,请确认 CLI已安装且可用。如果未安装,请询问用户:
elasticelastic"CLI不可用。您必须先安装elasticCLI才能继续?"elastic
等待用户回复。请勿猜测凭据、直接调用HTTP API或尝试其他变通方法。
该技能以HTTP简写形式引用操作(例如、、、、)。本文档末尾的操作表格将每个简写映射为等效的 CLI命令——请始终使用CLI而非直接调用HTTP API。
GET /GET /_cat/indicesGET /{index}/_mappingGET /{index}/_settings/index.modePOST /_queryelastic通过调用验证连接。如果验证失败,请引导用户查看CLI配置说明。
<!-- end-partial: preamble -->
GET /如果用户仅要求草稿或解释,并明确禁止实时访问,请跳过连接验证,不要调用CLI或API。说明该草稿未针对目标部署进行验证。
如果工作流API不可用,请返回状态和消息。常见原因包括Kibana版本不支持、许可证或功能权限不足,或目标项目未提供Workflows功能。设置控制Kibana UI,但不会移除公开的Workflows API。
workflows:ui:enabledPick the authoring path
选择编写路径
Default to the Discovery-tools path below — the tools are registered by default on Kibana
9.5+ and Serverless. Confirm with one probe: returns
; save it to a file and grep for . Two fallbacks, both
loaded only when needed:
platform.workflows.*GET kbn:/api/agent_builder/tools{ "results": [ { "id": ... } ] }"id": "platform.workflows."- No endpoint (404) or no
agent_builderids (e.g. Kibana 9.4) → read references/schema-path.md and hand-author from the raw JSON Schema.platform.workflows.* - An LLM connector is wired into Agent Builder and the user prefers Kibana's own generator → read references/generator-path.md.
State which path you picked and why in one sentence before proceeding. Measured path benchmarks live in
references/path-performance.md.
默认选择下方的Discovery-tools路径——工具默认在Kibana 9.5+和Serverless版本中注册。通过一次探测确认:返回;将其保存到文件并搜索。有两个备用路径,仅在需要时加载:
platform.workflows.*GET kbn:/api/agent_builder/tools{ "results": [ { "id": ... } ] }"id": "platform.workflows."- 无端点(404)或无
agent_builder标识(例如Kibana 9.4)→ 阅读references/schema-path.md并根据原始JSON Schema手动编写。platform.workflows.* - Agent Builder中已连接LLM连接器且用户偏好Kibana自带的生成器→ 阅读references/generator-path.md。
在继续之前,用一句话说明你选择的路径及原因。路径性能基准见references/path-performance.md。
Guidelines (all paths)
通用准则(所有路径)
- Treat tests as executions. runs the workflow graph, and
POST kbn:/api/workflows/testruns the selected step. Test only when every executed action is read-only or the user authorized its effects. Otherwise test a copy whose writes, notifications, and external calls are replaced withPOST kbn:/api/workflows/step/test, then restore the real steps and save the workflow disabled.console - Cite endpoints in HTTP shorthand, never raw transport. This skill's body refers to operations like
. The Operations table is the single place where shorthand binds to a concrete CLI command.
POST kbn:/api/workflows/test - Prefer purpose-built actions over generic . For Slack/Jira/PagerDuty/etc., prefer the connector step type (e.g.
http) over a rawslack2.sendMessagecall. Discover the exact action type viahttp(or the strict schema on the fallback path).get_step_definitions - Reference step outputs as , never
steps.<name>.output. Trigger event data issteps.<name>.with.*, nevereventortrigger.event.triggers.event - Don't guess connector ids. Call (Discovery-tools path) or
platform.workflows.get_connectors(Schema path), or ask the user. Placeholders should be obviously fake.GET kbn:/api/workflows/connectors - Handle failure deliberately. Add retry or fallback behavior where the user's requirements call for resilience. Do
not add everywhere: it can hide a failed action and allow the workflow to report false success.
continue: true - Surface gates, don't paper over them. If the API returns , report the required license or privileges; do not silently retry or blame the UI setting.
403 ... not available
- 将测试视为执行。 运行工作流图,
POST kbn:/api/workflows/test运行选定步骤。仅当每个执行的操作为只读或用户已授权其影响时才进行测试。否则测试副本,将其写入、通知和外部调用替换为POST kbn:/api/workflows/step/test,然后恢复真实步骤并保存禁用状态的工作流。console - 以HTTP简写形式引用端点,切勿使用原始传输方式。 本文档中的操作引用如。操作表格是简写与具体CLI命令绑定的唯一位置。
POST kbn:/api/workflows/test - 优先使用专用操作而非通用。 对于Slack/Jira/PagerDuty等,优先使用连接器步骤类型(例如
http)而非原始slack2.sendMessage调用。通过http(或备用路径上的严格Schema)发现确切的操作类型。get_step_definitions - 将步骤输出引用为,切勿使用
steps.<name>.output。 触发事件数据为steps.<name>.with.*,切勿使用event或trigger.event。triggers.event - 不要猜测连接器ID。 调用(Discovery-tools路径)或
platform.workflows.get_connectors(Schema路径),或询问用户。占位符应明显为虚构值。GET kbn:/api/workflows/connectors - 刻意处理失败。 在用户要求具备弹性的地方添加重试或回退行为。不要处处添加:这可能会隐藏失败的操作,导致工作流报告虚假成功。
continue: true - 明确限制条件,不要掩盖。 如果API返回,请报告所需的许可证或权限;不要静默重试或归咎于UI设置。
403 ... not available
Discovery-tools path
Discovery-tools路径
Use when tools are registered on the target Kibana. All calls go through
with . Response shape:
— the payload you want is
. Send the request body from a file and write the response to a file (see Operations),
then jq against that file; do not inline on multi-line JSON.
platform.workflows.*POST kbn:/api/agent_builder/tools/_execute{ "tool_id": "...", "tool_params": { ... } }{ "results": [ { "type": "other", "data": { ... }, "tool_result_id": "..." } ] }.results[0].datapython3 -cKeep context small; minimize round-trips. Do NOT front-load the whole step catalog — pull only the targeted details
you need, keep large tool output in files (not the transcript), and author in as few turns as possible (measured
rationale: references/path-performance.md).
-
Capture the user's intent before writing YAML. Identify, in order, the trigger (/
manual/scheduled), the inputs the workflow will receive at runtime, the data sources it must read, the actions it must take, and the desired output. If a required dependency is unknown (e.g. a Slack connector id), ask the user or use a clearly-marked placeholder.alert -
Look up only what you'll use. For the specific step types this workflow needs:
- with an exact
platform.workflows.get_step_definitions(e.g.stepType,"http","elasticsearch.esql.query"), or with"slack2.sendMessage"to browse. The response includes input params, config params, ansearchwhen you passoutputSummary, and usage examples. PassincludeOutputSummary: trueonly if the compact summary is insufficient.includeFullSchema: true - for the trigger event schema.
platform.workflows.get_trigger_definitions - to resolve real
platform.workflows.get_connectorsvalues for connector actions.connector-id - when you need a working YAML shape for a pattern.
platform.workflows.get_examples
Write each response to a file and jq the field you need — don't let full tool output land in the transcript. -
Draft the whole workflow in one pass. A workflow requires, at least one trigger, and a non-empty
namearray. Use 2-space indentation. Reference outputs assteps. Build the complete YAML in a single edit rather than growing it across many turns.steps.<name>.output.* -
Validate once. Callwith
platform.workflows.validate_workflow. On failure it returns errors + step definitions for referenced step types automatically, so you rarely need a second{ "yaml": "..." }call. Fix all reported issues in a single edit, then re-validate.get_step_definitions -
Test, save, and run. See Test / save / run below. Useto iterate on a single step (with
platform.workflows.workflow_execute_stepfor unsafe steps).confirmation_body
当目标Kibana上已注册工具时使用此路径。所有调用均通过,参数为。响应格式为——所需的负载为。从文件发送请求体并将响应写入文件(见操作),然后用jq处理该文件;不要在多行JSON中内联。
platform.workflows.*POST kbn:/api/agent_builder/tools/_execute{ "tool_id": "...", "tool_params": { ... } }{ "results": [ { "type": "other", "data": { ... }, "tool_result_id": "..." } ] }.results[0].datapython3 -c保持上下文精简;减少往返次数。 不要预先加载整个步骤目录——仅提取所需的目标细节,将大型工具输出保存在文件中(而非转录内容中),并尽可能少地通过多轮交互完成编写(测量依据:references/path-performance.md)。
-
编写YAML前捕捉用户意图。 按顺序确定触发器(/
manual/scheduled)、工作流运行时将接收的输入、必须读取的数据源、必须执行的操作以及期望的输出。如果存在未知的必需依赖项(例如Slack连接器ID),请询问用户或使用标记清晰的占位符。alert -
仅查找将使用的内容。 对于此工作流所需的特定步骤类型:
- 使用精确的(例如
stepType、"http"、"elasticsearch.esql.query")调用"slack2.sendMessage",或使用platform.workflows.get_step_definitions进行浏览。响应包含输入参数、配置参数、传递search时的includeOutputSummary: true以及使用示例。仅当精简摘要不足时才传递outputSummary。includeFullSchema: true - 使用获取触发器事件Schema。
platform.workflows.get_trigger_definitions - 使用解析连接器操作的真实
platform.workflows.get_connectors值。connector-id - 需要模式的可用YAML格式时使用。
platform.workflows.get_examples
将每个响应写入文件并用jq提取所需字段——不要让完整的工具输出出现在转录内容中。 - 使用精确的
-
一次性完成整个工作流的草稿。 工作流需要、至少一个触发器和非空的
name数组。使用2空格缩进。将输出引用为steps。在单次编辑中构建完整的YAML,而非通过多轮交互逐步完善。steps.<name>.output.* -
验证一次。 使用调用
{ "yaml": "..." }。失败时会自动返回错误及引用步骤类型的步骤定义,因此很少需要再次调用platform.workflows.validate_workflow。在单次编辑中修复所有报告的问题,然后重新验证。get_step_definitions
Schema path (last resort)
Schema路径(最后手段)
Only for Kibanas without the tools (see the probe above). Full recipe:
references/schema-path.md.
platform.workflows.*仅适用于没有工具的Kibana(见上方的探测)。完整步骤见references/schema-path.md。
platform.workflows.*Test / save / run
测试/保存/运行
Shared final phase for both paths.
-
Test only an execution-safe draft. Callwith the YAML inline as
POST kbn:/api/workflows/testand the run-timeworkflowYaml. For any workflow that writes / notifies / calls external services, replace those steps withinputsin the tested copy first, then restore them and save the workflow disabled.console -
Poll the execution. The response carries a. Poll
workflowExecutionIduntilGET kbn:/api/workflows/executions/{executionId}is one ofstatus,completed,failed, orcancelled; then fetchtimed_outfor step-by-step output. Only treatGET kbn:/api/workflows/executions/{executionId}/logsas success.status: completed -
Save.with
POST kbn:/api/workflows/workflow. Save side-effecting workflows with{ yaml, id? }until the user has authorized a real run. Subsequent edits useenabled: falseand may updatePUT kbn:/api/workflows/workflow/{id},yaml,enabled,name, ortags(partial updates supported).description -
Run only when authorized. Enable the workflow, then callwith the same
POST kbn:/api/workflows/workflow/{id}/runshape used at test time. Inspect via the execution + logs endpoints.inputs
两个路径共享的最终阶段。
-
仅测试执行安全的草稿。 使用内联的YAML作为和运行时
workflowYaml调用inputs。对于任何涉及写入/通知/调用外部服务的工作流,请先在测试副本中将这些步骤替换为POST kbn:/api/workflows/test,然后恢复这些步骤并保存禁用状态的工作流。console -
轮询执行状态。 响应包含。轮询
workflowExecutionId直到GET kbn:/api/workflows/executions/{executionId}为status、completed、failed或cancelled之一;然后获取timed_out以查看分步输出。仅将GET kbn:/api/workflows/executions/{executionId}/logs视为成功。status: completed -
保存。 使用调用
{ yaml, id? }。保存有副作用的工作流时设置POST kbn:/api/workflows/workflow,直到用户授权真实运行。后续编辑使用enabled: false,可更新PUT kbn:/api/workflows/workflow/{id}、yaml、enabled、name或tags(支持部分更新)。description -
仅在授权后运行。 启用工作流,然后使用测试时相同的格式调用
inputs。通过执行和日志端点查看状态。POST kbn:/api/workflows/workflow/{id}/run
Workflow YAML Quick Reference
Workflow YAML快速参考
yaml
version: "1"
name: Manual Hello Workflow
description: Logs a hello message from a manual workflow
enabled: true
tags: ["demo", "workflow"]
triggers:
- type: manual
inputs:
properties:
name:
type: string
description: Name to greet
default: "world"
steps:
- name: log_hello
type: console
with:
message: "Hello {{ inputs.name }}"An ordinary action step can use fields like these when its strict schema allows them:
yaml
- name: unique_step_name
type: step_type
with:
param: value
connector-id: connector-id-for-connector-actions # connector actions only
if: "steps.previous.output.ok: true"
timeout: "30s"
on-failure:
retry:
max-attempts: 3
delay: "5s"
fallback:
- name: handle_error
type: console
with:
message: "Step failed"Use when rendering text. Use when an entire value must retain its native type, for example
.
{{ ... }}${{ ... }}documents: "${{ steps.search.output.hits.hits }}"Common step types include:
| Step type | Use for |
|---|---|
| Debug logging during tests |
| Query Elasticsearch with Query DSL |
| Query Elasticsearch with ES|QL |
| Bulk indexing |
| Call a Kibana API |
| Set values under |
| Branch on a KQL-style condition |
| Loop over a collection |
| Pause execution |
| Generic HTTP requests |
| Run another saved workflow |
This is not an exhaustive compatibility list. On the Discovery-tools path,
answers "does step X exist and what does it take". On the schema path, is
the source of truth, and lists configured connector instances.
platform.workflows.get_step_definitionsGET kbn:/api/workflows/schema?loose=falseGET kbn:/api/workflows/connectorsdata.setyaml
version: "1"
name: Manual Hello Workflow
description: Logs a hello message from a manual workflow
enabled: true
tags: ["demo", "workflow"]
triggers:
- type: manual
inputs:
properties:
name:
type: string
description: Name to greet
default: "world"
steps:
- name: log_hello
type: console
with:
message: "Hello {{ inputs.name }}"当严格Schema允许时,普通操作步骤可使用以下字段:
yaml
- name: unique_step_name
type: step_type
with:
param: value
connector-id: connector-id-for-connector-actions # connector actions only
if: "steps.previous.output.ok: true"
timeout: "30s"
on-failure:
retry:
max-attempts: 3
delay: "5s"
fallback:
- name: handle_error
type: console
with:
message: "Step failed"渲染文本时使用。当整个值必须保留其原生类型时使用,例如。
{{ ... }}${{ ... }}documents: "${{ steps.search.output.hits.hits }}"常见步骤类型包括:
| 步骤类型 | 用途 |
|---|---|
| 测试期间的调试日志 |
| 使用Query DSL查询Elasticsearch |
| 使用ES|QL查询Elasticsearch |
| 批量索引 |
| 调用Kibana API |
| 在 |
| 根据KQL风格的条件分支 |
| 遍历集合 |
| 暂停执行 |
| 通用HTTP请求 |
| 运行另一个已保存的工作流 |
这并非详尽的兼容性列表。在Discovery-tools路径中,可回答"步骤X是否存在以及需要哪些参数"。在Schema路径中,是权威来源,列出已配置的连接器实例。
platform.workflows.get_step_definitionsGET kbn:/api/workflows/schema?loose=falseGET kbn:/api/workflows/connectorsdata.setExamples
示例
Manual hello (smallest possible draft): "Make a workflow that logs hello." → manual trigger + one step
that prints . Test with . See
Demo Test Loop.
consoleHello {{ inputs.name | default: "world" }}POST kbn:/api/workflows/testScheduled health check: "Every 5 minutes, ping and log the response." →
trigger () + step + . Look up the exact shape with . Add
bounded retry if requested.
https://api.example.com/healthscheduledevery: 5mhttpconsolewithget_step_definitions("http")Alert-triggered case + Slack notify: "When a Security alert fires, create a case and post to #soc-incidents." →
trigger + over + connector actions. Use and
(current fixtures use and ), then
for the real s. See Workflow Patterns.
alertforeachevent.alertsget_step_definitions("cases.createCase")get_step_definitions(search: "slack")cases.createCaseslack2.sendMessageget_connectorsconnector-idFor unfamiliar shapes on the schema path, read Workflow Patterns and
Generation Tips before drafting.
手动问候(最小草稿): "创建一个记录问候语的工作流。" → 手动触发器 + 一个打印的步骤。使用测试。见演示测试循环。
Hello {{ inputs.name | default: "world" }}consolePOST kbn:/api/workflows/test定时健康检查: "每5分钟ping 并记录响应。" → 触发器() + 步骤 + 。使用查找确切的格式。如果有要求,添加有限次数的重试。
https://api.example.com/healthscheduledevery: 5mhttpconsoleget_step_definitions("http")with警报触发的案例+Slack通知: "当安全警报触发时,创建案例并发布到#soc-incidents频道。" → 触发器 + 遍历的 + 连接器操作。使用和(当前示例使用和),然后使用获取真实的。见工作流模式。
alertevent.alertsforeachget_step_definitions("cases.createCase")get_step_definitions(search: "slack")cases.createCaseslack2.sendMessageget_connectorsconnector-id在Schema路径中遇到不熟悉的格式时,请先阅读工作流模式和生成技巧再起草。
Operations
操作
The HTTP-shorthand references in the body above bind to the CLI commands below. Multi-line YAML and JSON
payloads are easier to pass via than as inline flags.
elastic--input-file <path>Workflows API (both paths).
| HTTP API (shorthand) | |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Agent Builder tools (Discovery-tools path).
Every tool below is invoked through the same execute endpoint. Pass a JSON file with
.
--input-file{ "tool_id": "...", "tool_params": { ... } }| HTTP API (shorthand) | |
|---|---|
| |
| |
Workflow-relevant s:
tool_id | Purpose |
|---|---|
| Validate a YAML string; failure response includes step definitions for referenced step types. |
| Execute one step against the real environment (with user confirmation for unsafe steps). |
| Look up step type params, outputs, examples. |
| Look up a trigger's full event schema. |
| List connector instances configured on the target. |
| Search the bundled example library for working YAML patterns. |
Notes.
For , the input file is JSON of the form (or
in place of ). For , use — is optional. For
, include only the fields to update from , , , , and
. Deletion is soft by default. Use only when permanent deletion and immediate ID reuse are
intended. The Kibana API version is ; the CLI sets it automatically.
post-workflows-test{ "workflowYaml": "...", "inputs": {} }workflowIdworkflowYamlpost-workflows-workflow{ "yaml": "...", "id": "..." }idput-workflows-workflow-idnameenabledtagsyamldescriptionforce=true2023-10-31When invoking read-only commands from a shell that leaves stdin open (some terminals and agent runtimes do this),
append to avoid an crash — e.g.
.
get-</dev/nullEAGAIN: resource temporarily unavailableelastic stack kb workflows get-workflows-executions-executionid --execution-id "{id}" </dev/null本文档中引用的HTTP简写形式对应下方的 CLI命令。多行YAML和JSON负载通过传递比内联标志更简便。
elastic--input-file <path>Workflows API(所有路径)。
| HTTP API(简写) | |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
Agent Builder工具(Discovery-tools路径)。
下方所有工具均通过同一个执行端点调用。通过传递包含的JSON文件。
--input-file{ "tool_id": "...", "tool_params": { ... } }| HTTP API(简写) | |
|---|---|
| |
| |
与工作流相关的:
tool_id | 用途 |
|---|---|
| 验证YAML字符串;失败响应包含引用步骤类型的步骤定义。 |
| 在真实环境中执行单个步骤(不安全步骤需用户确认)。 |
| 查找步骤类型的参数、输出和示例。 |
| 查找触发器的完整事件Schema。 |
| 列出目标上已配置的连接器实例。 |
| 在捆绑的示例库中搜索可用的YAML模式。 |
注意事项。
对于,输入文件为JSON格式,例如(或用替代)。对于,使用——为可选。对于,仅包含要更新的字段:、、、和。默认情况下为软删除。仅当需要永久删除并立即重用ID时才使用。Kibana API版本为;CLI会自动设置该版本。
post-workflows-test{ "workflowYaml": "...", "inputs": {} }workflowIdworkflowYamlpost-workflows-workflow{ "yaml": "...", "id": "..." }idput-workflows-workflow-idnameenabledtagsyamldescriptionforce=true2023-10-31当从保持stdin打开的shell调用只读命令时(某些终端和代理运行时会这样做),请追加以避免崩溃——例如。
get-</dev/nullEAGAIN: resource temporarily unavailableelastic stack kb workflows get-workflows-executions-executionid --execution-id "{id}" </dev/null