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
99 lines (98 loc) • 2.93 kB
TypeScript
/**
* grafana_annotate tool
*
* Create or query annotations on Grafana dashboards. Annotations mark
* events (deployments, incidents, config changes) that correlate with
* metric changes visible on dashboards.
*/
import { GrafanaClientRegistry } from "../grafana-client-registry.js";
/**
* Resolve a time parameter that may be epoch ms (number) or a Grafana
* relative time string like "now-7d" (string). Returns epoch ms.
*/
export declare function resolveTimeParam(value: unknown): number | undefined;
export type ComparisonHint = {
beforeWindow: {
from: string;
to: string;
};
afterWindow: {
from: string;
to: string;
};
suggestion: string;
};
/**
* Build a comparisonHint for an annotation creation response.
*
* Provides ready-to-use time ranges for before/after comparison with
* `grafana_query`, eliminating manual time math for the agent.
*
* For region annotations (time → timeEnd), the "before" window ends at
* `time` and the "after" window starts at `timeEnd`. For point annotations,
* both windows are symmetric around the annotation time.
*
* The `afterWindow.to` is capped at "now" if the annotation is recent.
*/
export declare function buildComparisonHint(time: number, timeEnd: number | undefined, windowMs?: number): ComparisonHint;
export declare function createAnnotateToolFactory(registry: GrafanaClientRegistry): (_ctx: unknown) => {
name: string;
label: string;
description: string;
parameters: {
type: "object";
properties: {
action: {
type: string;
enum: string[];
description: string;
};
text: {
type: string;
description: string;
};
tags: {
type: string;
items: {
type: string;
};
description: string;
};
dashboardUid: {
type: string;
description: string;
};
panelId: {
type: string;
description: string;
};
time: {
type: string[];
description: string;
};
timeEnd: {
type: string[];
description: string;
};
from: {
type: string[];
description: string;
};
to: {
type: string[];
description: string;
};
limit: {
type: string;
description: string;
};
};
};
execute(_toolCallId: string, params: Record<string, unknown>): Promise<{
content: Array<{
type: "text";
text: string;
}>;
details: unknown;
}>;
};