Lu_Wang_ENB_DBX
Databricks Employee
Databricks Employee

Recommendation: use a custom code agent, deployed on Databricks Apps/Agent Runtime.

Suggested architecture

  1. Precompute the data

    • Parse Spark event logs asynchronously from the UC Volume.
    • Store normalized run-level and stage-level metrics in Delta tables.
    • Avoid reparsing raw event logs during every user request.
  2. Use a custom agent for orchestration

    • Keep the Python tools for log parsing, metric aggregation, and recommendation logic.
    • The agent should call deterministic tools, compare metrics against thresholds, and use the LLM mainly to explain findings and recommendations.
    • Databricks supports custom Python tools directly in code-first agents.
  3. Use Unity Catalog Functions selectively

    • Convert stable, parameterized, reusable logic—such as get_job_runs(job_id, limit) or get_run_metrics(run_id)—into UC Functions.
    • Do not force complex Spark-log parsing or dependency-heavy code into UC Functions.
    • UC Functions are appropriate for predefined, governed logic exposed as agent tools.
  4. Use Genie only as an optional interface

    • Genie is a good fit for natural-language analysis over the curated Delta tables.
    • It is not the best primary orchestrator for raw log inspection, custom Python execution, and multi-step analysis. Chat mode is focused on structured data and single-query questions.
  5. Use Databricks Apps for delivery

    • Apps provide the user-facing UI, authentication, and hosting layer; the custom agent remains the orchestration layer.
    • For new agents, Databricks recommends the current Agent Runtime/Agent Bricks path rather than legacy agent-server templates.

Pattern:
Databricks App → Custom Agent → Python tools + UC Functions → Delta metrics tables

This provides the flexibility needed for Spark analysis while retaining Unity Catalog governance, MLflow tracing, and a path to evaluation and production deployment.