{
    "title": "Metric Explorer",
    "description": "Deep-dive into any single metric — pick from a dropdown, all panels update. Works with any domain.",
    "tags": ["explorer", "grafana-lens", "generic"],
    "timezone": "browser",
    "editable": true,
    "schemaVersion": 39,
    "time": { "from": "now-6h", "to": "now" },
    "refresh": "30s",
    "templating": {
        "list": [
            {
                "name": "datasource",
                "type": "datasource",
                "query": "prometheus",
                "current": {},
                "hide": 0
            },
            {
                "name": "metric",
                "label": "Metric",
                "type": "query",
                "datasource": { "type": "prometheus", "uid": "$datasource" },
                "query": "label_values(__name__)",
                "refresh": 1,
                "includeAll": false,
                "current": {},
                "hide": 0,
                "sort": 1
            }
        ]
    },
    "panels": [
        {
            "id": 1,
            "title": "Current Value",
            "description": "For histogram _bucket metrics, shows per-bucket counts. Select _sum or _count variants for totals, or see Histogram Quantiles panel below.",
            "type": "stat",
            "gridPos": { "h": 4, "w": 12, "x": 0, "y": 0 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "$metric",
                    "legendFormat": "{{ __name__ }}",
                    "refId": "A"
                }
            ],
            "fieldConfig": {
                "defaults": {
                    "unit": "short"
                }
            }
        },
        {
            "id": 2,
            "title": "Rate of Change",
            "type": "stat",
            "gridPos": { "h": 4, "w": 12, "x": 12, "y": 0 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "rate($metric[5m])",
                    "legendFormat": "rate",
                    "refId": "A"
                }
            ],
            "fieldConfig": {
                "defaults": {
                    "unit": "short"
                }
            }
        },
        {
            "id": 3,
            "title": "Value Over Time",
            "type": "timeseries",
            "gridPos": { "h": 8, "w": 12, "x": 0, "y": 4 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "$metric",
                    "legendFormat": "{{ __name__ }}",
                    "refId": "A"
                }
            ],
            "fieldConfig": {
                "defaults": {
                    "unit": "short",
                    "custom": {
                        "fillOpacity": 10
                    }
                }
            }
        },
        {
            "id": 4,
            "title": "Rate Over Time",
            "type": "timeseries",
            "gridPos": { "h": 8, "w": 12, "x": 12, "y": 4 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "rate($metric[5m])",
                    "legendFormat": "rate",
                    "refId": "A"
                }
            ],
            "fieldConfig": {
                "defaults": {
                    "unit": "short",
                    "custom": {
                        "fillOpacity": 10
                    }
                }
            }
        },
        {
            "id": 5,
            "title": "Breakdown by Labels",
            "type": "timeseries",
            "gridPos": { "h": 8, "w": 12, "x": 0, "y": 16 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "$metric",
                    "legendFormat": "",
                    "refId": "A"
                }
            ],
            "fieldConfig": {
                "defaults": {
                    "unit": "short",
                    "custom": {
                        "fillOpacity": 10
                    }
                }
            }
        },
        {
            "id": 7,
            "title": "Histogram Quantiles",
            "description": "Shows p50, p95, and p99 quantiles. Only meaningful when the selected metric is a histogram (_bucket suffix).",
            "type": "stat",
            "gridPos": { "h": 4, "w": 24, "x": 0, "y": 12 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "histogram_quantile(0.50, sum(rate($metric[5m])) by (le))",
                    "legendFormat": "p50",
                    "refId": "A"
                },
                {
                    "expr": "histogram_quantile(0.95, sum(rate($metric[5m])) by (le))",
                    "legendFormat": "p95",
                    "refId": "B"
                },
                {
                    "expr": "histogram_quantile(0.99, sum(rate($metric[5m])) by (le))",
                    "legendFormat": "p99",
                    "refId": "C"
                }
            ],
            "fieldConfig": {
                "defaults": {
                    "unit": "short",
                    "decimals": 2,
                    "noValue": "N/A (not a histogram)"
                }
            },
            "options": {
                "graphMode": "none",
                "reduceOptions": { "calcs": ["lastNotNull"] }
            }
        },
        {
            "id": 6,
            "title": "All Series",
            "type": "table",
            "gridPos": { "h": 8, "w": 12, "x": 12, "y": 16 },
            "datasource": { "type": "prometheus", "uid": "$datasource" },
            "targets": [
                {
                    "expr": "$metric",
                    "format": "table",
                    "instant": true,
                    "refId": "A"
                }
            ]
        }
    ]
}
