mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-27 08:54:32 +00:00
fix(ingest/grafana): add exception handling (#14921)
This commit is contained in:
parent
cecb91b615
commit
1d0e3778a5
@ -8,12 +8,14 @@ References:
|
|||||||
- Dashboard JSON structure: https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/view-dashboard-json-model/
|
- Dashboard JSON structure: https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/view-dashboard-json-model/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
from pydantic import BaseModel, ConfigDict, Field
|
from pydantic import BaseModel, ConfigDict, Field
|
||||||
|
|
||||||
from datahub.emitter.mcp_builder import ContainerKey
|
from datahub.emitter.mcp_builder import ContainerKey
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
# Grafana-specific type definitions for better type safety
|
# Grafana-specific type definitions for better type safety
|
||||||
GrafanaQueryTarget = Dict[
|
GrafanaQueryTarget = Dict[
|
||||||
str, Any
|
str, Any
|
||||||
@ -89,7 +91,13 @@ class Dashboard(_GrafanaBaseModel):
|
|||||||
def parse_obj(cls, data: Dict[str, Any]) -> "Dashboard":
|
def parse_obj(cls, data: Dict[str, Any]) -> "Dashboard":
|
||||||
"""Custom parsing to handle nested panel extraction."""
|
"""Custom parsing to handle nested panel extraction."""
|
||||||
dashboard_data = data.get("dashboard", {})
|
dashboard_data = data.get("dashboard", {})
|
||||||
panels = cls.extract_panels(dashboard_data.get("panels", []))
|
_panel_data = dashboard_data.get("panels", [])
|
||||||
|
try:
|
||||||
|
panels = cls.extract_panels(_panel_data)
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(
|
||||||
|
f"Error extracting panels from dashboard for dashboard panels {_panel_data} : {e}"
|
||||||
|
)
|
||||||
|
|
||||||
# Extract meta.folderId from nested structure
|
# Extract meta.folderId from nested structure
|
||||||
meta = dashboard_data.get("meta", {})
|
meta = dashboard_data.get("meta", {})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user