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
72 lines (71 loc) • 2.64 kB
TypeScript
/**
* Pure utility functions shared between the alloy_pipeline tool and its tests.
*
* Extracted here so tests import the real implementations instead of
* duplicating them (maintenance risk if the tool's version diverges).
*/
import type { PipelineDefinition } from "./types.js";
import type { PipelineRecipe } from "./recipes/types.js";
/**
* Extract Alloy component IDs from raw River config.
* Matches patterns like: `type.subtype "label" {` or `type.subtype.sub2 "label" {`
* Returns component IDs in the format Alloy uses: `type.subtype.label`
*/
export declare function extractComponentIds(config: string): string[];
/**
* Infer signal type from raw Alloy config component types.
* loki/faro → logs, otelcol+traces/tempo → traces, pyroscope → profiles, else metrics.
*/
export declare function inferSignalFromConfig(config: string): PipelineDefinition["signal"];
/** Map signal type to the appropriate query tool name. */
export declare function queryToolForSignal(signal: PipelineDefinition["signal"]): string;
/** Map signal type to the query type key used in response shapes. */
export declare function queryTypeForSignal(signal: PipelineDefinition["signal"]): "metrics" | "logs" | "traces";
/**
* Build a basic suggestedWorkflow for raw-config pipelines based on signal type.
*/
export declare function rawConfigSuggestedWorkflow(pipelineName: string, signal: PipelineDefinition["signal"], sampleQueries?: Record<string, string>): ({
tool: string;
action: string;
example: {
action: string;
name: string;
query?: undefined;
expr?: undefined;
};
} | {
tool: string;
action: string;
example: {
action?: undefined;
name?: undefined;
query?: undefined;
expr?: undefined;
};
} | {
tool: string;
action: string;
example: {
query: string;
action?: undefined;
name?: undefined;
expr?: undefined;
};
} | {
tool: string;
action: string;
example: {
expr: string;
action?: undefined;
name?: undefined;
query?: undefined;
};
})[];
/** Redact sensitive params for storage (does not mutate original). */
export declare function redactSecrets(params: Record<string, unknown>, recipe: Pick<PipelineRecipe, "credentialParams">): Record<string, unknown>;
/**
* Scan raw Alloy config for likely plaintext credentials.
* Returns advisory warnings (not errors) — the config is still written.
* Only flags credentials that are NOT already wrapped in sys.env().
*/
export declare function scanForCredentials(config: string): string[];