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

66 lines (65 loc) 2.34 kB
/** * Alloy HTTP Client * * Communicates with Grafana Alloy's HTTP API for pipeline management: * - Health checks (/-/healthy, /-/ready) * - Config reload (/-/reload) * - Component introspection (/api/v0/component/{id}) * * Follows the same pattern as grafana-client.ts: class with typed methods, * fetch-based HTTP calls, actionable error messages. * * Alloy's HTTP API runs on a configurable port (default: 12345). * Key behaviors: * - /-/healthy returns 500 with unhealthy component names if any are unhealthy * - /-/reload returns 400 with error message if config reload fails * - A failed reload keeps the previous running config (safe by default) */ import type { AlloyClientOptions, AlloyComponentInfo, PipelineHealthResult } from "./types.js"; export declare class AlloyClient { private readonly url; private readonly timeout; constructor(opts: AlloyClientOptions); /** Base URL for display in error messages. */ get baseUrl(): string; /** * Check if Alloy is healthy (all components running). * Returns { ok: true } if healthy, or { ok: false, unhealthyComponents } if not. * Returns { ok: false } with error if Alloy is unreachable. */ healthy(): Promise<{ ok: boolean; unhealthyComponents?: string[]; error?: string; }>; /** * Check if Alloy is ready (initial config load complete). */ ready(): Promise<boolean>; /** * Trigger config reload. Alloy re-reads all .alloy files from its config directory. * * On success: returns { ok: true }. * On failure: returns { ok: false, error } — Alloy keeps previous config running. */ reload(): Promise<{ ok: boolean; error?: string; }>; /** * List all running components. */ listComponents(): Promise<AlloyComponentInfo[]>; /** * Get a specific component's status by ID. * Returns null if the component doesn't exist. */ getComponent(id: string): Promise<AlloyComponentInfo | null>; /** * Check health of specific components by their IDs. * Fetches all components in a single request, then does local lookups. */ checkPipelineHealth(componentIds: string[]): Promise<PipelineHealthResult>; private fetchWithTimeout; private formatError; }