

TimescaleDB) as a datasource in Grafana.
Steps
- Navigate to your Grafana Instance.
- Login with your credentials.
- Click on the Connection on the left sidebar to open the Data Sources.
- Click the Add data source button.
- In the search box, type “PostgreSQL” as
TimescaleDBis an extension of PostgreSQL 1.In the settings form, fill in the details to connect to your TimescaleDB/PostgreSQL database:- Name: Enter the name for the datasource as
Doku. - Host: Provide the host address and port of your PostgreSQL server (e.g.,
127.0.0.1). - Database: Enter the name of the database. Default database used by Doku is
postgres. - TLS/SSL Setiing: Enter the securtity to use for connection. Default used by Doku is
require. - User: The username for the database. Default user used by Doku is
admin. - Password: The password for the database. Default password used by Doku is
Doku.
- Name: Enter the name for the datasource as
- Optionally customize the Max open connections, Max idle connections, and Connection Max Lifetime.
- Click the Save & Test button at the bottom of the page.
Grafana Resources
Dashboard
Dashboard
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": {
"type": "grafana",
"uid": "-- Grafana --"
},
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"editable": true,
"fiscalYearStartMonth": 0,
"graphTooltip": 0,
"id": 8,
"links": [
{
"icon": "info",
"tags": [],
"targetBlank": true,
"title": "Doku Documentation",
"tooltip": "",
"type": "link",
"url": "https://grafana.com/docs/grafana/latest/"
},
{
"icon": "info",
"tags": [],
"targetBlank": true,
"title": "Doku Community",
"tooltip": "",
"type": "link",
"url": "https://dokulabs.slack.com/"
},
{
"icon": "info",
"tags": [],
"targetBlank": true,
"title": "Dokulabs GitHub",
"tooltip": "",
"type": "link",
"url": "https://github.com/dokulabs/"
}
],
"liveNow": false,
"panels": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"gridPos": {
"h": 4,
"w": 11,
"x": 0,
"y": 0
},
"id": 23,
"options": {
"code": {
"language": "plaintext",
"showLineNumbers": false,
"showMiniMap": false
},
"content": "---\n---\n---\n---\n---\n---",
"mode": "markdown"
},
"pluginVersion": "10.2.3",
"transparent": true,
"type": "text"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"gridPos": {
"h": 4,
"w": 2,
"x": 11,
"y": 0
},
"id": 2,
"options": {
"code": {
"language": "plaintext",
"showLineNumbers": false,
"showMiniMap": false
},
"content": "",
"mode": "markdown"
},
"pluginVersion": "10.2.3",
"transparent": true,
"type": "text"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"gridPos": {
"h": 4,
"w": 11,
"x": 13,
"y": 0
},
"id": 22,
"options": {
"code": {
"language": "plaintext",
"showLineNumbers": false,
"showMiniMap": false
},
"content": "---\n---\n---\n---\n---\n---",
"mode": "markdown"
},
"pluginVersion": "10.2.3",
"transparent": true,
"type": "text"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the total number of requests sent to Large Language Models (LLM) Platforms in the selected time interval.",
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "yellow",
"mode": "continuous-BlPu"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 6,
"x": 0,
"y": 4
},
"id": 3,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT count(*) FROM DOKU_DATA\nWHERE $__timeFilter(time)",
"refId": "A",
"sql": {
"columns": [
{
"name": "COUNT",
"parameters": [
{
"name": "environment",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Total Requests",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the average time taken to process each request by the Large Language Models (LLM), offering a snapshot of system performance and efficiency.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 5
}
]
},
"unit": "s"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 4,
"x": 6,
"y": 4
},
"id": 4,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT AVG(requestduration) FROM DOKU_DATA\nWHERE $__timeFilter(time)",
"refId": "A",
"sql": {
"columns": [
{
"name": "AVG",
"parameters": [
{
"name": "requestduration",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Avg Request Duration",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the average count of Total tokens used per LLM request",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 1000
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 4,
"x": 10,
"y": 4
},
"id": 5,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT AVG(totaltokens) FROM DOKU_DATA\nWHERE $__timeFilter(time)",
"refId": "A",
"sql": {
"columns": [
{
"name": "AVG",
"parameters": [
{
"name": "totaltokens",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Avg Tokens per Request",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the average cost incurred per request to the LLM, helping monitor and optimize budget allocation for LLM usage.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 5
}
]
},
"unit": "currencyUSD"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 4,
"x": 14,
"y": 4
},
"id": 6,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT AVG(usagecost) FROM DOKU_DATA \nWHERE $__timeFilter(time)",
"refId": "A",
"sql": {
"columns": [
{
"name": "AVG",
"parameters": [
{
"name": "usagecost",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Avg Cost / Request",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the total cost on LLM requests over the selected period.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-BlPu"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "currencyUSD"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 6,
"x": 18,
"y": 4
},
"id": 10,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT SUM(usagecost) FROM DOKU_DATA\nWHERE $__timeFilter(time)",
"refId": "A",
"sql": {
"columns": [
{
"name": "SUM",
"parameters": [
{
"name": "usagecost",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Total Cost",
"transparent": true,
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the count of API requests made to LLMs over the selected time.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic-by-name"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "series",
"axisGridShow": true,
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 100,
"gradientMode": "opacity",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineStyle": {
"dash": [
10,
10
],
"fill": "dash"
},
"lineWidth": 2,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "always",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"fieldMinMax": false,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 5,
"w": 24,
"x": 0,
"y": 7
},
"id": 17,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT\n DATE_TRUNC('day', \"time\") AS \"time\",\n COUNT(endpoint) AS total_requests\nFROM \n DOKU_DATA\nWHERE\n $__timeFilter(\"time\")\nGROUP BY \n DATE_TRUNC('day', \"time\")\nORDER BY \n \"time\";",
"refId": "A",
"sql": {
"columns": [
{
"alias": "\"Prompt Tokens\"",
"parameters": [
{
"name": "prompttokens",
"type": "functionParameter"
}
],
"type": "function"
},
{
"alias": "\"time\"",
"parameters": [
{
"name": "\"time\"",
"type": "functionParameter"
}
],
"type": "function"
},
{
"alias": "\"Completion Tokens\"",
"parameters": [
{
"name": "completiontokens",
"type": "functionParameter"
}
],
"type": "function"
},
{
"alias": "\"Total Tokens\"",
"parameters": [
{
"name": "totaltokens",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Total Requests / Day",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel illustrates the distribution of LLM requests across different usage categories: Chat Generations, Embeddings, Image Generations, Audio Generations, and Fine Tuning. It visualizes the relative volume of requests, helping to identify which types of operations are most frequently performed and providing insights into usage patterns by category.\n\n",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": []
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 0,
"y": 12
},
"id": 12,
"options": {
"displayLabels": [
"name",
"percent"
],
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": false,
"values": []
},
"pieType": "pie",
"reduceOptions": {
"calcs": [],
"fields": "/^requests$/",
"values": true
},
"tooltip": {
"mode": "single",
"sort": "asc"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT \n category,\n CAST(COUNT(*) AS INTEGER) AS Requests,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage\n FROM \n (\n SELECT \n CASE\n WHEN endpoint LIKE 'openai.chat%' THEN 'Chat'\n WHEN endpoint LIKE 'openai.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'anthropic.completions%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.summarize%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.generate%' THEN 'Chat'\n WHEN endpoint LIKE 'cohere.chat%' THEN 'Chat'\n WHEN endpoint LIKE '%embed%' THEN 'Embeddings'\n WHEN endpoint LIKE 'openai.images%' THEN 'Image'\n WHEN endpoint LIKE 'openai.audio%' THEN 'Audio'\n WHEN endpoint LIKE 'openai.fine_tuning%' THEN 'Fine Tuning'\n END AS category,\n endpoint\n FROM DOKU_DATA\n WHERE $__timeFilter(time)\n ) AS subquery\n GROUP BY category",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Usage by Category",
"transparent": true,
"type": "piechart"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "Displays the cost breakdown by provider (OpenAI, Cohere, Anthropic) for LLM requests, offering insights into financial deployment across different services.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": [],
"unit": "currencyUSD"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 6,
"y": 12
},
"id": 16,
"options": {
"displayLabels": [
"name",
"value"
],
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": false,
"values": []
},
"pieType": "pie",
"reduceOptions": {
"calcs": [],
"fields": "/.*/",
"values": true
},
"tooltip": {
"mode": "single",
"sort": "asc"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT\n CASE\n WHEN endpoint LIKE 'openai.%' THEN 'OpenAI'\n WHEN endpoint LIKE 'cohere.%' THEN 'Cohere'\n WHEN endpoint LIKE 'anthropic.%' THEN 'Anthropic'\n END AS provider,\n SUM(usageCost) AS total_cost\nFROM\n DOKU_DATA\nWHERE $__timeFilter(time)\nGROUP BY\n provider\nORDER BY\n total_cost DESC;",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Usage cost by Provider",
"transparent": true,
"type": "piechart"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel presents a pie chart detailing the distribution of expenses for LLM requests by various applications. It shows how budget allocations are consumed by different applications, enabling a deeper understanding of cost drivers and facilitating cost optimization efforts.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": [],
"unit": "currencyUSD"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 12,
"y": 12
},
"id": 18,
"options": {
"displayLabels": [
"name",
"value"
],
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"uniqueValues"
],
"fields": "",
"values": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": " SELECT\n applicationName,\n sum(usageCost) AS \"usageCost\"\n FROM\n DOKU_DATA\n WHERE $__timeFilter(time)\n GROUP BY\n applicationName\n ORDER BY\n \"usageCost\" DESC",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Usage cost by Application",
"transparent": true,
"type": "piechart"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "Visualizes the allocation of LLM request expenses across different environments, such as development, staging, and production. This breakdown helps in tracking and managing costs with respect to operational environments.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
}
},
"mappings": [],
"unit": "currencyUSD"
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 6,
"x": 18,
"y": 12
},
"id": 19,
"options": {
"displayLabels": [
"name",
"value"
],
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": false
},
"pieType": "pie",
"reduceOptions": {
"calcs": [
"uniqueValues"
],
"fields": "",
"values": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": " SELECT\n environment,\n sum(usageCost) AS \"usageCost\"\n FROM\n DOKU_DATA\n WHERE $__timeFilter(time)\n GROUP BY\n environment\n ORDER BY\n \"usageCost\" DESC",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
}
}
],
"title": "Usage cost by Environment",
"transparent": true,
"type": "piechart"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the average count of Prompt tokens used per LLM request",
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-YlBl"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 5
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 6,
"x": 0,
"y": 21
},
"id": 9,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT AVG(prompttokens) FROM DOKU_DATA WHERE \n $__timeFilter(\"time\")",
"refId": "A",
"sql": {
"columns": [
{
"name": "AVG",
"parameters": [
{
"name": "prompttokens",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Avg Prompt Tokens / Request",
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "Provides a time-series analysis of token consumption for LLM requests, highlighting trends in usage intensity and complexity over time.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "series",
"axisGridShow": true,
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 10,
"gradientMode": "hue",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": 86400000,
"lineInterpolation": "linear",
"lineStyle": {
"fill": "solid"
},
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "never",
"spanNulls": true,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"fieldMinMax": false,
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 18,
"x": 6,
"y": 21
},
"id": 11,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT prompttokens AS \"Prompt Tokens\", \"time\" AS \"time\", completiontokens AS \"Completion Tokens\", totaltokens AS \"Total Tokens\" FROM DOKU_DATA",
"refId": "A",
"sql": {
"columns": [
{
"alias": "\"Prompt Tokens\"",
"parameters": [
{
"name": "prompttokens",
"type": "functionParameter"
}
],
"type": "function"
},
{
"alias": "\"time\"",
"parameters": [
{
"name": "\"time\"",
"type": "functionParameter"
}
],
"type": "function"
},
{
"alias": "\"Completion Tokens\"",
"parameters": [
{
"name": "completiontokens",
"type": "functionParameter"
}
],
"type": "function"
},
{
"alias": "\"Total Tokens\"",
"parameters": [
{
"name": "totaltokens",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Token usage",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "This panel shows the average count of Completion tokens used per LLM request",
"fieldConfig": {
"defaults": {
"color": {
"mode": "continuous-YlBl"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 5
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 3,
"w": 6,
"x": 0,
"y": 24
},
"id": 7,
"options": {
"colorMode": "background",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": [
"lastNotNull"
],
"fields": "",
"values": false
},
"textMode": "auto",
"wideLayout": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT AVG(completiontokens) FROM DOKU_DATA WHERE \n $__timeFilter(\"time\")",
"refId": "A",
"sql": {
"columns": [
{
"name": "AVG",
"parameters": [
{
"name": "completiontokens",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Avg Completion Tokens / Request",
"type": "stat"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "Displays the frequency of model usage over time, identifying the most utilised models and showcasing usage trends across different periods",
"fieldConfig": {
"defaults": {
"color": {
"fixedColor": "purple",
"mode": "continuous-YlBl"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "none"
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 12,
"x": 0,
"y": 27
},
"id": 13,
"options": {
"displayMode": "lcd",
"maxVizHeight": 167,
"minVizHeight": 10,
"minVizWidth": 75,
"namePlacement": "top",
"orientation": "horizontal",
"reduceOptions": {
"calcs": [
"sum"
],
"fields": "/^total_count$/",
"values": true
},
"showUnfilled": true,
"sizing": "manual",
"valueMode": "text"
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT \n model,\n total_count,\n percentage_usage\nFROM \n (\n SELECT \n model,\n COUNT(*) AS total_count,\n ROUND(100.0 * COUNT(*) / SUM(COUNT(*)) OVER(), 2) AS percentage_usage\n FROM \n DOKU_DATA\n WHERE $__timeFilter(time)\n GROUP BY \n model\n ORDER BY \n percentage_usage DESC\n ) sub\nLIMIT 5;",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [
{
"name": "model",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Top models by usage",
"type": "bargauge"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "Breaks down token usage across different LLM models, offering insights into which models are driving the highest token consumption.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisBorderShow": false,
"axisCenteredZero": false,
"axisColorMode": "text",
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"insertNulls": false,
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 6,
"w": 12,
"x": 12,
"y": 27
},
"id": 14,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom",
"showLegend": true
},
"tooltip": {
"mode": "single",
"sort": "none"
}
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "time_series",
"rawQuery": true,
"rawSql": "SELECT \n DATE_TRUNC('day', \"time\") AS \"time\",\n model,\n COUNT(*) AS \"Model:\"\nFROM \n DOKU_DATA\nWHERE \n $__timeFilter(\"time\")\nGROUP BY \n 1, model\nORDER BY \n \"time\" ASC, model;",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [
{
"name": "model",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "Model usage by day",
"type": "timeseries"
},
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"description": "Table showing prompts and responses along with their associated costs and token usage.",
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic-by-name"
},
"custom": {
"align": "center",
"cellOptions": {
"mode": "gradient",
"type": "color-background"
},
"filterable": true,
"inspect": true
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green"
},
{
"color": "red",
"value": 80
}
]
},
"unit": "currencyUSD"
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 24,
"x": 0,
"y": 33
},
"id": 15,
"options": {
"cellHeight": "sm",
"footer": {
"countRows": false,
"fields": "",
"reducer": [
"sum"
],
"show": false
},
"showHeader": true
},
"pluginVersion": "10.2.3",
"targets": [
{
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "${datasource}"
},
"editorMode": "code",
"format": "table",
"rawQuery": true,
"rawSql": "SELECT \"time\", applicationName, model, prompt, response, usageCost FROM DOKU_DATA WHERE $__timeFilter(time)",
"refId": "A",
"sql": {
"columns": [
{
"parameters": [
{
"name": "endpoint",
"type": "functionParameter"
}
],
"type": "function"
},
{
"parameters": [
{
"name": "prompt",
"type": "functionParameter"
}
],
"type": "function"
},
{
"parameters": [
{
"name": "response",
"type": "functionParameter"
}
],
"type": "function"
},
{
"parameters": [
{
"name": "totaltokens",
"type": "functionParameter"
}
],
"type": "function"
}
],
"groupBy": [
{
"property": {
"type": "string"
},
"type": "groupBy"
}
],
"limit": 50
},
"table": "doku"
}
],
"title": "User Activity",
"transparent": true,
"type": "table"
}
],
"refresh": "",
"schemaVersion": 39,
"tags": [
"Doku",
"OpenAI",
"Cohere",
"Anthropic"
],
"templating": {
"list": [
{
"current": {
"selected": true,
"text": "grafana-postgresql-datasource",
"value": "dbd38750-cf8a-4f35-a031-af943c441f1d"
},
"hide": 0,
"includeAll": false,
"label": "Datasource",
"multi": false,
"name": "datasource",
"options": [],
"query": "grafana-postgresql-datasource",
"queryValue": "",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"type": "datasource"
}
]
},
"time": {
"from": "now-7d",
"to": "now"
},
"timepicker": {},
"timezone": "",
"title": "Doku - LLM Monitoring",
"uid": "doku-llm-monitoring",
"version": 1,
"weekStart": ""
}

