{
	"annotations": { "list": [] },
	"description": "Ollama LLM Monitoring - Generation metrics, token usage, model performance",
	"editable": true,
	"fiscalYearStartMonth": 0,
	"graphTooltip": 1,
	"panels": [
		{
			"collapsed": false,
			"gridPos": { "h": 1, "w": 24, "x": 0, "y": 0 },
			"id": 100,
			"panels": [],
			"title": "Overview",
			"type": "row"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "thresholds" },
					"mappings": [
						{
							"options": {
								"0": { "color": "red", "text": "DOWN" },
								"1": { "color": "green", "text": "UP" }
							},
							"type": "value"
						}
					],
					"thresholds": {
						"mode": "absolute",
						"steps": [
							{ "color": "red", "value": null },
							{ "color": "green", "value": 1 }
						]
					}
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 0, "y": 1 },
			"id": 1,
			"options": {
				"colorMode": "background",
				"graphMode": "none",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [{ "expr": "up{job=\"ollama\"}", "refId": "A" }],
			"title": "Proxy Status",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "short"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 3, "y": 1 },
			"id": 2,
			"options": {
				"colorMode": "value",
				"graphMode": "area",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [{ "expr": "sum(ollama_requests_total{status=\"success\"})", "refId": "A" }],
			"title": "Total Requests",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "short"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 6, "y": 1 },
			"id": 3,
			"options": {
				"colorMode": "value",
				"graphMode": "area",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [{ "expr": "sum(ollama_tokens_generated_total)", "refId": "A" }],
			"title": "Total Tokens Generated",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "short"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 9, "y": 1 },
			"id": 4,
			"options": {
				"colorMode": "value",
				"graphMode": "area",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [{ "expr": "sum(ollama_prompt_tokens_total)", "refId": "A" }],
			"title": "Total Prompt Tokens",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "thresholds" },
					"mappings": [],
					"thresholds": {
						"mode": "absolute",
						"steps": [
							{ "color": "green", "value": null },
							{ "color": "yellow", "value": 1 },
							{ "color": "red", "value": 3 }
						]
					},
					"unit": "short"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 12, "y": 1 },
			"id": 5,
			"options": {
				"colorMode": "background",
				"graphMode": "area",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [{ "expr": "sum(ollama_active_requests)", "refId": "A" }],
			"title": "Active Requests",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "thresholds" },
					"mappings": [],
					"thresholds": {
						"mode": "absolute",
						"steps": [
							{ "color": "green", "value": null },
							{ "color": "red", "value": 1 }
						]
					},
					"unit": "short"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 15, "y": 1 },
			"id": 6,
			"options": {
				"colorMode": "background",
				"graphMode": "area",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [{ "expr": "sum(ollama_requests_total{status=\"error\"})", "refId": "A" }],
			"title": "Total Errors",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "s"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 18, "y": 1 },
			"id": 7,
			"options": {
				"colorMode": "value",
				"graphMode": "none",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [
				{
					"expr": "histogram_quantile(0.50, sum(rate(ollama_generation_duration_seconds_bucket[5m])) by (le))",
					"refId": "A"
				}
			],
			"title": "Median Generation Time",
			"type": "stat"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "s"
				}
			},
			"gridPos": { "h": 4, "w": 3, "x": 21, "y": 1 },
			"id": 8,
			"options": {
				"colorMode": "value",
				"graphMode": "none",
				"justifyMode": "auto",
				"orientation": "auto",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"textMode": "auto"
			},
			"targets": [
				{
					"expr": "histogram_quantile(0.50, sum(rate(ollama_time_to_first_token_seconds_bucket[5m])) by (le))",
					"refId": "A"
				}
			],
			"title": "Median TTFT",
			"type": "stat"
		},
		{
			"collapsed": false,
			"gridPos": { "h": 1, "w": 24, "x": 0, "y": 5 },
			"id": 101,
			"panels": [],
			"title": "Performance",
			"type": "row"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": {
						"axisBorderShow": false,
						"axisCenteredZero": false,
						"axisColorMode": "text",
						"axisLabel": "",
						"axisPlacement": "auto",
						"barAlignment": 0,
						"drawStyle": "line",
						"fillOpacity": 20,
						"gradientMode": "none",
						"hideFrom": { "legend": false, "tooltip": false, "viz": false },
						"insertNulls": false,
						"lineInterpolation": "smooth",
						"lineWidth": 2,
						"pointSize": 5,
						"scaleDistribution": { "type": "linear" },
						"showPoints": "auto",
						"spanNulls": false,
						"stacking": { "group": "A", "mode": "none" },
						"thresholdsStyle": { "mode": "off" }
					},
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "s"
				}
			},
			"gridPos": { "h": 8, "w": 12, "x": 0, "y": 6 },
			"id": 10,
			"options": {
				"legend": {
					"calcs": ["mean", "max"],
					"displayMode": "table",
					"placement": "bottom",
					"showLegend": true
				},
				"tooltip": { "mode": "multi", "sort": "desc" }
			},
			"targets": [
				{
					"expr": "histogram_quantile(0.50, sum(rate(ollama_generation_duration_seconds_bucket[5m])) by (le, model))",
					"legendFormat": "{{model}} p50",
					"refId": "A"
				},
				{
					"expr": "histogram_quantile(0.95, sum(rate(ollama_generation_duration_seconds_bucket[5m])) by (le, model))",
					"legendFormat": "{{model}} p95",
					"refId": "B"
				}
			],
			"title": "Generation Duration by Model (p50 / p95)",
			"type": "timeseries"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": {
						"axisBorderShow": false,
						"axisCenteredZero": false,
						"axisColorMode": "text",
						"axisLabel": "",
						"axisPlacement": "auto",
						"barAlignment": 0,
						"drawStyle": "line",
						"fillOpacity": 20,
						"gradientMode": "none",
						"hideFrom": { "legend": false, "tooltip": false, "viz": false },
						"insertNulls": false,
						"lineInterpolation": "smooth",
						"lineWidth": 2,
						"pointSize": 5,
						"scaleDistribution": { "type": "linear" },
						"showPoints": "auto",
						"spanNulls": false,
						"stacking": { "group": "A", "mode": "none" },
						"thresholdsStyle": { "mode": "off" }
					},
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "s"
				}
			},
			"gridPos": { "h": 8, "w": 12, "x": 12, "y": 6 },
			"id": 11,
			"options": {
				"legend": {
					"calcs": ["mean", "max"],
					"displayMode": "table",
					"placement": "bottom",
					"showLegend": true
				},
				"tooltip": { "mode": "multi", "sort": "desc" }
			},
			"targets": [
				{
					"expr": "histogram_quantile(0.50, sum(rate(ollama_time_to_first_token_seconds_bucket[5m])) by (le, model))",
					"legendFormat": "{{model}} p50",
					"refId": "A"
				},
				{
					"expr": "histogram_quantile(0.95, sum(rate(ollama_time_to_first_token_seconds_bucket[5m])) by (le, model))",
					"legendFormat": "{{model}} p95",
					"refId": "B"
				}
			],
			"title": "Time to First Token by Model (p50 / p95)",
			"type": "timeseries"
		},
		{
			"collapsed": false,
			"gridPos": { "h": 1, "w": 24, "x": 0, "y": 14 },
			"id": 102,
			"panels": [],
			"title": "Token Usage",
			"type": "row"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": {
						"axisBorderShow": false,
						"axisCenteredZero": false,
						"axisColorMode": "text",
						"axisLabel": "",
						"axisPlacement": "auto",
						"barAlignment": 0,
						"drawStyle": "line",
						"fillOpacity": 30,
						"gradientMode": "none",
						"hideFrom": { "legend": false, "tooltip": false, "viz": false },
						"insertNulls": false,
						"lineInterpolation": "smooth",
						"lineWidth": 2,
						"pointSize": 5,
						"scaleDistribution": { "type": "linear" },
						"showPoints": "auto",
						"spanNulls": false,
						"stacking": { "group": "A", "mode": "normal" },
						"thresholdsStyle": { "mode": "off" }
					},
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "short"
				}
			},
			"gridPos": { "h": 8, "w": 12, "x": 0, "y": 15 },
			"id": 12,
			"options": {
				"legend": {
					"calcs": ["sum"],
					"displayMode": "table",
					"placement": "bottom",
					"showLegend": true
				},
				"tooltip": { "mode": "multi", "sort": "desc" }
			},
			"targets": [
				{
					"expr": "sum(rate(ollama_tokens_generated_total[5m])) by (model)",
					"legendFormat": "{{model}}",
					"refId": "A"
				}
			],
			"title": "Tokens Generated per Second by Model",
			"type": "timeseries"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": {
						"axisBorderShow": false,
						"axisCenteredZero": false,
						"axisColorMode": "text",
						"axisLabel": "",
						"axisPlacement": "auto",
						"barAlignment": 0,
						"drawStyle": "line",
						"fillOpacity": 30,
						"gradientMode": "none",
						"hideFrom": { "legend": false, "tooltip": false, "viz": false },
						"insertNulls": false,
						"lineInterpolation": "smooth",
						"lineWidth": 2,
						"pointSize": 5,
						"scaleDistribution": { "type": "linear" },
						"showPoints": "auto",
						"spanNulls": false,
						"stacking": { "group": "A", "mode": "normal" },
						"thresholdsStyle": { "mode": "off" }
					},
					"mappings": [],
					"thresholds": { "mode": "absolute", "steps": [{ "color": "green", "value": null }] },
					"unit": "reqps"
				}
			},
			"gridPos": { "h": 8, "w": 12, "x": 12, "y": 15 },
			"id": 13,
			"options": {
				"legend": {
					"calcs": ["mean", "sum"],
					"displayMode": "table",
					"placement": "bottom",
					"showLegend": true
				},
				"tooltip": { "mode": "multi", "sort": "desc" }
			},
			"targets": [
				{
					"expr": "sum(rate(ollama_requests_total{status=\"success\"}[5m])) by (model)",
					"legendFormat": "{{model}}",
					"refId": "A"
				}
			],
			"title": "Requests per Second by Model",
			"type": "timeseries"
		},
		{
			"collapsed": false,
			"gridPos": { "h": 1, "w": 24, "x": 0, "y": 23 },
			"id": 103,
			"panels": [],
			"title": "Model Distribution",
			"type": "row"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } },
					"mappings": []
				}
			},
			"gridPos": { "h": 8, "w": 8, "x": 0, "y": 24 },
			"id": 14,
			"options": {
				"legend": { "displayMode": "list", "placement": "right", "showLegend": true },
				"pieType": "pie",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"tooltip": { "mode": "single", "sort": "none" }
			},
			"targets": [
				{
					"expr": "sum(ollama_requests_total{status=\"success\"}) by (model)",
					"legendFormat": "{{model}}",
					"refId": "A"
				}
			],
			"title": "Requests by Model",
			"type": "piechart"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } },
					"mappings": []
				}
			},
			"gridPos": { "h": 8, "w": 8, "x": 8, "y": 24 },
			"id": 15,
			"options": {
				"legend": { "displayMode": "list", "placement": "right", "showLegend": true },
				"pieType": "pie",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"tooltip": { "mode": "single", "sort": "none" }
			},
			"targets": [
				{
					"expr": "sum(ollama_tokens_generated_total) by (model)",
					"legendFormat": "{{model}}",
					"refId": "A"
				}
			],
			"title": "Tokens by Model",
			"type": "piechart"
		},
		{
			"datasource": { "type": "prometheus", "uid": "${datasource}" },
			"fieldConfig": {
				"defaults": {
					"color": { "mode": "palette-classic" },
					"custom": { "hideFrom": { "legend": false, "tooltip": false, "viz": false } },
					"mappings": []
				}
			},
			"gridPos": { "h": 8, "w": 8, "x": 16, "y": 24 },
			"id": 16,
			"options": {
				"legend": { "displayMode": "list", "placement": "right", "showLegend": true },
				"pieType": "pie",
				"reduceOptions": { "calcs": ["lastNotNull"], "fields": "", "values": false },
				"tooltip": { "mode": "single", "sort": "none" }
			},
			"targets": [
				{
					"expr": "sum(ollama_requests_total{status=\"success\"}) by (endpoint)",
					"legendFormat": "{{endpoint}}",
					"refId": "A"
				}
			],
			"title": "Requests by Endpoint",
			"type": "piechart"
		}
	],
	"refresh": "30s",
	"schemaVersion": 39,
	"tags": ["manacore", "ollama", "llm", "ai"],
	"templating": {
		"list": [
			{
				"current": { "selected": false, "text": "Prometheus", "value": "Prometheus" },
				"hide": 0,
				"includeAll": false,
				"multi": false,
				"name": "datasource",
				"options": [],
				"query": "prometheus",
				"refresh": 1,
				"regex": "",
				"skipUrlSync": false,
				"type": "datasource"
			}
		]
	},
	"time": { "from": "now-1h", "to": "now" },
	"timepicker": {},
	"timezone": "browser",
	"title": "Ollama LLM Service",
	"uid": "ollama-dashboard",
	"version": 1,
	"weekStart": "monday"
}
