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
25 lines (24 loc) • 821 B
JavaScript
/**
* Shared utilities for trace connector recipes (span-metrics, service-graph).
*/
/**
* Derive an OTLP metrics ingestion URL from a Prometheus remote_write URL.
* Mimir: /api/prom/push → /api/v1/otlp
* Prometheus: /api/v1/write → /api/v1/otlp
* Fallback: strip path, append /api/v1/otlp
*/
export function deriveOtlpMetricsUrl(remoteWriteUrl) {
try {
const url = new URL(remoteWriteUrl);
url.pathname = url.pathname
.replace(/\/api\/prom\/push$/, "/api/v1/otlp")
.replace(/\/api\/v1\/write$/, "/api/v1/otlp");
if (!url.pathname.includes("/otlp")) {
url.pathname = "/api/v1/otlp";
}
return url.toString().replace(/\/$/, "");
}
catch {
return remoteWriteUrl.replace(/\/api\/prom\/push$/, "/api/v1/otlp");
}
}