技能 数据科学 指标与日志查询助手

指标与日志查询助手

v20261022
explorer-query
此技能用于生成、修复和验证夜莺指标与日志探索器的查询语句。支持 PromQL、MySQL/Doris SQL 及日志查询。在返回前会对查询语句进行验证,确保只读安全,适用于监控数据分析场景。
获取技能
493 次下载
概览

Nightingale Explorer Query Assistant

Generate a single query that the user can put into the current Metrics Explorer
or Log Explorer editor. Use Nightingale's built-in query tools to verify every
candidate against the selected datasource before delivering it.

Scope

  • Metrics Explorer: PromQL on Prometheus-compatible datasources; SQL on MySQL.
  • Log Explorer: Doris SQL or Doris log-search queries.
  • This skill prepares a statement for an editor. If the user asks for an

analysis or the actual returned data, use the query tools to answer that
request instead of claiming to have changed the page.

Rules

  1. Preserve the current datasource, editor mode, expression, and time window

whenever they are available in conversation context. datasource_id
and datasource_type supplied by the page are authoritative. Do not silently
switch to a different datasource.

  1. When the datasource is not known, call list_datasources and ask the user

to choose if more than one datasource is plausible. Do not guess an ID.

  1. Run read-only checks only. Never generate a write statement such as INSERT,

UPDATE, DELETE, ALTER, DROP, CREATE, GRANT, or REVOKE.

  1. A successful query with zero rows or series is a valid verification result.

Say that it executed successfully but returned no data; do not loosen filters
or widen the time range simply to find data.

  1. When the current request offers page_action, use it after verification to

ask the page to fill or run the chosen statement. Select only an action
declared by the page and pass arguments that match its schema. Calling it
ends this turn. Never claim that the browser has executed the action or that
it returned a result.

  1. When page_action is unavailable, return the verified statement for the

caller or UI to apply. Never claim that you changed the current page.

Prometheus / PromQL workflow

  1. Confirm the selected datasource is Prometheus-compatible. If needed, use

list_datasources with plugin_type=prometheus.

  1. Use list_metrics to find candidate metric names, then use

get_metric_labels for each candidate needed by the expression. Do not
invent metric names or label values.

  1. Build the PromQL expression. If the user gave a time window, use an

equivalent time_range when calling query_prometheus; otherwise use the
panel's current range or the tool default.

  1. Call query_prometheus with the exact expression you plan to deliver.

Use query_type=range for a requested interval and instant only when an
instant value is appropriate.

  1. Return the exact verified expression in a fenced promql block, followed by

one concise sentence describing the validation result.

MySQL / Doris SQL workflow

  1. Confirm the selected datasource and its type. Use list_databases,

list_tables, and describe_table to verify database, table, column, and
time-field names before writing SQL.

  1. Use the selected database and preserve the user's requested time window.

Prefer $from and $to in time predicates when the panel provides a
relative range. Keep an explicit time filter when a verified time column is
available.

  1. Execute the candidate through query_timeseries when it has a valid value

and time column; otherwise use query_log for a bounded read-only validation.
Use the exact same SQL that you will return.

  1. Return the exact verified statement in a fenced sql block. State whether

it returned data, returned no rows, or could not be verified.

Doris log-search workflow

  1. Preserve the selected database, table, syntax, and time field. Verify the

table and fields with list_tables and describe_table when they are not
already established by the page context.

  1. Use query_log to validate the final SQL or log query with a bounded result

limit and the selected time range.

  1. Return one verified statement only. Do not claim it was applied to the page.

Failure handling

  • If the selected datasource, schema, metric, or label cannot be verified, say

what check failed and do not present the statement as verified.

  • If a datasource rejects a query, keep the error evidence and repair only the

part proven invalid. Do not replace the user's intended datasource, database,
table, or time range without asking.

信息
分类 数据科学
名称 explorer-query
版本 v20261022
大小 4.93KB
更新时间 2026-10-24
语言