def create_home_dashboard(grafana_api, dashboards): home_data = load_json_data(settings.HOME_DASHBOARD_LOCATION) panels = home_data['panels'] for panel in panels: if panel['title'] in [ 'new_records_created (in last 24h)', 'time_since_last_record_created' ]: panel['savedOverrides'] = generate_overrides(dashboards) # native polystat logic for column/row auto scalling works strange panel['polystat']['columns'] = get_best_column_count( len(dashboards)) if panel['title'] == 'new_records_created (in last 24h)': update_home_panel_element(panel, HomeLastDayTraffic) if panel['title'] == 'time_since_last_record_created': update_home_panel_element(panel, HomeLastModifiedTime) response = grafana_api.dashboard.update_dashboard(dashboard={ 'dashboard': home_data, 'folderID': 0, 'overwrite': True }) print(f"Dashboard for home generated:", response) return response
def create_home_dashboard(grafana_api, dashboards): home_data = load_json_data(settings.HOME_DASHBOARD_LOCATION) panels = home_data["panels"] for panel in panels: if panel["title"] in [ "new_records_created (in last 24h)", "time_since_last_record_created", ]: panel["savedOverrides"] = generate_overrides(dashboards) # native polystat logic for column/row auto scalling works strange panel["polystat"]["columns"] = get_best_column_count(len(dashboards)) if panel["title"] == "new_records_created (in last 24h)": update_home_panel_element(panel, HomeLastDayTraffic) if panel["title"] == "time_since_last_record_created": update_home_panel_element(panel, HomeLastModifiedTime) if panel["title"] == "RECENT ALERTS": update_home_panel_element(panel, HomeAlerts) response = grafana_api.dashboard.update_dashboard( dashboard={"dashboard": home_data, "folderID": 0, "overwrite": True} ) print(f"Dashboard for home generated:", response) return response