#!/usr/bin/env python3
import json
import requests

# Read the Docker Metrics dashboard
with open('/home/eric/smart-city-digital-twin-martinique/grafana-dashboard-docker-metrics.json', 'r') as f:
    dashboard = json.load(f)

# Import to Grafana
url = "https://grafana.digitribe.fr/api/dashboards/db"
auth = ('admin', 'Digitribe972')

payload = {
    "dashboard": dashboard,
    "overwrite": True
}

try:
    resp = requests.post(url, json=payload, auth=auth, verify=False)
    print(f"Status: {resp.status_code}")
    print(resp.json())
except Exception as e:
    print(f"Error: {e}")
