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
30 lines (29 loc) • 1.15 kB
TypeScript
/**
* Panel query resolution utility.
*
* Extracts the query expression and datasource from an existing dashboard
* panel, so grafana_query / grafana_query_logs can re-run it with different
* time ranges without the agent navigating panel JSON manually.
*/
import { GrafanaClient } from "../grafana-client.js";
export type ResolvedPanelQuery = {
expr: string;
datasourceUid: string;
datasourceType: string;
queryTool: "grafana_query" | "grafana_query_logs" | "grafana_query_traces";
panelTitle: string;
panelType: string;
/** Template variable values replaced with .* for broad matching */
templateVarsReplaced: boolean;
};
export type PanelResolveError = {
error: string;
};
/**
* Resolve a dashboard panel's query expression and datasource.
*
* Fetches the dashboard, finds the panel by ID, extracts `targets[0].expr`,
* resolves the datasource UID (handling template variables), and determines
* which query tool to use based on datasource type.
*/
export declare function resolvePanelQuery(client: GrafanaClient, dashboardUid: string, panelId: number): Promise<ResolvedPanelQuery | PanelResolveError>;