UNPKG

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

115 lines (114 loc) 3.45 kB
/** * grafana_update_dashboard tool * * Five operations in one tool: * - add_panel: Add a new panel with auto-layout + query validation * - remove_panel: Remove a panel by ID or title * - update_panel: Merge updates into an existing panel + query validation * - update_metadata: Change title, description, tags, time range, refresh * - delete: Permanently remove a dashboard * * Uses the same POST /api/dashboards/db endpoint as create-dashboard, * but preserves dashboard.id and version for update semantics. * * Query validation: When adding or updating panel targets, PromQL expressions * are dry-run against Grafana. The panel is always saved regardless validation * is informational, included as a queryValidation object in the response. */ import { GrafanaClientRegistry } from "../grafana-client-registry.js"; import type { GrafanaClient } from "../grafana-client.js"; type Target = { refId?: string; expr?: string; datasource?: { uid?: string; type?: string; }; }; /** Per-query validation result. */ export type QueryValidationEntry = { refId: string; expr: string; valid: boolean; error?: string; sampleValue?: number; }; /** Aggregate validation result for all targets in a panel. */ export type QueryValidation = { validated: boolean; results: QueryValidationEntry[]; datasourceUid?: string; skippedReason?: string; }; export declare function createUpdateDashboardToolFactory(registry: GrafanaClientRegistry): (_ctx: unknown) => { name: string; label: string; description: string; parameters: { type: "object"; properties: { uid: { type: string; description: string; }; operation: { type: string; enum: string[]; description: string; }; panel: { type: string; description: string; }; panelId: { type: string; description: string; }; panelTitle: { type: string; description: string; }; updates: { type: string; description: string; }; title: { type: string; description: string; }; description: { type: string; description: string; }; tags: { type: string; items: { type: string; }; description: string; }; time: { type: string; description: string; }; refresh: { type: string; description: string; }; }; required: string[]; }; execute(_toolCallId: string, params: Record<string, unknown>): Promise<{ content: Array<{ type: "text"; text: string; }>; details: unknown; }>; }; /** * Dry-run PromQL expressions from panel targets to validate them. * Returns a QueryValidation object never throws. */ export declare function validateTargetQueries(client: GrafanaClient, targets: Target[], datasourceUid: string): Promise<QueryValidation>; export {};