[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6BXFKMC53ZH0PY31VNATDR8":3,"skill-same:01M6BXFKMC53ZH0PY31VNATDR8":114},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":51,"linkOnly":52,"markdownContent":53,"markdownBody":54,"frontMatter":55,"refName":61,"commitSha":62,"skillDirectory":63,"forksCount":64,"repositoryHtmlUrl":65,"repositoryHomepageUrl":17,"ownerHtmlUrl":66,"ownerBlogUrl":67,"ownerDescription":68,"updatedAt":69,"install":70,"resources":83},"01M6BXFKMC53ZH0PY31VNATDR8","grafana-generator","Grafana监控栈生成","Reads the entire codebase, detects Java\u002FSpring Boot, Rust\u002FActix+Axum, Python\u002FDjango, or Go\u002FGin, discovers all HTTP endpoints, and generates a working Grafana + Prometheus + node_exporter observability stack with podman-compose. Dashboard includes machine metrics (CPU, memory, disk, I\u002FO, network) and application metrics (request counters, error counters, latency p50\u002Fp70\u002Fp90\u002Fp95\u002Fp99\u002Fp99.9 per endpoint).","读取整个代码库，识别 Java\u002FSpring Boot、Rust\u002FActix+Axum、Python\u002FDjango 或 Go\u002FGin，发现所有 HTTP 端点，并生成一个可用的 Grafana + Prometheus + node_exporter 可观测性技术栈（使用 podman-compose）。仪表盘包括机器指标（CPU、内存、磁盘、I\u002FO、网络）和应用指标（请求计数器、错误计数器、每个端点的延迟 p50\u002Fp70\u002Fp90\u002Fp95\u002Fp99\u002Fp99.9）。","diegopacheco\u002Fai-playground","diegopacheco","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F121278?v=4","01M6BXCP8P7GGSJ8M1W2MFDTGT","Diego Pacheco","01M6BXCPD3WM51H465XW9YM4BV",21,"Unlicense",null,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD3B3T8FK02S5JVCZA1M","运维监控与告警","SCENARIO","使用场景",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQGD4WETX0HM3SM9QKQ15B","SRE 工程师","PROFESSION","适用职业",[31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50],"grafana generator","grafana","prometheus","stack","Bash","disk","endpoint","network","spring boot","java","go","observability","metrics","boot","podman","http","dashboard","rust","memory","python","2026-11-10 10:12:30",false,"---\nname: grafana-generator\ndescription: Reads the entire codebase, detects Java\u002FSpring Boot, Rust\u002FActix+Axum, Python\u002FDjango, or Go\u002FGin, discovers all HTTP endpoints, and generates a working Grafana + Prometheus + node_exporter observability stack with podman-compose. Dashboard includes machine metrics (CPU, memory, disk, I\u002FO, network) and application metrics (request counters, error counters, latency p50\u002Fp70\u002Fp90\u002Fp95\u002Fp99\u002Fp99.9 per endpoint).\nallowed-tools: [Glob, Grep, Read, Bash, Write]\n---\n\n# Grafana Dashboard Generator\n\nYou are a Grafana observability stack generator agent. When invoked, you scan the entire codebase to detect the stack, discover all HTTP endpoints, and generate a complete working Grafana + Prometheus + node_exporter setup with podman-compose. The generated dashboard has machine-level metrics and per-endpoint application metrics.\n\n## Global Context\n- User request: $ARGUMENTS\n- Output locations: `grafana\u002F`, `prometheus\u002F`, `podman-compose.yaml`, `run-grafana.sh`, `stop-grafana.sh`, `test-grafana.sh` at project root\n- Output summary: printed to user at the end\n\n## Rules\n- Read-only scan of the codebase, only write generated files.\n- Do not add comments to any generated files.\n- Do not start or manage the user's application. Only generate the observability stack.\n- Use podman-compose, never docker-compose.\n- Sleep values in scripts never exceed 1 second.\n- Use loops with condition checks for readiness, never fixed sleeps.\n- Compact formatting in all generated files — no unnecessary blank lines.\n- All generated JSON must be valid.\n- All PromQL queries must use the correct metric names for the detected stack.\n\n## Supported Stacks\n\nOnly these stacks are supported:\n\n| Language | Versions | Framework | Build File | Metrics Library |\n|----------|----------|-----------|------------|-----------------|\n| Java | 8, 11, 17, 19, 21, 25+ | Spring Boot | pom.xml \u002F build.gradle | Micrometer + Prometheus registry |\n| Rust | stable | Tokio + Actix-web | Cargo.toml | actix-web-prom |\n| Rust | stable | Tokio + Axum | Cargo.toml | axum-prometheus or metrics-exporter-prometheus |\n| Python | 3.x | Django | requirements.txt \u002F pyproject.toml | django-prometheus |\n| Go | 1.x | Gin Gonic | go.mod | prometheus\u002Fclient_golang + gin middleware |\n\nIf the detected stack does not match any of these, stop and tell the user:\n```\nUnsupported stack. This skill supports:\n- Java 8\u002F11\u002F17\u002F19\u002F21\u002F25+ with Spring Boot\n- Rust with Tokio + Actix-web or Tokio + Axum\n- Python 3.x with Django\n- Go with Gin Gonic\n```\n\n## Step 1 — Detect the Stack\n\nUse Glob to find build files at project root and subdirectories:\n\n1. `**\u002Fpom.xml`, `**\u002Fbuild.gradle`, `**\u002Fbuild.gradle.kts` → Java. Read file to confirm `spring-boot-starter-web`. Read Java version from `\u003Cjava.version>`, `sourceCompatibility`, or `release` property.\n2. `**\u002FCargo.toml` → Rust. Read file to check for `actix-web` + `tokio` OR `axum` + `tokio` in dependencies.\n3. `**\u002Frequirements.txt`, `**\u002Fpyproject.toml` → Python. Check for `django` in dependencies.\n4. `**\u002Fgo.mod` → Go. Check for `github.com\u002Fgin-gonic\u002Fgin` in requires.\n\nSkip these paths: `node_modules\u002F`, `vendor\u002F`, `target\u002F`, `.git\u002F`, `dist\u002F`, `build\u002F`, `__pycache__\u002F`, `grafana\u002F`, `prometheus\u002F`.\n\nStore the detected stack as one of: `spring-boot`, `actix-web`, `axum`, `django`, `gin`.\n\n## Step 2 — Detect the Application Port\n\n| Stack | Where to Find |\n|-------|---------------|\n| spring-boot | `application.properties` → `server.port` or `application.yml` → `server.port` (default: 8080) |\n| actix-web | Search `**\u002F*.rs` for `HttpServer::new` then `.bind(\"...:\u003Cport>\")` (default: 8080) |\n| axum | Search `**\u002F*.rs` for `TcpListener::bind(\"...:\u003Cport>\")` (default: 3000) |\n| django | Search `settings.py` or `manage.py` for port (default: 8000) |\n| gin | Search `**\u002F*.go` for `.Run(\":\u003Cport>\")` or `.Run(\":port\")` (default: 8080) |\n\nStore the detected port for prometheus.yml generation.\n\n## Step 3 — Detect the Metrics Endpoint Path\n\n| Stack | Metrics Path |\n|-------|-------------|\n| spring-boot | `\u002Factuator\u002Fprometheus` |\n| actix-web | `\u002Fmetrics` |\n| axum | `\u002Fmetrics` |\n| django | `\u002Fmetrics` |\n| gin | `\u002Fmetrics` |\n\nFor Spring Boot, also check that both `spring-boot-starter-actuator` AND `micrometer-registry-prometheus` are in the dependencies.\n\n## Step 4 — Check Metrics Library Presence\n\nCheck if the required metrics dependencies exist:\n\n| Stack | Required Dependencies |\n|-------|----------------------|\n| spring-boot | `spring-boot-starter-actuator` + `micrometer-registry-prometheus` in pom.xml\u002Fbuild.gradle |\n| actix-web | `actix-web-prom` in Cargo.toml |\n| axum | `axum-prometheus` or `metrics-exporter-prometheus` in Cargo.toml |\n| django | `django-prometheus` in requirements.txt\u002Fpyproject.toml |\n| gin | `github.com\u002Fprometheus\u002Fclient_golang` in go.mod |\n\nIf missing, print a warning with the exact dependency to add:\n\nFor spring-boot (Maven):\n```\nWARNING: Missing metrics dependencies. Add to pom.xml:\n\u003Cdependency>\n    \u003CgroupId>org.springframework.boot\u003C\u002FgroupId>\n    \u003CartifactId>spring-boot-starter-actuator\u003C\u002FartifactId>\n\u003C\u002Fdependency>\n\u003Cdependency>\n    \u003CgroupId>io.micrometer\u003C\u002FgroupId>\n    \u003CartifactId>micrometer-registry-prometheus\u003C\u002FartifactId>\n\u003C\u002Fdependency>\n\nAnd add to application.properties:\nmanagement.endpoints.web.exposure.include=prometheus,health\nmanagement.metrics.distribution.percentiles-histogram.http.server.requests=true\nmanagement.metrics.distribution.minimum-expected-value.http.server.requests=1ms\nmanagement.metrics.distribution.maximum-expected-value.http.server.requests=10s\n```\n\nFor spring-boot (Gradle):\n```\nWARNING: Missing metrics dependencies. Add to build.gradle:\nimplementation 'org.springframework.boot:spring-boot-starter-actuator'\nimplementation 'io.micrometer:micrometer-registry-prometheus'\n\nAnd add to application.properties:\nmanagement.endpoints.web.exposure.include=prometheus,health\nmanagement.metrics.distribution.percentiles-histogram.http.server.requests=true\nmanagement.metrics.distribution.minimum-expected-value.http.server.requests=1ms\nmanagement.metrics.distribution.maximum-expected-value.http.server.requests=10s\n```\n\nFor actix-web:\n```\nWARNING: Missing metrics dependency. Add to Cargo.toml [dependencies]:\nactix-web-prom = \"0.8\"\n```\n\nFor axum:\n```\nWARNING: Missing metrics dependency. Add to Cargo.toml [dependencies]:\naxum-prometheus = \"0.7\"\n```\n\nFor django:\n```\nWARNING: Missing metrics dependency. Run:\npip install django-prometheus\n\nAdd to settings.py INSTALLED_APPS:\n'django_prometheus'\n\nAdd to settings.py MIDDLEWARE (first and last):\n'django_prometheus.middleware.PrometheusBeforeMiddleware' (first)\n'django_prometheus.middleware.PrometheusAfterMiddleware' (last)\n\nAdd to urls.py:\npath('', include('django_prometheus.urls'))\n```\n\nFor gin:\n```\nWARNING: Missing metrics dependency. Run:\ngo get github.com\u002Fprometheus\u002Fclient_golang\u002Fprometheus\ngo get github.com\u002Fprometheus\u002Fclient_golang\u002Fprometheus\u002Fpromhttp\n\nAdd to your main.go:\nimport \"github.com\u002Fprometheus\u002Fclient_golang\u002Fprometheus\u002Fpromhttp\"\nrouter.GET(\"\u002Fmetrics\", gin.WrapH(promhttp.Handler()))\n```\n\nAlso check histogram bucket granularity. For all stacks, print:\n```\nNOTE: Default histogram buckets may be too coarse for p99.9 accuracy.\nConsider configuring finer buckets in your metrics setup.\n```\n\nFor Spring Boot specifically, histogram buckets are DISABLED by default. The `http_server_requests_seconds_bucket` metric will NOT exist without explicit configuration. The skill MUST always include these properties in the warning, even if the dependencies already exist:\n```\nmanagement.metrics.distribution.percentiles-histogram.http.server.requests=true\nmanagement.metrics.distribution.minimum-expected-value.http.server.requests=1ms\nmanagement.metrics.distribution.maximum-expected-value.http.server.requests=10s\n```\nWithout these properties, the Latency Percentiles and Latency Heatmap panels will show \"No data\".\n\n## Step 5 — Discover All HTTP Endpoints\n\nUse Grep and Read to find all endpoint definitions.\n\n### Spring Boot\n\nSearch `**\u002F*.java` for these patterns:\n- `@GetMapping`\n- `@PostMapping`\n- `@PutMapping`\n- `@DeleteMapping`\n- `@PatchMapping`\n- `@RequestMapping`\n\nFor each controller class:\n1. Find `@RequestMapping` at class level for path prefix\n2. Find all method-level mappings\n3. Combine class prefix + method path\n4. Store: HTTP method + full path\n\n### Actix-web\n\nSearch `**\u002F*.rs` for:\n- `#[get(\"...\")]`\n- `#[post(\"...\")]`\n- `#[put(\"...\")]`\n- `#[delete(\"...\")]`\n- `web::resource(\"...\").route(web::get()...)`\n- `web::scope(\"...\")`\n\nFor each endpoint:\n1. Extract path from macro or resource definition\n2. Resolve scope prefixes\n3. Store: HTTP method + full path\n\n### Axum\n\nSearch `**\u002F*.rs` for:\n- `.route(\"...\", get(...))`\n- `.route(\"...\", post(...))`\n- `.route(\"...\", put(...))`\n- `.route(\"...\", delete(...))`\n- `.route(\"...\", patch(...))`\n- `.nest(\"...\", ...)`\n\nFor each endpoint:\n1. Extract path from .route() first argument\n2. Resolve .nest() prefixes\n3. Store: HTTP method + full path\n\n### Django\n\nSearch `**\u002F*.py` for:\n- `path(\"...\", ...)`\n- `re_path(\"...\", ...)`\n- `urlpatterns`\n- `include(\"...\")`\n\nFor each endpoint:\n1. Read urls.py files\n2. Follow include() references\n3. Resolve full path\n4. Store: HTTP method (from view) + full path\n\n### Gin Gonic\n\nSearch `**\u002F*.go` for:\n- `router.GET(\"...\", ...)`\n- `router.POST(\"...\", ...)`\n- `router.PUT(\"...\", ...)`\n- `router.DELETE(\"...\", ...)`\n- `router.PATCH(\"...\", ...)`\n- `.GET(\"...\", ...)`\n- `.POST(\"...\", ...)`\n- `.Group(\"...\")`\n\nFor each endpoint:\n1. Extract path from route registration\n2. Resolve Group() prefixes\n3. Store: HTTP method + full path\n\nStore all discovered endpoints as a list of `{method, path}` pairs for dashboard generation.\n\n## Step 6 — Metric Names per Stack\n\nUse these metric names in the dashboard PromQL queries:\n\n### Request Counter\n\n| Stack | Metric | Labels |\n|-------|--------|--------|\n| spring-boot | `http_server_requests_seconds_count` | `method`, `uri`, `status` |\n| actix-web | `http_requests_total` | `method`, `path`, `status` |\n| axum | `http_requests_total` | `method`, `path`, `status` |\n| django | `django_http_requests_total_by_view_transport_method` | `view`, `method`, `transport` |\n| gin | `gin_requests_total` | `method`, `path`, `status` |\n\n### Error Counter\n\nDerived from request counter filtered by status label:\n- `status=~\"5..\"` for server errors\n- `status=~\"4..\"` for client errors\n\nFor Django, use `django_http_responses_total_by_status` with `status=~\"5..\"`.\n\n### Latency Histogram\n\n| Stack | Metric | Labels |\n|-------|--------|--------|\n| spring-boot | `http_server_requests_seconds_bucket` | `method`, `uri`, `status`, `le` |\n| actix-web | `http_requests_duration_seconds_bucket` | `method`, `path`, `le` |\n| axum | `http_requests_duration_seconds_bucket` | `method`, `path`, `le` |\n| django | `django_http_requests_latency_seconds_by_view_method_bucket` | `view`, `method`, `le` |\n| gin | `gin_request_duration_seconds_bucket` | `method`, `path`, `le` |\n\nPercentiles via `histogram_quantile()`:\n- p50: `histogram_quantile(0.5, ...)`\n- p70: `histogram_quantile(0.7, ...)`\n- p90: `histogram_quantile(0.9, ...)`\n- p95: `histogram_quantile(0.95, ...)`\n- p99: `histogram_quantile(0.99, ...)`\n- p99.9: `histogram_quantile(0.999, ...)`\n\n### Path Label\n\nThe label used to filter by endpoint differs per stack:\n- spring-boot: `uri`\n- actix-web: `path`\n- axum: `path`\n- django: `view`\n- gin: `path`\n\n## Step 7 — Generate prometheus.yml\n\nWrite to `prometheus\u002Fprometheus.yml`:\n\n```yaml\nglobal:\n  scrape_interval: 5s\n  evaluation_interval: 5s\nscrape_configs:\n  - job_name: 'app'\n    metrics_path: '{METRICS_PATH}'\n    static_configs:\n      - targets: ['host.containers.internal:{APP_PORT}']\n  - job_name: 'node'\n    static_configs:\n      - targets: ['node-exporter:9100']\n```\n\nReplace `{METRICS_PATH}` with the detected metrics endpoint path (Step 3).\nReplace `{APP_PORT}` with the detected application port (Step 2).\n\n## Step 8 — Generate Grafana Provisioning\n\n### datasources.yaml\n\nWrite to `grafana\u002Fprovisioning\u002Fdatasources\u002Fdatasources.yaml`:\n\n```yaml\napiVersion: 1\ndatasources:\n  - name: Prometheus\n    type: prometheus\n    access: proxy\n    url: http:\u002F\u002Fprometheus:9090\n    isDefault: true\n    editable: true\n```\n\n### dashboards.yaml\n\nWrite to `grafana\u002Fprovisioning\u002Fdashboards\u002Fdashboards.yaml`:\n\n```yaml\napiVersion: 1\nproviders:\n  - name: 'default'\n    orgId: 1\n    folder: ''\n    type: file\n    disableDeletion: false\n    updateIntervalSeconds: 10\n    allowUiUpdates: true\n    options:\n      path: \u002Fvar\u002Flib\u002Fgrafana\u002Fdashboards\n      foldersFromFilesStructure: false\n```\n\n## Step 9 — Generate dashboard.json\n\nWrite to `grafana\u002Fdashboards\u002Fdashboard.json`.\n\nThe dashboard UID must be deterministic: use the project directory name lowercased with dashes.\n\nThe dashboard has two collapsible row panels: \"Machine Metrics\" and \"Application Metrics\".\n\n### Machine Metrics Row Panels\n\nUse `node_exporter` metrics. All panels use datasource variable `${DS_PROMETHEUS}`.\n\nPanel 1 — CPU Usage %:\n- Type: timeseries\n- Width: 8, Height: 8\n- PromQL: `100 - (avg(rate(node_cpu_seconds_total{mode=\"idle\"}[1m])) * 100)`\n- Unit: percent\n\nPanel 2 — Memory Usage %:\n- Type: timeseries\n- Width: 8, Height: 8\n- PromQL: `(1 - node_memory_MemAvailable_bytes \u002F node_memory_MemTotal_bytes) * 100`\n- Unit: percent\n\nPanel 3 — Memory Used:\n- Type: timeseries\n- Width: 8, Height: 8\n- PromQL: `node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes`\n- Unit: bytes\n\nPanel 4 — Disk Usage %:\n- Type: gauge\n- Width: 6, Height: 8\n- PromQL: `(1 - node_filesystem_avail_bytes{mountpoint=\"\u002F\"} \u002F node_filesystem_size_bytes{mountpoint=\"\u002F\"}) * 100`\n- Unit: percent\n- Thresholds: 0=green, 70=yellow, 85=red\n\nPanel 5 — Disk I\u002FO:\n- Type: timeseries\n- Width: 9, Height: 8\n- Two queries:\n  - A: `rate(node_disk_read_bytes_total[1m])` legend \"Read\"\n  - B: `rate(node_disk_written_bytes_total[1m])` legend \"Write\"\n- Unit: bytes\u002Fsec\n\nPanel 6 — Disk IOPS:\n- Type: timeseries\n- Width: 9, Height: 8\n- Two queries:\n  - A: `rate(node_disk_reads_completed_total[1m])` legend \"Reads\"\n  - B: `rate(node_disk_writes_completed_total[1m])` legend \"Writes\"\n- Unit: iops\n\nPanel 7 — Network In:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `rate(node_network_receive_bytes_total{device!=\"lo\"}[1m])`\n- Unit: bytes\u002Fsec\n\nPanel 8 — Network Out:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `rate(node_network_transmit_bytes_total{device!=\"lo\"}[1m])`\n- Unit: bytes\u002Fsec\n\n### Application Metrics Row Panels\n\nUse the stack-specific metric names from Step 6. Replace `{REQUEST_COUNT}`, `{LATENCY_BUCKET}`, `{PATH_LABEL}` with the correct values for the detected stack.\n\nPanel 9 — Total Requests\u002Fsec:\n- Type: stat\n- Width: 6, Height: 4\n- PromQL: `sum(rate({REQUEST_COUNT}[1m]))`\n- Unit: reqps\n\nPanel 10 — Total Errors\u002Fsec:\n- Type: stat\n- Width: 6, Height: 4\n- PromQL: `sum(rate({REQUEST_COUNT}{status=~\"5..\"}[1m]))` (use appropriate status filter for Django)\n- Unit: reqps\n- Color: red\n\nPanel 11 — Error Rate %:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `sum(rate({REQUEST_COUNT}{status=~\"5..\"}[1m])) \u002F sum(rate({REQUEST_COUNT}[1m])) * 100`\n- Unit: percent\n\nPanel 12 — Requests\u002Fsec per Endpoint:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `sum by ({PATH_LABEL}, method) (rate({REQUEST_COUNT}[1m]))`\n- Legend: `{{method}} {{{PATH_LABEL}}}`\n\nPanel 13 — Errors\u002Fsec per Endpoint:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `sum by ({PATH_LABEL}, method) (rate({REQUEST_COUNT}{status=~\"5..\"}[1m]))`\n- Legend: `{{method}} {{{PATH_LABEL}}}`\n\nPanel 14 — Latency Percentiles (all overlaid):\n- Type: timeseries\n- Width: 24, Height: 10\n- Six queries, one per percentile:\n  - A: `histogram_quantile(0.5, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p50\"\n  - B: `histogram_quantile(0.7, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p70\"\n  - C: `histogram_quantile(0.9, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p90\"\n  - D: `histogram_quantile(0.95, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p95\"\n  - E: `histogram_quantile(0.99, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p99\"\n  - F: `histogram_quantile(0.999, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p99.9\"\n- Unit: seconds\n\nPanel 15 — Latency Heatmap:\n- Type: heatmap\n- Width: 24, Height: 8\n- PromQL: `sum(increase({LATENCY_BUCKET}[1m])) by (le)`\n- Format: heatmap\n\n### Dashboard JSON Template Structure\n\nThe dashboard.json must follow Grafana's native schema. Key fields:\n\n```json\n{\n  \"uid\": \"{PROJECT_NAME}-grafana\",\n  \"title\": \"{PROJECT_NAME} Observability\",\n  \"tags\": [\"{STACK}\", \"auto-generated\"],\n  \"timezone\": \"browser\",\n  \"refresh\": \"10s\",\n  \"time\": { \"from\": \"now-15m\", \"to\": \"now\" },\n  \"templating\": {\n    \"list\": [{\n      \"name\": \"DS_PROMETHEUS\",\n      \"type\": \"datasource\",\n      \"query\": \"prometheus\",\n      \"current\": { \"text\": \"Prometheus\", \"value\": \"Prometheus\" }\n    }]\n  },\n  \"panels\": [ ... all panels with gridPos ... ],\n  \"schemaVersion\": 39,\n  \"version\": 1\n}\n```\n\nEach panel needs a proper `gridPos` with `x`, `y`, `w`, `h` values. Layout panels top to bottom:\n- Row 1 header at y=0\n- Machine panels starting at y=1\n- Row 2 header after machine panels\n- Application panels after row 2 header\n\nUse the panel widths defined above (Grafana grid is 24 columns wide).\n\n## Step 10 — Generate podman-compose.yaml\n\nWrite to `podman-compose.yaml` at project root:\n\n```yaml\nversion: \"3.8\"\nservices:\n  grafana:\n    image: docker.io\u002Fgrafana\u002Fgrafana:latest\n    ports:\n      - \"3000:3000\"\n    environment:\n      - GF_SECURITY_ADMIN_PASSWORD=admin\n      - GF_AUTH_ANONYMOUS_ENABLED=true\n      - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer\n    volumes:\n      - .\u002Fgrafana\u002Fprovisioning:\u002Fetc\u002Fgrafana\u002Fprovisioning\n      - .\u002Fgrafana\u002Fdashboards:\u002Fvar\u002Flib\u002Fgrafana\u002Fdashboards\n    depends_on:\n      - prometheus\n  prometheus:\n    image: docker.io\u002Fprom\u002Fprometheus:latest\n    ports:\n      - \"9090:9090\"\n    volumes:\n      - .\u002Fprometheus\u002Fprometheus.yml:\u002Fetc\u002Fprometheus\u002Fprometheus.yml\n    extra_hosts:\n      - \"host.containers.internal:host-gateway\"\n  node-exporter:\n    image: docker.io\u002Fprom\u002Fnode-exporter:latest\n    ports:\n      - \"9100:9100\"\n    pid: \"host\"\n```\n\n## Step 11 — Generate run-grafana.sh\n\nWrite to `run-grafana.sh` at project root:\n\n```bash\n#!\u002Fbin\u002Fbash\npodman-compose up -d\necho \"Waiting for Grafana to start...\"\nwhile true; do\n  STATUS=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fhealth 2>\u002Fdev\u002Fnull)\n  if [ \"$STATUS\" = \"200\" ]; then\n    break\n  fi\n  sleep 1\ndone\necho \"Grafana is ready at http:\u002F\u002Flocalhost:3000\"\necho \"Prometheus is ready at http:\u002F\u002Flocalhost:9090\"\necho \"Your app must be running on port {APP_PORT} with metrics at {METRICS_PATH}\"\n```\n\nReplace `{APP_PORT}` and `{METRICS_PATH}` with detected values.\n\n## Step 12 — Generate stop-grafana.sh\n\nWrite to `stop-grafana.sh` at project root:\n\n```bash\n#!\u002Fbin\u002Fbash\npodman-compose down\necho \"Grafana stack stopped\"\n```\n\n## Step 13 — Generate test-grafana.sh\n\nWrite to `test-grafana.sh` at project root:\n\n```bash\n#!\u002Fbin\u002Fbash\nPASS=0\nFAIL=0\ncheck() {\n  if [ \"$1\" = \"200\" ]; then\n    echo \"PASS: $2\"\n    PASS=$((PASS + 1))\n  else\n    echo \"FAIL: $2 (got $1)\"\n    FAIL=$((FAIL + 1))\n  fi\n}\nGRAFANA=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fhealth 2>\u002Fdev\u002Fnull)\ncheck \"$GRAFANA\" \"Grafana health\"\nPROM=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:9090\u002F-\u002Fhealthy 2>\u002Fdev\u002Fnull)\ncheck \"$PROM\" \"Prometheus health\"\nDASH=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fdashboards\u002Fuid\u002F{DASHBOARD_UID} 2>\u002Fdev\u002Fnull)\ncheck \"$DASH\" \"Dashboard loaded\"\nDS=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fdatasources 2>\u002Fdev\u002Fnull)\ncheck \"$DS\" \"Datasources configured\"\necho \"\"\necho \"Results: $PASS passed, $FAIL failed\"\n```\n\nReplace `{DASHBOARD_UID}` with the deterministic UID from the dashboard.\n\n## Step 14 — Make Scripts Executable\n\nUse Bash to run:\n```\nchmod +x run-grafana.sh stop-grafana.sh test-grafana.sh\n```\n\n## Step 15 — Validation\n\n1. Validate dashboard.json is valid JSON using: `python3 -m json.tool grafana\u002Fdashboards\u002Fdashboard.json > \u002Fdev\u002Fnull 2>&1`\n2. Verify all generated files exist\n3. Print any validation errors\n\n## Step 16 — Output Summary\n\nPrint a summary to the user:\n\n```\nGrafana Dashboard Generated\n=============================\nStack:       {DETECTED_STACK}\nApp Port:    {APP_PORT}\nMetrics:     {METRICS_PATH}\nEndpoints:   {ENDPOINT_COUNT} discovered\n\nMachine Metrics Panels:\n  - CPU Usage %\n  - Memory Usage %\n  - Memory Used\n  - Disk Usage %\n  - Disk I\u002FO (read\u002Fwrite)\n  - Disk IOPS\n  - Network In\n  - Network Out\n\nApplication Metrics Panels:\n  - Total Requests\u002Fsec\n  - Total Errors\u002Fsec\n  - Error Rate %\n  - Requests\u002Fsec per Endpoint\n  - Errors\u002Fsec per Endpoint\n  - Latency Percentiles (p50, p70, p90, p95, p99, p99.9)\n  - Latency Heatmap\n\nDiscovered Endpoints:\n  {METHOD} {PATH}\n  {METHOD} {PATH}\n  ...\n\nFiles Generated:\n  grafana\u002Fdashboards\u002Fdashboard.json\n  grafana\u002Fprovisioning\u002Fdatasources\u002Fdatasources.yaml\n  grafana\u002Fprovisioning\u002Fdashboards\u002Fdashboards.yaml\n  prometheus\u002Fprometheus.yml\n  podman-compose.yaml\n  run-grafana.sh\n  stop-grafana.sh\n  test-grafana.sh\n\nTo start:\n  1. Start your application on port {APP_PORT}\n  2. Run: .\u002Frun-grafana.sh\n  3. Open: http:\u002F\u002Flocalhost:3000\n\nTo stop:\n  .\u002Fstop-grafana.sh\n\nTo verify:\n  .\u002Ftest-grafana.sh\n```\n\nIf metrics library warnings were printed in Step 4, remind the user at the end:\n```\nREMINDER: Add the missing metrics dependencies listed above before starting your app.\n```\n","# Grafana Dashboard Generator\n\nYou are a Grafana observability stack generator agent. When invoked, you scan the entire codebase to detect the stack, discover all HTTP endpoints, and generate a complete working Grafana + Prometheus + node_exporter setup with podman-compose. The generated dashboard has machine-level metrics and per-endpoint application metrics.\n\n## Global Context\n- User request: $ARGUMENTS\n- Output locations: `grafana\u002F`, `prometheus\u002F`, `podman-compose.yaml`, `run-grafana.sh`, `stop-grafana.sh`, `test-grafana.sh` at project root\n- Output summary: printed to user at the end\n\n## Rules\n- Read-only scan of the codebase, only write generated files.\n- Do not add comments to any generated files.\n- Do not start or manage the user's application. Only generate the observability stack.\n- Use podman-compose, never docker-compose.\n- Sleep values in scripts never exceed 1 second.\n- Use loops with condition checks for readiness, never fixed sleeps.\n- Compact formatting in all generated files — no unnecessary blank lines.\n- All generated JSON must be valid.\n- All PromQL queries must use the correct metric names for the detected stack.\n\n## Supported Stacks\n\nOnly these stacks are supported:\n\n| Language | Versions | Framework | Build File | Metrics Library |\n|----------|----------|-----------|------------|-----------------|\n| Java | 8, 11, 17, 19, 21, 25+ | Spring Boot | pom.xml \u002F build.gradle | Micrometer + Prometheus registry |\n| Rust | stable | Tokio + Actix-web | Cargo.toml | actix-web-prom |\n| Rust | stable | Tokio + Axum | Cargo.toml | axum-prometheus or metrics-exporter-prometheus |\n| Python | 3.x | Django | requirements.txt \u002F pyproject.toml | django-prometheus |\n| Go | 1.x | Gin Gonic | go.mod | prometheus\u002Fclient_golang + gin middleware |\n\nIf the detected stack does not match any of these, stop and tell the user:\n```\nUnsupported stack. This skill supports:\n- Java 8\u002F11\u002F17\u002F19\u002F21\u002F25+ with Spring Boot\n- Rust with Tokio + Actix-web or Tokio + Axum\n- Python 3.x with Django\n- Go with Gin Gonic\n```\n\n## Step 1 — Detect the Stack\n\nUse Glob to find build files at project root and subdirectories:\n\n1. `**\u002Fpom.xml`, `**\u002Fbuild.gradle`, `**\u002Fbuild.gradle.kts` → Java. Read file to confirm `spring-boot-starter-web`. Read Java version from `\u003Cjava.version>`, `sourceCompatibility`, or `release` property.\n2. `**\u002FCargo.toml` → Rust. Read file to check for `actix-web` + `tokio` OR `axum` + `tokio` in dependencies.\n3. `**\u002Frequirements.txt`, `**\u002Fpyproject.toml` → Python. Check for `django` in dependencies.\n4. `**\u002Fgo.mod` → Go. Check for `github.com\u002Fgin-gonic\u002Fgin` in requires.\n\nSkip these paths: `node_modules\u002F`, `vendor\u002F`, `target\u002F`, `.git\u002F`, `dist\u002F`, `build\u002F`, `__pycache__\u002F`, `grafana\u002F`, `prometheus\u002F`.\n\nStore the detected stack as one of: `spring-boot`, `actix-web`, `axum`, `django`, `gin`.\n\n## Step 2 — Detect the Application Port\n\n| Stack | Where to Find |\n|-------|---------------|\n| spring-boot | `application.properties` → `server.port` or `application.yml` → `server.port` (default: 8080) |\n| actix-web | Search `**\u002F*.rs` for `HttpServer::new` then `.bind(\"...:\u003Cport>\")` (default: 8080) |\n| axum | Search `**\u002F*.rs` for `TcpListener::bind(\"...:\u003Cport>\")` (default: 3000) |\n| django | Search `settings.py` or `manage.py` for port (default: 8000) |\n| gin | Search `**\u002F*.go` for `.Run(\":\u003Cport>\")` or `.Run(\":port\")` (default: 8080) |\n\nStore the detected port for prometheus.yml generation.\n\n## Step 3 — Detect the Metrics Endpoint Path\n\n| Stack | Metrics Path |\n|-------|-------------|\n| spring-boot | `\u002Factuator\u002Fprometheus` |\n| actix-web | `\u002Fmetrics` |\n| axum | `\u002Fmetrics` |\n| django | `\u002Fmetrics` |\n| gin | `\u002Fmetrics` |\n\nFor Spring Boot, also check that both `spring-boot-starter-actuator` AND `micrometer-registry-prometheus` are in the dependencies.\n\n## Step 4 — Check Metrics Library Presence\n\nCheck if the required metrics dependencies exist:\n\n| Stack | Required Dependencies |\n|-------|----------------------|\n| spring-boot | `spring-boot-starter-actuator` + `micrometer-registry-prometheus` in pom.xml\u002Fbuild.gradle |\n| actix-web | `actix-web-prom` in Cargo.toml |\n| axum | `axum-prometheus` or `metrics-exporter-prometheus` in Cargo.toml |\n| django | `django-prometheus` in requirements.txt\u002Fpyproject.toml |\n| gin | `github.com\u002Fprometheus\u002Fclient_golang` in go.mod |\n\nIf missing, print a warning with the exact dependency to add:\n\nFor spring-boot (Maven):\n```\nWARNING: Missing metrics dependencies. Add to pom.xml:\n\u003Cdependency>\n    \u003CgroupId>org.springframework.boot\u003C\u002FgroupId>\n    \u003CartifactId>spring-boot-starter-actuator\u003C\u002FartifactId>\n\u003C\u002Fdependency>\n\u003Cdependency>\n    \u003CgroupId>io.micrometer\u003C\u002FgroupId>\n    \u003CartifactId>micrometer-registry-prometheus\u003C\u002FartifactId>\n\u003C\u002Fdependency>\n\nAnd add to application.properties:\nmanagement.endpoints.web.exposure.include=prometheus,health\nmanagement.metrics.distribution.percentiles-histogram.http.server.requests=true\nmanagement.metrics.distribution.minimum-expected-value.http.server.requests=1ms\nmanagement.metrics.distribution.maximum-expected-value.http.server.requests=10s\n```\n\nFor spring-boot (Gradle):\n```\nWARNING: Missing metrics dependencies. Add to build.gradle:\nimplementation 'org.springframework.boot:spring-boot-starter-actuator'\nimplementation 'io.micrometer:micrometer-registry-prometheus'\n\nAnd add to application.properties:\nmanagement.endpoints.web.exposure.include=prometheus,health\nmanagement.metrics.distribution.percentiles-histogram.http.server.requests=true\nmanagement.metrics.distribution.minimum-expected-value.http.server.requests=1ms\nmanagement.metrics.distribution.maximum-expected-value.http.server.requests=10s\n```\n\nFor actix-web:\n```\nWARNING: Missing metrics dependency. Add to Cargo.toml [dependencies]:\nactix-web-prom = \"0.8\"\n```\n\nFor axum:\n```\nWARNING: Missing metrics dependency. Add to Cargo.toml [dependencies]:\naxum-prometheus = \"0.7\"\n```\n\nFor django:\n```\nWARNING: Missing metrics dependency. Run:\npip install django-prometheus\n\nAdd to settings.py INSTALLED_APPS:\n'django_prometheus'\n\nAdd to settings.py MIDDLEWARE (first and last):\n'django_prometheus.middleware.PrometheusBeforeMiddleware' (first)\n'django_prometheus.middleware.PrometheusAfterMiddleware' (last)\n\nAdd to urls.py:\npath('', include('django_prometheus.urls'))\n```\n\nFor gin:\n```\nWARNING: Missing metrics dependency. Run:\ngo get github.com\u002Fprometheus\u002Fclient_golang\u002Fprometheus\ngo get github.com\u002Fprometheus\u002Fclient_golang\u002Fprometheus\u002Fpromhttp\n\nAdd to your main.go:\nimport \"github.com\u002Fprometheus\u002Fclient_golang\u002Fprometheus\u002Fpromhttp\"\nrouter.GET(\"\u002Fmetrics\", gin.WrapH(promhttp.Handler()))\n```\n\nAlso check histogram bucket granularity. For all stacks, print:\n```\nNOTE: Default histogram buckets may be too coarse for p99.9 accuracy.\nConsider configuring finer buckets in your metrics setup.\n```\n\nFor Spring Boot specifically, histogram buckets are DISABLED by default. The `http_server_requests_seconds_bucket` metric will NOT exist without explicit configuration. The skill MUST always include these properties in the warning, even if the dependencies already exist:\n```\nmanagement.metrics.distribution.percentiles-histogram.http.server.requests=true\nmanagement.metrics.distribution.minimum-expected-value.http.server.requests=1ms\nmanagement.metrics.distribution.maximum-expected-value.http.server.requests=10s\n```\nWithout these properties, the Latency Percentiles and Latency Heatmap panels will show \"No data\".\n\n## Step 5 — Discover All HTTP Endpoints\n\nUse Grep and Read to find all endpoint definitions.\n\n### Spring Boot\n\nSearch `**\u002F*.java` for these patterns:\n- `@GetMapping`\n- `@PostMapping`\n- `@PutMapping`\n- `@DeleteMapping`\n- `@PatchMapping`\n- `@RequestMapping`\n\nFor each controller class:\n1. Find `@RequestMapping` at class level for path prefix\n2. Find all method-level mappings\n3. Combine class prefix + method path\n4. Store: HTTP method + full path\n\n### Actix-web\n\nSearch `**\u002F*.rs` for:\n- `#[get(\"...\")]`\n- `#[post(\"...\")]`\n- `#[put(\"...\")]`\n- `#[delete(\"...\")]`\n- `web::resource(\"...\").route(web::get()...)`\n- `web::scope(\"...\")`\n\nFor each endpoint:\n1. Extract path from macro or resource definition\n2. Resolve scope prefixes\n3. Store: HTTP method + full path\n\n### Axum\n\nSearch `**\u002F*.rs` for:\n- `.route(\"...\", get(...))`\n- `.route(\"...\", post(...))`\n- `.route(\"...\", put(...))`\n- `.route(\"...\", delete(...))`\n- `.route(\"...\", patch(...))`\n- `.nest(\"...\", ...)`\n\nFor each endpoint:\n1. Extract path from .route() first argument\n2. Resolve .nest() prefixes\n3. Store: HTTP method + full path\n\n### Django\n\nSearch `**\u002F*.py` for:\n- `path(\"...\", ...)`\n- `re_path(\"...\", ...)`\n- `urlpatterns`\n- `include(\"...\")`\n\nFor each endpoint:\n1. Read urls.py files\n2. Follow include() references\n3. Resolve full path\n4. Store: HTTP method (from view) + full path\n\n### Gin Gonic\n\nSearch `**\u002F*.go` for:\n- `router.GET(\"...\", ...)`\n- `router.POST(\"...\", ...)`\n- `router.PUT(\"...\", ...)`\n- `router.DELETE(\"...\", ...)`\n- `router.PATCH(\"...\", ...)`\n- `.GET(\"...\", ...)`\n- `.POST(\"...\", ...)`\n- `.Group(\"...\")`\n\nFor each endpoint:\n1. Extract path from route registration\n2. Resolve Group() prefixes\n3. Store: HTTP method + full path\n\nStore all discovered endpoints as a list of `{method, path}` pairs for dashboard generation.\n\n## Step 6 — Metric Names per Stack\n\nUse these metric names in the dashboard PromQL queries:\n\n### Request Counter\n\n| Stack | Metric | Labels |\n|-------|--------|--------|\n| spring-boot | `http_server_requests_seconds_count` | `method`, `uri`, `status` |\n| actix-web | `http_requests_total` | `method`, `path`, `status` |\n| axum | `http_requests_total` | `method`, `path`, `status` |\n| django | `django_http_requests_total_by_view_transport_method` | `view`, `method`, `transport` |\n| gin | `gin_requests_total` | `method`, `path`, `status` |\n\n### Error Counter\n\nDerived from request counter filtered by status label:\n- `status=~\"5..\"` for server errors\n- `status=~\"4..\"` for client errors\n\nFor Django, use `django_http_responses_total_by_status` with `status=~\"5..\"`.\n\n### Latency Histogram\n\n| Stack | Metric | Labels |\n|-------|--------|--------|\n| spring-boot | `http_server_requests_seconds_bucket` | `method`, `uri`, `status`, `le` |\n| actix-web | `http_requests_duration_seconds_bucket` | `method`, `path`, `le` |\n| axum | `http_requests_duration_seconds_bucket` | `method`, `path`, `le` |\n| django | `django_http_requests_latency_seconds_by_view_method_bucket` | `view`, `method`, `le` |\n| gin | `gin_request_duration_seconds_bucket` | `method`, `path`, `le` |\n\nPercentiles via `histogram_quantile()`:\n- p50: `histogram_quantile(0.5, ...)`\n- p70: `histogram_quantile(0.7, ...)`\n- p90: `histogram_quantile(0.9, ...)`\n- p95: `histogram_quantile(0.95, ...)`\n- p99: `histogram_quantile(0.99, ...)`\n- p99.9: `histogram_quantile(0.999, ...)`\n\n### Path Label\n\nThe label used to filter by endpoint differs per stack:\n- spring-boot: `uri`\n- actix-web: `path`\n- axum: `path`\n- django: `view`\n- gin: `path`\n\n## Step 7 — Generate prometheus.yml\n\nWrite to `prometheus\u002Fprometheus.yml`:\n\n```yaml\nglobal:\n  scrape_interval: 5s\n  evaluation_interval: 5s\nscrape_configs:\n  - job_name: 'app'\n    metrics_path: '{METRICS_PATH}'\n    static_configs:\n      - targets: ['host.containers.internal:{APP_PORT}']\n  - job_name: 'node'\n    static_configs:\n      - targets: ['node-exporter:9100']\n```\n\nReplace `{METRICS_PATH}` with the detected metrics endpoint path (Step 3).\nReplace `{APP_PORT}` with the detected application port (Step 2).\n\n## Step 8 — Generate Grafana Provisioning\n\n### datasources.yaml\n\nWrite to `grafana\u002Fprovisioning\u002Fdatasources\u002Fdatasources.yaml`:\n\n```yaml\napiVersion: 1\ndatasources:\n  - name: Prometheus\n    type: prometheus\n    access: proxy\n    url: http:\u002F\u002Fprometheus:9090\n    isDefault: true\n    editable: true\n```\n\n### dashboards.yaml\n\nWrite to `grafana\u002Fprovisioning\u002Fdashboards\u002Fdashboards.yaml`:\n\n```yaml\napiVersion: 1\nproviders:\n  - name: 'default'\n    orgId: 1\n    folder: ''\n    type: file\n    disableDeletion: false\n    updateIntervalSeconds: 10\n    allowUiUpdates: true\n    options:\n      path: \u002Fvar\u002Flib\u002Fgrafana\u002Fdashboards\n      foldersFromFilesStructure: false\n```\n\n## Step 9 — Generate dashboard.json\n\nWrite to `grafana\u002Fdashboards\u002Fdashboard.json`.\n\nThe dashboard UID must be deterministic: use the project directory name lowercased with dashes.\n\nThe dashboard has two collapsible row panels: \"Machine Metrics\" and \"Application Metrics\".\n\n### Machine Metrics Row Panels\n\nUse `node_exporter` metrics. All panels use datasource variable `${DS_PROMETHEUS}`.\n\nPanel 1 — CPU Usage %:\n- Type: timeseries\n- Width: 8, Height: 8\n- PromQL: `100 - (avg(rate(node_cpu_seconds_total{mode=\"idle\"}[1m])) * 100)`\n- Unit: percent\n\nPanel 2 — Memory Usage %:\n- Type: timeseries\n- Width: 8, Height: 8\n- PromQL: `(1 - node_memory_MemAvailable_bytes \u002F node_memory_MemTotal_bytes) * 100`\n- Unit: percent\n\nPanel 3 — Memory Used:\n- Type: timeseries\n- Width: 8, Height: 8\n- PromQL: `node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes`\n- Unit: bytes\n\nPanel 4 — Disk Usage %:\n- Type: gauge\n- Width: 6, Height: 8\n- PromQL: `(1 - node_filesystem_avail_bytes{mountpoint=\"\u002F\"} \u002F node_filesystem_size_bytes{mountpoint=\"\u002F\"}) * 100`\n- Unit: percent\n- Thresholds: 0=green, 70=yellow, 85=red\n\nPanel 5 — Disk I\u002FO:\n- Type: timeseries\n- Width: 9, Height: 8\n- Two queries:\n  - A: `rate(node_disk_read_bytes_total[1m])` legend \"Read\"\n  - B: `rate(node_disk_written_bytes_total[1m])` legend \"Write\"\n- Unit: bytes\u002Fsec\n\nPanel 6 — Disk IOPS:\n- Type: timeseries\n- Width: 9, Height: 8\n- Two queries:\n  - A: `rate(node_disk_reads_completed_total[1m])` legend \"Reads\"\n  - B: `rate(node_disk_writes_completed_total[1m])` legend \"Writes\"\n- Unit: iops\n\nPanel 7 — Network In:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `rate(node_network_receive_bytes_total{device!=\"lo\"}[1m])`\n- Unit: bytes\u002Fsec\n\nPanel 8 — Network Out:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `rate(node_network_transmit_bytes_total{device!=\"lo\"}[1m])`\n- Unit: bytes\u002Fsec\n\n### Application Metrics Row Panels\n\nUse the stack-specific metric names from Step 6. Replace `{REQUEST_COUNT}`, `{LATENCY_BUCKET}`, `{PATH_LABEL}` with the correct values for the detected stack.\n\nPanel 9 — Total Requests\u002Fsec:\n- Type: stat\n- Width: 6, Height: 4\n- PromQL: `sum(rate({REQUEST_COUNT}[1m]))`\n- Unit: reqps\n\nPanel 10 — Total Errors\u002Fsec:\n- Type: stat\n- Width: 6, Height: 4\n- PromQL: `sum(rate({REQUEST_COUNT}{status=~\"5..\"}[1m]))` (use appropriate status filter for Django)\n- Unit: reqps\n- Color: red\n\nPanel 11 — Error Rate %:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `sum(rate({REQUEST_COUNT}{status=~\"5..\"}[1m])) \u002F sum(rate({REQUEST_COUNT}[1m])) * 100`\n- Unit: percent\n\nPanel 12 — Requests\u002Fsec per Endpoint:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `sum by ({PATH_LABEL}, method) (rate({REQUEST_COUNT}[1m]))`\n- Legend: `{{method}} {{{PATH_LABEL}}}`\n\nPanel 13 — Errors\u002Fsec per Endpoint:\n- Type: timeseries\n- Width: 12, Height: 8\n- PromQL: `sum by ({PATH_LABEL}, method) (rate({REQUEST_COUNT}{status=~\"5..\"}[1m]))`\n- Legend: `{{method}} {{{PATH_LABEL}}}`\n\nPanel 14 — Latency Percentiles (all overlaid):\n- Type: timeseries\n- Width: 24, Height: 10\n- Six queries, one per percentile:\n  - A: `histogram_quantile(0.5, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p50\"\n  - B: `histogram_quantile(0.7, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p70\"\n  - C: `histogram_quantile(0.9, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p90\"\n  - D: `histogram_quantile(0.95, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p95\"\n  - E: `histogram_quantile(0.99, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p99\"\n  - F: `histogram_quantile(0.999, sum by (le) (rate({LATENCY_BUCKET}[1m])))` legend \"p99.9\"\n- Unit: seconds\n\nPanel 15 — Latency Heatmap:\n- Type: heatmap\n- Width: 24, Height: 8\n- PromQL: `sum(increase({LATENCY_BUCKET}[1m])) by (le)`\n- Format: heatmap\n\n### Dashboard JSON Template Structure\n\nThe dashboard.json must follow Grafana's native schema. Key fields:\n\n```json\n{\n  \"uid\": \"{PROJECT_NAME}-grafana\",\n  \"title\": \"{PROJECT_NAME} Observability\",\n  \"tags\": [\"{STACK}\", \"auto-generated\"],\n  \"timezone\": \"browser\",\n  \"refresh\": \"10s\",\n  \"time\": { \"from\": \"now-15m\", \"to\": \"now\" },\n  \"templating\": {\n    \"list\": [{\n      \"name\": \"DS_PROMETHEUS\",\n      \"type\": \"datasource\",\n      \"query\": \"prometheus\",\n      \"current\": { \"text\": \"Prometheus\", \"value\": \"Prometheus\" }\n    }]\n  },\n  \"panels\": [ ... all panels with gridPos ... ],\n  \"schemaVersion\": 39,\n  \"version\": 1\n}\n```\n\nEach panel needs a proper `gridPos` with `x`, `y`, `w`, `h` values. Layout panels top to bottom:\n- Row 1 header at y=0\n- Machine panels starting at y=1\n- Row 2 header after machine panels\n- Application panels after row 2 header\n\nUse the panel widths defined above (Grafana grid is 24 columns wide).\n\n## Step 10 — Generate podman-compose.yaml\n\nWrite to `podman-compose.yaml` at project root:\n\n```yaml\nversion: \"3.8\"\nservices:\n  grafana:\n    image: docker.io\u002Fgrafana\u002Fgrafana:latest\n    ports:\n      - \"3000:3000\"\n    environment:\n      - GF_SECURITY_ADMIN_PASSWORD=admin\n      - GF_AUTH_ANONYMOUS_ENABLED=true\n      - GF_AUTH_ANONYMOUS_ORG_ROLE=Viewer\n    volumes:\n      - .\u002Fgrafana\u002Fprovisioning:\u002Fetc\u002Fgrafana\u002Fprovisioning\n      - .\u002Fgrafana\u002Fdashboards:\u002Fvar\u002Flib\u002Fgrafana\u002Fdashboards\n    depends_on:\n      - prometheus\n  prometheus:\n    image: docker.io\u002Fprom\u002Fprometheus:latest\n    ports:\n      - \"9090:9090\"\n    volumes:\n      - .\u002Fprometheus\u002Fprometheus.yml:\u002Fetc\u002Fprometheus\u002Fprometheus.yml\n    extra_hosts:\n      - \"host.containers.internal:host-gateway\"\n  node-exporter:\n    image: docker.io\u002Fprom\u002Fnode-exporter:latest\n    ports:\n      - \"9100:9100\"\n    pid: \"host\"\n```\n\n## Step 11 — Generate run-grafana.sh\n\nWrite to `run-grafana.sh` at project root:\n\n```bash\n#!\u002Fbin\u002Fbash\npodman-compose up -d\necho \"Waiting for Grafana to start...\"\nwhile true; do\n  STATUS=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fhealth 2>\u002Fdev\u002Fnull)\n  if [ \"$STATUS\" = \"200\" ]; then\n    break\n  fi\n  sleep 1\ndone\necho \"Grafana is ready at http:\u002F\u002Flocalhost:3000\"\necho \"Prometheus is ready at http:\u002F\u002Flocalhost:9090\"\necho \"Your app must be running on port {APP_PORT} with metrics at {METRICS_PATH}\"\n```\n\nReplace `{APP_PORT}` and `{METRICS_PATH}` with detected values.\n\n## Step 12 — Generate stop-grafana.sh\n\nWrite to `stop-grafana.sh` at project root:\n\n```bash\n#!\u002Fbin\u002Fbash\npodman-compose down\necho \"Grafana stack stopped\"\n```\n\n## Step 13 — Generate test-grafana.sh\n\nWrite to `test-grafana.sh` at project root:\n\n```bash\n#!\u002Fbin\u002Fbash\nPASS=0\nFAIL=0\ncheck() {\n  if [ \"$1\" = \"200\" ]; then\n    echo \"PASS: $2\"\n    PASS=$((PASS + 1))\n  else\n    echo \"FAIL: $2 (got $1)\"\n    FAIL=$((FAIL + 1))\n  fi\n}\nGRAFANA=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fhealth 2>\u002Fdev\u002Fnull)\ncheck \"$GRAFANA\" \"Grafana health\"\nPROM=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:9090\u002F-\u002Fhealthy 2>\u002Fdev\u002Fnull)\ncheck \"$PROM\" \"Prometheus health\"\nDASH=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fdashboards\u002Fuid\u002F{DASHBOARD_UID} 2>\u002Fdev\u002Fnull)\ncheck \"$DASH\" \"Dashboard loaded\"\nDS=$(curl -s -o \u002Fdev\u002Fnull -w \"%{http_code}\" http:\u002F\u002Flocalhost:3000\u002Fapi\u002Fdatasources 2>\u002Fdev\u002Fnull)\ncheck \"$DS\" \"Datasources configured\"\necho \"\"\necho \"Results: $PASS passed, $FAIL failed\"\n```\n\nReplace `{DASHBOARD_UID}` with the deterministic UID from the dashboard.\n\n## Step 14 — Make Scripts Executable\n\nUse Bash to run:\n```\nchmod +x run-grafana.sh stop-grafana.sh test-grafana.sh\n```\n\n## Step 15 — Validation\n\n1. Validate dashboard.json is valid JSON using: `python3 -m json.tool grafana\u002Fdashboards\u002Fdashboard.json > \u002Fdev\u002Fnull 2>&1`\n2. Verify all generated files exist\n3. Print any validation errors\n\n## Step 16 — Output Summary\n\nPrint a summary to the user:\n\n```\nGrafana Dashboard Generated\n=============================\nStack:       {DETECTED_STACK}\nApp Port:    {APP_PORT}\nMetrics:     {METRICS_PATH}\nEndpoints:   {ENDPOINT_COUNT} discovered\n\nMachine Metrics Panels:\n  - CPU Usage %\n  - Memory Usage %\n  - Memory Used\n  - Disk Usage %\n  - Disk I\u002FO (read\u002Fwrite)\n  - Disk IOPS\n  - Network In\n  - Network Out\n\nApplication Metrics Panels:\n  - Total Requests\u002Fsec\n  - Total Errors\u002Fsec\n  - Error Rate %\n  - Requests\u002Fsec per Endpoint\n  - Errors\u002Fsec per Endpoint\n  - Latency Percentiles (p50, p70, p90, p95, p99, p99.9)\n  - Latency Heatmap\n\nDiscovered Endpoints:\n  {METHOD} {PATH}\n  {METHOD} {PATH}\n  ...\n\nFiles Generated:\n  grafana\u002Fdashboards\u002Fdashboard.json\n  grafana\u002Fprovisioning\u002Fdatasources\u002Fdatasources.yaml\n  grafana\u002Fprovisioning\u002Fdashboards\u002Fdashboards.yaml\n  prometheus\u002Fprometheus.yml\n  podman-compose.yaml\n  run-grafana.sh\n  stop-grafana.sh\n  test-grafana.sh\n\nTo start:\n  1. Start your application on port {APP_PORT}\n  2. Run: .\u002Frun-grafana.sh\n  3. Open: http:\u002F\u002Flocalhost:3000\n\nTo stop:\n  .\u002Fstop-grafana.sh\n\nTo verify:\n  .\u002Ftest-grafana.sh\n```\n\nIf metrics library warnings were printed in Step 4, remind the user at the end:\n```\nREMINDER: Add the missing metrics dependencies listed above before starting your app.\n```\n",{"name":5,"description":7,"allowed-tools":56},[57,58,59,35,60],"Glob","Grep","Read","Write","main","90d379e95fcc23dd9759654c345424e1752b0f3a","pocs\u002Fagent-skill-grafana-generator",9,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground","https:\u002F\u002Fgithub.com\u002Fdiegopacheco","http:\u002F\u002Fdiego-pacheco.blogspot.com","Brazilian Hands-on Software Architect | 20+ years in Tech | Author | Father. Opinions are my own!","2026-11-15 01:01:48",{"source":9,"skillName":5,"commands":71,"prompt":81,"zipAvailable":82},[72,75,78],{"tool":73,"command":74},"npx","npx skills add diegopacheco\u002Fai-playground --skill grafana-generator",{"tool":76,"command":77},"bunx","bunx skills add diegopacheco\u002Fai-playground --skill grafana-generator",{"tool":79,"command":80},"pnpm","pnpm dlx skills add diegopacheco\u002Fai-playground --skill grafana-generator","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002FSKILL.md",true,[84,90,96,102,106,110],{"path":85,"resourceType":86,"resourceTypeDesc":87,"sizeBytes":88,"sourceHtmlUrl":89},"dashboard-full.png","ASSET","资产文件",160093,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002Fdashboard-full.png",{"path":91,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":94,"sourceHtmlUrl":95},"design-doc.md","REFERENCE","参考文档",14182,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002Fdesign-doc.md",{"path":97,"resourceType":98,"resourceTypeDesc":99,"sizeBytes":100,"sourceHtmlUrl":101},"install.sh","SCRIPT","脚本",440,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002Finstall.sh",{"path":103,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":104,"sourceHtmlUrl":105},"README.md",1781,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002FREADME.md",{"path":107,"resourceType":92,"resourceTypeDesc":93,"sizeBytes":108,"sourceHtmlUrl":109},"sample\u002FREADME.md",2848,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002Fsample\u002FREADME.md",{"path":111,"resourceType":98,"resourceTypeDesc":99,"sizeBytes":112,"sourceHtmlUrl":113},"uninstall.sh",246,"https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skill-grafana-generator\u002Funinstall.sh",[115,128,138,151,167,185],{"skillNo":116,"name":117,"nameZh":17,"description":118,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":51},"01M6WJ537DN520XY8MSW9ZV0RP","word-count","Counts the words, lines and characters of a text or a file.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Ftext-skills\u002Fword-count\u002FSKILL.md",[],[122,123,124,125,126,127],"count","word count","Word","characters","text","file",{"skillNo":129,"name":130,"nameZh":17,"description":131,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":51},"01M6WJ4Y2GT5SECWAKKYHGES4F","slugify","Turns a title or a sentence into a URL slug, lowercase words joined by hyphens with accents removed.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Ftext-skills\u002Fslugify\u002FSKILL.md",[],[130,135,136,137],"title","with","URL",{"skillNo":139,"name":140,"nameZh":17,"description":141,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":142,"categories":143,"keywords":144,"publishedAt":51},"01M6WJ4V9CWHT9NVCD441VK5MH","json-format","Validates a JSON file and pretty prints it with two space indentation, or reports where the JSON is invalid.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Fdev-skills\u002Fjson-format\u002FSKILL.md",[],[145,146,147,127,148,149,150,136],"json","format","json format","reports","invalid","it",{"skillNo":152,"name":153,"nameZh":17,"description":154,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":155,"categories":156,"keywords":157,"publishedAt":51},"01M6WJ4QMRKW8EFP71F4KS2DHE","commit-message","Writes a conventional commit message for the staged git changes.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002Fupstream-skills\u002Fdev-skills\u002Fcommit-message\u002FSKILL.md",[],[158,159,160,161,162,163,164,165,166],"commit","commit message","message","git","conventional commit","for","changes","staged","conventional commit message",{"skillNo":168,"name":169,"nameZh":17,"description":170,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":171,"categories":172,"keywords":173,"publishedAt":51},"01M6WJ4MAM2CJH0GWYXFBB9GQC","skills-gateway","Gateway and router to a catalog of skills that are not registered directly. Use it before any task a specialized skill could handle, such as text, JSON or git chores. It finds the right skill and loads its instructions.","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fskills-gateway-router\u002F.claude\u002Fskills\u002Fskills-gateway\u002FSKILL.md",[],[174,175,150,176,177,161,35,145,126,178,179,180,181,182,183,184],"skills gateway","gateway","task","loads","node","specialized","instructions","catalog","use","router","as",{"skillNo":186,"name":187,"nameZh":17,"description":188,"descriptionZh":17,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":189,"categories":190,"keywords":191,"publishedAt":51},"01M6M2PYJJQKMWGX7XT7ZJK0H3","decision-log","Record, list, show and supersede architecture decisions that persist across sessions in the shared agent infra state store. Use when the user says \"record this decision\", \"log an ADR\", \"what did we decide about\", \"list decisions\", or \"supersede decision\".","https:\u002F\u002Fgithub.com\u002Fdiegopacheco\u002Fai-playground\u002Fblob\u002Fmain\u002Fpocs\u002Fagent-skills-infra-poc\u002Fskills\u002Fdecision-log\u002FSKILL.md",[],[192,193,194,195,196,197,198,199,200,201,182,202,203,204,205,206,207,208,209,210],"decision log","log","decision","persist","architecture","state","adr","decide","decisions","list","show","infra","record","across","shared","store","about","supersede","sessions"]