Metric Management Interface
Table of Contents
- Introduction
- Project Structure
- Core Components
- Architecture Overview
- Detailed Component Analysis
- Dependency Analysis
- Performance Considerations
- Troubleshooting Guide
- Conclusion
- Appendices
Introduction
This document describes the Metric Management Interface, focusing on the hierarchical metric classification system, filtering mechanisms, and visualization controls. It explains the metric explorer component, category-based navigation, and search functionality. It also documents the metric configuration interface, including visibility settings, calculation formulas, and data source mappings, and details the integration with the bi-analysis service for metric definitions, the field visibility configuration system, and real-time metric updates. Examples are included for creating custom metrics, configuring metric hierarchies, and implementing advanced filtering with date ranges and segmentation. Performance considerations and caching strategies are addressed for large metric catalogs.
Project Structure
The Metric Management Interface spans frontend and backend components:
- Frontend (Next.js app): Provides the metric explorer UI, modal-based configuration forms, and tooltip-driven help.
- Backend (gRPC/HTTP services): Defines metric types and configurations, exposes CRUD APIs, and integrates with analysis services for field metadata, visibility, and query building.
Diagram sources
Section sources
Core Components
- Metric Explorer UI: Renders metric groups, supports search, and previews help images.
- Metric Configuration Modals: Allow creation of derived, order, and formula metrics via the MetricService API.
- Metric Tooltip: Displays help content and images for each metric.
- Field Visibility Config: Controls whether fields appear in dashboards and reports.
- Field Metadata: Describes available fields, tables, and dimensions for metric construction.
- SQL Builder and Validation: Ensures safe and correct metric expressions and filters.
Section sources
- [page.tsx]
- [MetricTooltip.tsx]
- [DerivedMetricModal.tsx]
- [OrderMetricModal.tsx]
- [FormulaMetricModal.tsx]
- [metrics.json]
- [metric.proto]
- [field_visible_config.proto]
- [field_meta.proto]
- [sql_builder.go]
Architecture Overview
The Metric Management Interface follows a layered architecture:
- Presentation Layer: Next.js components render the metric explorer and configuration modals.
- API Layer: gRPC/HTTP endpoints expose MetricService and related analysis services.
- Business Logic Layer: SQL builder, validator, and formula engine enforce correctness and safety.
- Data Layer: Field metadata, visibility, tables, and dimensions define the metric catalog.
Diagram sources
Detailed Component Analysis
Metric Explorer Component
- Category-based navigation: Groups metrics by domain (e.g., Traffic, Financial, Regional).
- Search functionality: Filters metrics by name; highlights popular metrics when no query is present.
- Help preview: Clicking an image opens a modal preview.
Diagram sources
Section sources
Metric Configuration Interface
- Types: Basic, Derived, Order, Formula.
- Derived metrics: Aggregate a source field over time range.
- Order metrics: Apply time basis and query conditions.
- Formula metrics: Define expressions with dependencies on other metrics.
Diagram sources
Section sources
Field Visibility Configuration System
- Purpose: Control which fields are visible in dashboards and reports.
- Integration: Exposed via HTTP/GRPC endpoints and consumed by the UI and analysis services.
- Data model: Defines visibility rules per field and context.
Diagram sources
Section sources
Field Metadata and Data Source Mappings
- Field metadata: Describes available fields, their types, and relationships.
- Tables and Dimensions: Define the logical schema underlying metrics.
- Field Groups: Logical collections of fields for navigation and filtering.
Diagram sources
Section sources
Metric Definition Lifecycle
- Create: POST /v1/metrics with Metric payload.
- Update: PUT /v1/metrics/{metric.id} with FieldMask for partial updates.
- Delete: DELETE /v1/metrics/{id}.
- List: GET /v1/metrics returns grouped metrics.
Diagram sources
Section sources
Advanced Filtering and Date Range Segmentation
- Query conditions: Order metrics support structured query_condition for segmentation.
- SQL Builder: Translates metric definitions into executable SQL with validations.
- Template and Home services: Provide reusable templates and home layouts for metric consumption.
Diagram sources
Section sources
Real-time Metric Updates
- Real-time charting: The UI integrates real-time charts for live dashboards.
- Field visibility: Dynamic visibility rules can alter which metrics are rendered.
- Template and home services: Provide preconfigured layouts that reflect real-time updates.
Section sources
Dependency Analysis
The Metric Management Interface depends on:
- MetricService for CRUD operations on metrics.
- FieldMeta, FieldVisibleConfig, Table, Dimension for data source and visibility.
- SQL Builder/Validator/Formula for safe metric computation.
- Template/Home for layout and reuse.
Diagram sources
Section sources
Performance Considerations
- Large metric catalogs:
- Paginate metric listings and lazy-load help images.
- Cache metric groups and metadata in the browser.
- Caching strategies:
- HTTP caching for ListMetrics responses.
- Local storage for frequently accessed tooltips and images.
- CDN for static images referenced by metrics.
- SQL computation:
- Pre-validate formulas and conditions to avoid runtime errors.
- Use indexed fields and time-range filters to reduce scan sizes.
- Real-time updates:
- Debounce frequent UI updates.
- Use incremental refresh for charts and tables.
[No sources needed since this section provides general guidance]
Troubleshooting Guide
- Metric creation fails:
- Verify FieldMask usage for partial updates.
- Ensure formula dependencies are resolvable and expressions are valid.
- Visibility issues:
- Confirm FieldVisibleConfig rules match the current context.
- Rebuild templates if visibility does not apply.
- Search not working:
- Check metrics.json entries and ensure keys match metric names.
- Validate search query normalization.
Section sources
Conclusion
The Metric Management Interface provides a robust, extensible system for discovering, configuring, and consuming metrics. Its hierarchical classification, powerful filtering, and integration with field metadata and visibility enable precise control over metric presentation and computation. By leveraging SQL validation, caching, and real-time charting, it scales effectively for large catalogs while maintaining a responsive user experience.
[No sources needed since this section summarizes without analyzing specific files]
Appendices
Example Workflows
Creating a custom derived metric:
- Select "Derived" in the metrics page.
- Choose source field, aggregation type, and time range field.
- Submit via POST /v1/metrics.
Creating an order-specific metric:
- Select "Order".
- Set order field, time basis, and query condition.
- Submit via POST /v1/metrics.
Creating a formula metric:
- Select "Formula".
- Enter expression and specify dependency metric IDs.
- Submit via POST /v1/metrics.
Configuring metric hierarchies:
- Group metrics by domain (e.g., Traffic, Financial).
- Use templates to standardize layouts.
Advanced filtering with date ranges and segmentation:
- Use OrderConfig query_condition to segment by date/time and attributes.
- Apply FieldVisibleConfig to restrict visible fields per context.
Section sources