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
77 lines (76 loc) • 2.35 kB
TypeScript
/**
* grafana_query tool
*
* Run PromQL instant or range queries against any Prometheus datasource.
* The agent uses this to answer data questions directly without creating
* a dashboard — "what's my cost today?" gets a number, not a URL.
*/
import type { GrafanaClientRegistry } from "../grafana-client-registry.js";
/** Max number of top-level series returned from a range query. */
export declare const MAX_RANGE_SERIES = 50;
/** Max number of top-level results returned from an instant query. */
export declare const MAX_INSTANT_RESULTS = 50;
/**
* Auto-calculate a step interval from a time range.
* Targets ~300 datapoints — enough for trend visibility without response bloat.
* Returns step in seconds as a string (Prometheus-compatible).
*/
export declare function calculateAutoStep(startStr: string, endStr: string): {
stepSeconds: number;
stepDisplay: string;
};
export declare function createQueryToolFactory(registry: GrafanaClientRegistry): (_ctx: unknown) => {
name: string;
label: string;
description: string;
parameters: {
type: "object";
properties: {
datasourceUid: {
type: string;
description: string;
};
expr: {
type: string;
description: string;
};
dashboardUid: {
type: string;
description: string;
};
panelId: {
type: string;
description: string;
};
queryType: {
type: string;
enum: string[];
description: string;
};
time: {
type: string;
description: string;
};
start: {
type: string;
description: string;
};
end: {
type: string;
description: string;
};
step: {
type: string;
description: string;
};
};
required: never[];
};
execute(_toolCallId: string, params: Record<string, unknown>): Promise<{
content: Array<{
type: "text";
text: string;
}>;
details: unknown;
}>;
};