ml-ai — скилл для Claude Code: что делает и как установить
Настраивает функции машинного обучения и ассистента в Grafana Cloud. Помогает включить прогнозирование метрик, поиск аномалий через DBSCAN и автоанализ инцидентов Sift.
npx skills add grafana/skills --skill ml-ai -a claude-codeЧто делает ml-ai
Скилл добавляет в агент инструкции для работы с ML-модулями Grafana Cloud. Через API настраиваются задания прогнозирования Prophet и детекция выбросов алгоритмом DBSCAN. Это позволяет отслеживать отклонения метрик без ручного подбора статичных порогов. Сюда же входят запуск 8 автоматических проверок первопричин сбоев в Sift и подключение провайдеров через LLM Plugin.
Скилл формирует запросы к grafana-ml-app и grafana-sift-app, а также конфигурирует манифест grafana-llm-app для работы с моделями вроде gpt-4o. Для поиска отклонений среди однотипных сервисов агент рассчитывает показатель ml_outlier_score, а для алертов использует предсказанную верхнюю границу ml_forecast_upper.
Для запуска нужен стек Grafana Cloud уровней Pro или Advanced и токен с правом plugins:write. Динамические алерты не сработают на новых графиках. Моделям Prophet нужно минимум 14 дней непрерывной истории метрики.
Какие задачи решает
- настроить динамический алерт по прогнозу Prophet без статичных порогов
- выявить сервисы с аномальным числом ошибок 5xx с помощью алгоритма DBSCAN
- запустить автоматический разбор инцидента через 8 проверок инструмента Sift
- подключить языковую модель к Grafana Assistant через конфигурацию LLM Plugin
Примеры запросов агенту
- Настрой алерт на CPU через Prophet, если текущее значение превысит прогноз на 10%
- Запусти расследование инцидента в Sift по сервису checkout за последние 30 минут
- Подключи OpenAI в grafana-llm-app для работы ассистента в дашбордах
Как установить ml-ai
1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill ml-ai -a claude-code2Вручную: положить файлы
~/.claude/skills/ml-ai/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/ml-ai/
1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill ml-ai -a codex2Вручную: положить файлы
.agents/skills/ml-ai/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill ml-ai -a cursor2Вручную: положить файлы
.cursor/skills/ml-ai/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install grafana/skills ml-ai2Вручную: положить файлы
.github/skills/ml-ai/SKILL.md1Через Skills CLI (Vercel)
npx skills add grafana/skills --skill ml-ai -a gemini-cli2Командой платформы
gemini skills install https://github.com/grafana/skills --path skills/grafana-cloud/ml-aiВручную: положить файлы
.devin/skills/ml-ai/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add grafana/skills --skill ml-ai -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы о ml-ai
Как установить ml-ai в Claude Code?
Выполните команду npx skills add grafana/skills --skill ml-ai -a claude-code. Агент загрузит инструкции в ~/.claude/skills/ml-ai/SKILL.md.
Что делает скилл ml-ai?
Он даёт агенту готовые сценарии для включения ML-функций в Grafana Cloud. Агент сможет создавать задания прогнозирования Prophet, находить аномалии DBSCAN, запускать проверки Sift и настраивать Grafana Assistant.
Что требуется для работы динамических алертов?
Нужен стек Grafana Cloud Pro или Advanced, токен с правом plugins:write и не менее 14 дней истории для отслеживаемой метрики.
Исходный текст
SKILL.md · Apache-2.0
---
name: ml-ai
license: Apache-2.0
description: Turn on AI + ML features in Grafana Cloud — Grafana Assistant (NL → PromQL/LogQL/TraceQL, dashboard build, incident investigation, MCP integration), Dynamic Alerting (Prophet forecasting + DBSCAN outlier detection), Sift (8-analysis automated root-cause), Knowledge Graph + RCA Workbench, and the LLM Plugin (OpenAI / Anthropic / Azure / Ollama / vLLM / LiteLLM). Use when you want anomaly alerts without static thresholds, natural-language querying, automated incident investigation, dashboards generated from a sentence, or a managed LLM proxy for plugins — even when the user says "alert when something looks weird", "explain this PromQL", "find the root cause", "make this a dashboard", or "wire Claude into Grafana" without naming any of these products.
---
# Grafana Cloud AI & ML
> **Docs**: https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/
ML alerting + automated RCA + LLM-powered Assistant in one Grafana Cloud stack.
## Prerequisites
- Grafana Cloud stack (Pro / Advanced — most features GA, some in preview)
- API token with `plugins:write` for ML / Sift / LLM-plugin endpoints
- For Dynamic Alerting: at least 14 days (ideally 90d) of history for the metric you want to forecast
## Common Workflows
### 1. Forecasting alert with Dynamic Alerting
```bash
# 1. Create forecast job (Prophet — learns daily/weekly seasonality)
curl -X POST https://<stack>.grafana.net/api/plugins/grafana-ml-app/resources/ml/v1/forecast \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"name": "cpu-forecast",
"metric": "avg(rate(node_cpu_seconds_total{mode=\"user\"}[5m]))",
"datasourceId": 1,
"interval": 300,
"trainingWindow": "90d",
"forecastWindow": "7d",
"algorithm": { "name": "prophet", "config": {} }
}'
# 2. Verify job is producing the predicted-value metric (may take a few minutes).
# <datasourceId> must match the datasourceId used above (find it via
# GET /api/datasources), or run the query from Explore instead.
curl -s -H "Authorization: Bearer <token>" \
'https://<stack>.grafana.net/api/datasources/proxy/<datasourceId>/api/v1/query?query=ml_forecast_upper{job="cpu-forecast"}' \
| jq '.data.result | length'
# Expect > 0
# 3. Add an alert that fires when actual exceeds the upper bound
# expr: avg(rate(node_cpu_seconds_total{mode="user"}[5m]))
# > ml_forecast_upper{job="cpu-forecast"} * 1.1
```
### 2. Outlier alert — one service deviates from peers
```bash
# 1. Create outlier job (DBSCAN — groups peers, flags the odd one)
curl -X POST https://<stack>.grafana.net/api/plugins/grafana-ml-app/resources/ml/v1/outlier \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{
"name": "service-error-outliers",
"metric": "sum(rate(http_requests_total{status=~\"5..\"}[5m])) by (service)",
"datasourceId": 1,
"interval": 300,
"algorithm": { "name": "dbscan", "sensitivity": 0.5, "config": { "epsilon": 0.5 } }
}'
# 2. Verify the score metric exists (<datasourceId> must match the
# datasourceId used above, or run the query from Explore instead)
curl -s -H "Authorization: Bearer <token>" \
'https://<stack>.grafana.net/api/datasources/proxy/<datasourceId>/api/v1/query?query=ml_outlier_score{job="service-error-outliers"}' \
| jq '.data.result | length'
# 3. Alert when ml_outlier_score{job="service-error-outliers"} > 0.8 for 5m
```
### 3. Run a Sift investigation
```bash
# 1. Trigger from API (or from Explore / Incident / OnCall)
curl -X POST https://<stack>.grafana.net/api/plugins/grafana-sift-app/resources/sift/v1/investigations \
-H "Authorization: Bearer <token>" -H "Content-Type: application/json" \
-d '{ "name":"checkout-spike","start":"2024-02-01T10:00:00Z","end":"2024-02-01T10:30:00Z",
"filters":{"service":"checkout","namespace":"production"} }'
# 2. The response includes an investigation ID — open it in the UI:
# https://<stack>.grafana.net/a/grafana-sift-app/investigations/<id>
# 3. Verify analyses ran — each of the 8 checks shows ✔ or ✖ with linked evidence.
```
See [`references/sift.md`](references/sift.md) for the full 8-analysis table.
### 4. Wire up the LLM Plugin
```yaml
# 1. Provision (provisioning/plugins/llm.yaml — see references/llm-and-graph.md)
apiVersion: 1
apps:
- type: grafana-llm-app
jsonData: { openAIUrl: https://api.openai.com, openAIModel: gpt-4o }
secureJsonData: { openAIKey: sk-... }
```
```bash
# 2. Restart Grafana, then verify the health endpoint reports the configured provider
curl -s -H "Authorization: Bearer <token>" \
https://<stack>.grafana.net/api/plugins/grafana-llm-app/health | jq
# Expect: {"status":"ok", ...}
# 3. Verify in a panel — open any panel, click the Assistant icon, ask "what does this query do?"
```
See [`references/llm-and-graph.md`](references/llm-and-graph.md) for Assistant capabilities, Knowledge Graph search syntax, and Adaptive Metrics recommendations.
## Resources
- [Machine Learning docs](https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/)
- [Sift](https://grafana.com/docs/grafana-cloud/alerting-and-irm/machine-learning/sift/)
- [Grafana Assistant](https://grafana.com/docs/grafana-cloud/visualizations/grafana-assistant/)
- [LLM Plugin](https://grafana.com/grafana/plugins/grafana-llm-app/)
© grafana · Apache-2.0 · grafana/skills