Implements three observability improvements: #82 — publish_grafana_copy(): Uses SQLite online backup API (WAL-safe) to atomically publish a consistent read-only copy beside the target. Adds --publish-copy option to grafana-schema and snapshot CLI commands. #83 — examples/grafana/: Minimal working Grafana setup with docker-compose, provisioning datasource/dashboard YAML, and three dashboard JSON files (mt5cli-overview, mt5cli-trades, mt5cli-market). All queries use grafana_* views; no credentials or private paths included. #84 — mt5cli/telemetry.py: Optional OTel metrics behind mt5cli[otel] extra. Base install is unaffected. Adds _Mt5Metrics singleton (no-op until configure_metrics() is called), wraps update_history() and update_observability() with record_history_update / record_snapshot_update context managers, and emits account/position gauges from snapshots. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
114 lines
3.0 KiB
JSON
114 lines
3.0 KiB
JSON
{
|
|
"__inputs": [
|
|
{
|
|
"name": "DS_MT5CLI_SQLITE",
|
|
"label": "mt5cli-SQLite",
|
|
"description": "",
|
|
"type": "datasource",
|
|
"pluginId": "frser-sqlite-datasource",
|
|
"pluginName": "SQLite"
|
|
}
|
|
],
|
|
"__requires": [
|
|
{
|
|
"type": "datasource",
|
|
"id": "frser-sqlite-datasource",
|
|
"name": "SQLite",
|
|
"version": "1.0.0"
|
|
}
|
|
],
|
|
"annotations": {"list": []},
|
|
"editable": true,
|
|
"fiscalYearStartMonth": 0,
|
|
"graphTooltip": 0,
|
|
"id": null,
|
|
"links": [],
|
|
"panels": [
|
|
{
|
|
"datasource": "${DS_MT5CLI_SQLITE}",
|
|
"fieldConfig": {"defaults": {}, "overrides": []},
|
|
"gridPos": {"h": 8, "w": 12, "x": 0, "y": 0},
|
|
"id": 1,
|
|
"title": "Realized P/L by Symbol",
|
|
"type": "table",
|
|
"targets": [
|
|
{
|
|
"rawSql": "SELECT \"symbol\", \"cumulative_pnl\", \"deal_count\" FROM grafana_realized_pnl ORDER BY cumulative_pnl DESC",
|
|
"format": "table",
|
|
"refId": "A"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"datasource": "${DS_MT5CLI_SQLITE}",
|
|
"fieldConfig": {"defaults": {}, "overrides": []},
|
|
"gridPos": {"h": 8, "w": 12, "x": 12, "y": 0},
|
|
"id": 2,
|
|
"title": "Trade Statistics by Symbol",
|
|
"type": "table",
|
|
"targets": [
|
|
{
|
|
"rawSql": "SELECT \"symbol\", \"total_deals\", \"winning_deals\", \"losing_deals\", \"total_profit\", \"avg_profit\" FROM grafana_trade_stats ORDER BY total_profit DESC",
|
|
"format": "table",
|
|
"refId": "A"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"datasource": "${DS_MT5CLI_SQLITE}",
|
|
"fieldConfig": {"defaults": {}, "overrides": []},
|
|
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 8},
|
|
"id": 3,
|
|
"title": "Open Position Profit Over Time",
|
|
"type": "timeseries",
|
|
"targets": [
|
|
{
|
|
"rawSql": "SELECT \"time\" AS time, \"symbol\", SUM(\"profit\") AS profit FROM grafana_position_snapshots GROUP BY time, symbol ORDER BY time",
|
|
"format": "time_series",
|
|
"refId": "A"
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"datasource": "${DS_MT5CLI_SQLITE}",
|
|
"fieldConfig": {"defaults": {}, "overrides": []},
|
|
"gridPos": {"h": 8, "w": 24, "x": 0, "y": 16},
|
|
"id": 4,
|
|
"title": "Cash Events Over Time",
|
|
"type": "timeseries",
|
|
"targets": [
|
|
{
|
|
"rawSql": "SELECT \"time\" AS time, \"profit\" FROM grafana_cash_events ORDER BY time",
|
|
"format": "time_series",
|
|
"refId": "A"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"refresh": "5m",
|
|
"schemaVersion": 36,
|
|
"tags": ["mt5cli", "trades"],
|
|
"templating": {
|
|
"list": [
|
|
{
|
|
"current": {},
|
|
"hide": 0,
|
|
"includeAll": false,
|
|
"label": "Data Source",
|
|
"multi": false,
|
|
"name": "DS_MT5CLI_SQLITE",
|
|
"options": [],
|
|
"query": "frser-sqlite-datasource",
|
|
"refresh": 1,
|
|
"type": "datasource"
|
|
}
|
|
]
|
|
},
|
|
"time": {"from": "now-30d", "to": "now"},
|
|
"timepicker": {},
|
|
"timezone": "browser",
|
|
"title": "MT5CLI - Trade Analytics",
|
|
"uid": "mt5cli-trades",
|
|
"version": 1
|
|
}
|