Skip to content

Commit 0a90c23

Browse files
samuelclayclaude
andcommitted
Add 11 missing LLM features to Grafana and convert cost charts to stacked timeseries
The FEATURES list in rllm_costs.py was missing daily_briefing, webfeed, and 9 discover/backfill features, so their costs appeared in provider/model totals but not in the "Cost by Feature" chart. Also converts the 3 donut charts to stacked time series and replaces the provider trend with a requests-by-feature chart. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7dd8207 commit 0a90c23

File tree

2 files changed

+139
-63
lines changed

2 files changed

+139
-63
lines changed

apps/statistics/rllm_costs.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,22 @@ def record(cls, provider, model, feature, input_tokens, output_tokens, cost_usd,
130130
FEATURES = [
131131
"archive_assistant",
132132
"ask_ai",
133+
"daily_briefing",
133134
"story_classification",
134135
"transcription",
136+
"webfeed",
135137
"search_story_embedding",
136138
"search_query_embedding",
137139
"search_feed_embedding",
140+
"discover_subreddits_categorize",
141+
"discover_podcasts_categorize",
142+
"discover_newsletters_categorize",
143+
"discover_real_feeds_categorize",
144+
"categorize_subreddits",
145+
"backfill_keyword_gen",
146+
"backfill_llm_suggest",
147+
"backfill_underpopulated_feeds",
148+
"generate_popular_feeds_taxonomy",
138149
]
139150
METRICS = ["tokens", "cost", "requests"]
140151

docker/grafana/dashboards/newsblur_dashboard.json

Lines changed: 128 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -10641,21 +10641,53 @@
1064110641
"type": "prometheus",
1064210642
"uid": "U1-fPO3Mk"
1064310643
},
10644-
"description": "Today's cost breakdown by AI provider (OpenAI, Anthropic, Google, xAI)",
10644+
"description": "Cost breakdown by provider over time",
1064510645
"fieldConfig": {
1064610646
"defaults": {
1064710647
"color": {
1064810648
"mode": "palette-classic"
1064910649
},
1065010650
"custom": {
10651+
"axisCenteredZero": false,
10652+
"axisColorMode": "text",
10653+
"axisLabel": "",
10654+
"axisPlacement": "auto",
10655+
"barAlignment": 0,
10656+
"drawStyle": "line",
10657+
"fillOpacity": 20,
10658+
"gradientMode": "opacity",
1065110659
"hideFrom": {
1065210660
"legend": false,
1065310661
"tooltip": false,
1065410662
"viz": false
10663+
},
10664+
"lineInterpolation": "smooth",
10665+
"lineWidth": 2,
10666+
"pointSize": 5,
10667+
"scaleDistribution": {
10668+
"type": "linear"
10669+
},
10670+
"showPoints": "never",
10671+
"spanNulls": true,
10672+
"stacking": {
10673+
"group": "A",
10674+
"mode": "normal"
10675+
},
10676+
"thresholdsStyle": {
10677+
"mode": "off"
1065510678
}
1065610679
},
1065710680
"decimals": 2,
1065810681
"mappings": [],
10682+
"thresholds": {
10683+
"mode": "absolute",
10684+
"steps": [
10685+
{
10686+
"color": "green",
10687+
"value": null
10688+
}
10689+
]
10690+
},
1065910691
"unit": "currencyUSD"
1066010692
},
1066110693
"overrides": []
@@ -10668,59 +10700,81 @@
1066810700
},
1066910701
"id": 205,
1067010702
"options": {
10671-
"displayLabels": [
10672-
"name",
10673-
"value"
10674-
],
1067510703
"legend": {
10676-
"displayMode": "list",
10677-
"placement": "bottom",
10678-
"showLegend": true
10679-
},
10680-
"pieType": "donut",
10681-
"reduceOptions": {
1068210704
"calcs": [
1068310705
"lastNotNull"
1068410706
],
10685-
"fields": "",
10686-
"values": false
10707+
"displayMode": "table",
10708+
"placement": "bottom",
10709+
"showLegend": true
1068710710
},
1068810711
"tooltip": {
10689-
"mode": "single",
10690-
"sort": "none"
10712+
"mode": "multi",
10713+
"sort": "desc"
1069110714
}
1069210715
},
1069310716
"targets": [
1069410717
{
1069510718
"expr": "llm_costs{metric=\"cost_usd\",provider=~\".+\",period=\"daily\"}",
10696-
"instant": true,
1069710719
"legendFormat": "{{provider}}",
1069810720
"refId": "A"
1069910721
}
1070010722
],
10701-
"title": "Today's Cost by Provider",
10702-
"type": "piechart"
10723+
"title": "Cost by Provider",
10724+
"type": "timeseries"
1070310725
},
1070410726
{
1070510727
"datasource": {
1070610728
"type": "prometheus",
1070710729
"uid": "U1-fPO3Mk"
1070810730
},
10709-
"description": "Today's cost breakdown by feature (Ask AI, Archive Assistant, Search Embeddings, etc.)",
10731+
"description": "Cost breakdown by feature over time",
1071010732
"fieldConfig": {
1071110733
"defaults": {
1071210734
"color": {
1071310735
"mode": "palette-classic"
1071410736
},
1071510737
"custom": {
10738+
"axisCenteredZero": false,
10739+
"axisColorMode": "text",
10740+
"axisLabel": "",
10741+
"axisPlacement": "auto",
10742+
"barAlignment": 0,
10743+
"drawStyle": "line",
10744+
"fillOpacity": 20,
10745+
"gradientMode": "opacity",
1071610746
"hideFrom": {
1071710747
"legend": false,
1071810748
"tooltip": false,
1071910749
"viz": false
10750+
},
10751+
"lineInterpolation": "smooth",
10752+
"lineWidth": 2,
10753+
"pointSize": 5,
10754+
"scaleDistribution": {
10755+
"type": "linear"
10756+
},
10757+
"showPoints": "never",
10758+
"spanNulls": true,
10759+
"stacking": {
10760+
"group": "A",
10761+
"mode": "normal"
10762+
},
10763+
"thresholdsStyle": {
10764+
"mode": "off"
1072010765
}
1072110766
},
1072210767
"decimals": 2,
1072310768
"mappings": [],
10769+
"thresholds": {
10770+
"mode": "absolute",
10771+
"steps": [
10772+
{
10773+
"color": "green",
10774+
"value": null
10775+
}
10776+
]
10777+
},
1072410778
"unit": "currencyUSD"
1072510779
},
1072610780
"overrides": []
@@ -10733,59 +10787,81 @@
1073310787
},
1073410788
"id": 206,
1073510789
"options": {
10736-
"displayLabels": [
10737-
"name",
10738-
"value"
10739-
],
1074010790
"legend": {
10741-
"displayMode": "list",
10742-
"placement": "bottom",
10743-
"showLegend": true
10744-
},
10745-
"pieType": "donut",
10746-
"reduceOptions": {
1074710791
"calcs": [
1074810792
"lastNotNull"
1074910793
],
10750-
"fields": "",
10751-
"values": false
10794+
"displayMode": "table",
10795+
"placement": "bottom",
10796+
"showLegend": true
1075210797
},
1075310798
"tooltip": {
10754-
"mode": "single",
10755-
"sort": "none"
10799+
"mode": "multi",
10800+
"sort": "desc"
1075610801
}
1075710802
},
1075810803
"targets": [
1075910804
{
1076010805
"expr": "llm_costs{metric=\"cost_usd\",feature=~\".+\",period=\"daily\"}",
10761-
"instant": true,
1076210806
"legendFormat": "{{feature}}",
1076310807
"refId": "A"
1076410808
}
1076510809
],
10766-
"title": "Today's Cost by Feature",
10767-
"type": "piechart"
10810+
"title": "Cost by Feature",
10811+
"type": "timeseries"
1076810812
},
1076910813
{
1077010814
"datasource": {
1077110815
"type": "prometheus",
1077210816
"uid": "U1-fPO3Mk"
1077310817
},
10774-
"description": "Today's cost breakdown by specific model (claude-opus, gpt-5.2, gemini-3, etc.)",
10818+
"description": "Cost breakdown by model over time",
1077510819
"fieldConfig": {
1077610820
"defaults": {
1077710821
"color": {
1077810822
"mode": "palette-classic"
1077910823
},
1078010824
"custom": {
10825+
"axisCenteredZero": false,
10826+
"axisColorMode": "text",
10827+
"axisLabel": "",
10828+
"axisPlacement": "auto",
10829+
"barAlignment": 0,
10830+
"drawStyle": "line",
10831+
"fillOpacity": 20,
10832+
"gradientMode": "opacity",
1078110833
"hideFrom": {
1078210834
"legend": false,
1078310835
"tooltip": false,
1078410836
"viz": false
10837+
},
10838+
"lineInterpolation": "smooth",
10839+
"lineWidth": 2,
10840+
"pointSize": 5,
10841+
"scaleDistribution": {
10842+
"type": "linear"
10843+
},
10844+
"showPoints": "never",
10845+
"spanNulls": true,
10846+
"stacking": {
10847+
"group": "A",
10848+
"mode": "normal"
10849+
},
10850+
"thresholdsStyle": {
10851+
"mode": "off"
1078510852
}
1078610853
},
1078710854
"decimals": 2,
1078810855
"mappings": [],
10856+
"thresholds": {
10857+
"mode": "absolute",
10858+
"steps": [
10859+
{
10860+
"color": "green",
10861+
"value": null
10862+
}
10863+
]
10864+
},
1078910865
"unit": "currencyUSD"
1079010866
},
1079110867
"overrides": []
@@ -10798,45 +10874,35 @@
1079810874
},
1079910875
"id": 210,
1080010876
"options": {
10801-
"displayLabels": [
10802-
"name",
10803-
"value"
10804-
],
1080510877
"legend": {
10806-
"displayMode": "list",
10807-
"placement": "bottom",
10808-
"showLegend": true
10809-
},
10810-
"pieType": "donut",
10811-
"reduceOptions": {
1081210878
"calcs": [
1081310879
"lastNotNull"
1081410880
],
10815-
"fields": "",
10816-
"values": false
10881+
"displayMode": "table",
10882+
"placement": "bottom",
10883+
"showLegend": true
1081710884
},
1081810885
"tooltip": {
10819-
"mode": "single",
10820-
"sort": "none"
10886+
"mode": "multi",
10887+
"sort": "desc"
1082110888
}
1082210889
},
1082310890
"targets": [
1082410891
{
1082510892
"expr": "llm_costs{metric=\"cost_usd\",model=~\".+\",period=\"daily\"}",
10826-
"instant": true,
1082710893
"legendFormat": "{{model}}",
1082810894
"refId": "A"
1082910895
}
1083010896
],
10831-
"title": "Today's Cost by Model",
10832-
"type": "piechart"
10897+
"title": "Cost by Model",
10898+
"type": "timeseries"
1083310899
},
1083410900
{
1083510901
"datasource": {
1083610902
"type": "prometheus",
1083710903
"uid": "U1-fPO3Mk"
1083810904
},
10839-
"description": "Historical cost trend by provider over time",
10905+
"description": "Request count breakdown by feature over time",
1084010906
"fieldConfig": {
1084110907
"defaults": {
1084210908
"color": {
@@ -10866,13 +10932,13 @@
1086610932
"spanNulls": true,
1086710933
"stacking": {
1086810934
"group": "A",
10869-
"mode": "none"
10935+
"mode": "normal"
1087010936
},
1087110937
"thresholdsStyle": {
1087210938
"mode": "off"
1087310939
}
1087410940
},
10875-
"decimals": 2,
10941+
"decimals": 0,
1087610942
"mappings": [],
1087710943
"thresholds": {
1087810944
"mode": "absolute",
@@ -10882,8 +10948,7 @@
1088210948
"value": null
1088310949
}
1088410950
]
10885-
},
10886-
"unit": "currencyUSD"
10951+
}
1088710952
},
1088810953
"overrides": []
1088910954
},
@@ -10897,7 +10962,7 @@
1089710962
"options": {
1089810963
"legend": {
1089910964
"calcs": [
10900-
"sum"
10965+
"lastNotNull"
1090110966
],
1090210967
"displayMode": "table",
1090310968
"placement": "bottom",
@@ -10910,12 +10975,12 @@
1091010975
},
1091110976
"targets": [
1091210977
{
10913-
"expr": "llm_costs{metric=\"cost_usd\",provider=~\".+\",period=\"daily\"}",
10914-
"legendFormat": "{{provider}}",
10978+
"expr": "llm_costs{metric=\"requests\",feature=~\".+\",period=\"daily\"}",
10979+
"legendFormat": "{{feature}}",
1091510980
"refId": "A"
1091610981
}
1091710982
],
10918-
"title": "Cost Trend by Provider",
10983+
"title": "Requests by Feature",
1091910984
"type": "timeseries"
1092010985
},
1092110986
{

0 commit comments

Comments
 (0)