How StoreView Enables Seamless Cross‑Project Log Queries in Alibaba Cloud SLS
This article explains how Alibaba Cloud's SLS StoreView feature creates virtual logstores that combine data from multiple projects and regions, allowing cross‑project queries, data isolation, enrichment, and unified analysis without costly data replication.
Overview
Alibaba Cloud Log Service (SLS) provides large‑scale, low‑cost, real‑time log, metric and trace storage with multi‑region support, but it cannot query across projects natively. StoreView introduces virtual logstores that combine data from multiple projects, enabling cross‑project queries and analysis.
Data Preparation
Two projects in different regions are used as test data, deliberately introducing schema differences such as the type of UnitsSold and differing pricing fields (USD vs RMB). The following image shows the test datasets:
Query
Define a StoreView that aggregates the logstores into a virtual logstore all_market_data. After creation, queries return combined results that match expectations, as demonstrated by the query results and histogram images.
Data Isolation
StoreView can restrict access to specific rows, for example only logs where Country = 'China', allowing fine‑grained data authorization without copying data. The isolation view is defined and its query results show only China‑related data.
Data Enrichment
Using SPL extend statements, additional fields such as logstoreName can be added to the result set, demonstrating enrichment capabilities.
Analysis
StoreView supports standard SQL analysis. The service automatically provides two meta columns, __project__ and __logstore__, which identify the source of each row and can be used in WHERE clauses for further filtering.
Column Type Compatibility
If the same column has different types across logstores (e.g., UnitsSold as long vs text), the service coerces the column to text. Converting the type in the query resolves errors.
Column Auto‑Completion
When logstores have different column sets, StoreView includes the union of all columns, filling missing values with null. This behavior is illustrated by the query results showing nulls for absent columns.
Column Extension and Processing
Complex calculations, such as unifying revenue columns with different currencies, can be simplified by defining a StoreView that creates a unified TotalRevenue column via SPL. Subsequent analysis can then use a simple SQL statement.
Conclusion
StoreView provides convenient cross‑project query and analysis, data isolation, and enrichment, reducing the need for costly data copying tasks while simplifying multi‑region log analytics. Ongoing improvements aim to enhance usability, stability, and performance.
Alibaba Cloud Observability
Driving continuous progress in observability technology!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
