fetch_ml/scripts/dev/setup-monitoring.py
Jeremie Fraeys cb142213fa
chore(build): update build system, Dockerfiles, and dependencies
Build and deployment improvements:

Makefile:
- Native library build targets with ASan support
- Cross-platform compilation helpers
- Performance benchmark targets
- Security scan integration

Docker:
- secure-prod.Dockerfile: Hardened production image (non-root, minimal surface)
- simple.Dockerfile: Lightweight development image

Scripts:
- build/: Go and native library build scripts, cross-platform builds
- ci/: checks.sh, test.sh, verify-paths.sh for validation
- benchmarks/: Local performance testing and regression tracking
- dev/: Monitoring setup

Dependencies: Update to latest stable with security patches

Commands:
- api-server/main.go: Server initialization updates
- data_manager/data_sync.go: Data sync with visibility
- errors/main.go: Error handling improvements
- tui/: TUI improvements for group management
2026-03-08 13:03:48 -04:00

62 lines
1.5 KiB
Python

#!/usr/bin/env python3
import os
# Create monitoring directory structure
repo_root = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
monitoring_dir = os.path.join(repo_root, "monitoring")
grafana_dir = os.path.join(monitoring_dir, "grafana")
datasources_dir = os.path.join(grafana_dir, "provisioning", "datasources")
providers_dir = os.path.join(grafana_dir, "provisioning", "dashboards")
os.makedirs(datasources_dir, exist_ok=True)
os.makedirs(providers_dir, exist_ok=True)
# Essential datasource configurations
datasources = {
"prometheus.yml": """apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
jsonData:
timeInterval: "5s"
""",
"loki.yml": """apiVersion: 1
datasources:
- name: Loki
type: loki
access: proxy
url: http://loki:3100
editable: true
jsonData:
maxLines: 1000
""",
"dashboards.yml": """apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
""",
}
# Write configuration files
for filename, content in datasources.items():
if filename == "dashboards.yml":
path = os.path.join(providers_dir, filename)
else:
path = os.path.join(datasources_dir, filename)
with open(path, "w") as f:
f.write(content)
print("Monitoring setup completed!")