openclaw-grafana-lens
Version:
OpenClaw plugin that gives AI agents full Grafana access — 18 composable tools for PromQL/LogQL/TraceQL queries, dashboard creation, alerting, SRE investigation, security monitoring, data collection pipeline management via Grafana Alloy (29 recipes), and
44 lines (43 loc) • 1.79 kB
TypeScript
/**
* Query error guidance — pattern-match PromQL/LogQL errors to structured hints.
*
* Addresses mcp-grafana #430: agents send bad PromQL blind and cannot recover
* from cryptic errors like "parse error: unexpected end of input".
*
* Each guidance rule has a regex pattern and produces a structured hint with
* cause, suggestion, and optional corrected example.
*/
export interface QueryGuidance {
cause: string;
suggestion: string;
example?: string;
}
/**
* Match a PromQL error to structured guidance for agent recovery.
* Returns undefined if no pattern matches.
*/
export declare function getPromQLGuidance(error: string, expr: string): QueryGuidance | undefined;
/**
* Match a LogQL error to structured guidance for agent recovery.
* Returns undefined if no pattern matches.
*/
export declare function getLogQLGuidance(error: string, expr: string): QueryGuidance | undefined;
/**
* Match a TraceQL error to structured guidance for agent recovery.
* Returns undefined if no pattern matches.
*/
export declare function getTraceQLGuidance(error: string, expr: string): QueryGuidance | undefined;
/**
* Parse Prometheus "infos" field into structured warnings.
*
* Prometheus returns an `infos` array on successful queries when there are
* non-fatal issues (e.g., applying rate() to a gauge metric). The tool should
* surface these so the agent can self-correct.
*/
export declare function parsePrometheusWarnings(infos: string[] | undefined): QueryGuidance[] | undefined;
/**
* Generate a hint when a query returns no data (empty result set).
* This is not an error — Prometheus returns success with empty results —
* but the agent may not know why there's no data.
*/
export declare function getEmptyResultHint(expr: string): QueryGuidance;