Skip to content

Guance Data Sampling Technical Guide: Optimizing Data Volume and Query Efficiency


Processing Logic

The Guance data sampling feature spans the entire data processing lifecycle:

  1. Collection-phase sampling: filters data before it is reported, reducing data ingestion volume and storage costs;

  2. Query-phase sampling: intelligently downsamples large-scale query results, speeding up chart rendering and data analysis.

Core Principles

The two sampling phases are independent yet complementary: collection-phase sampling determines which data is permanently stored and directly affects storage costs; query-phase sampling only affects how data is displayed, while the raw data remains fully intact. Sampling strategies optimize resource consumption while preserving the integrity of critical data.

Sampling Configuration in the Data Collection Phase

Three typical scenarios are described below.

1. Real User Monitoring (RUM) Sampling

  • Configuration entry: Guance console > RUM > Create/Edit Application > SDK Configuration.

  • Sampling logic:

    • Control the data reporting ratio by setting the sampleRate parameter (for example, sampleRate: 90).

    • At SDK initialization, a random number (0–100) is generated. If the random number is less than the sampling rate, the data is reported.

  • Use cases: Web/Android/iOS/mini-program applications that need to reduce storage costs for user behavior data.

2. Application Performance Monitoring (APM) Sampling

  • Supported methods:

    • Set the sampling rate through code instrumentation (for example, OpenTelemetry);

    • Configure trace data sampling rules in the DataKit collector.

  • Sampling strategy:

    • Full collection: error requests and slow requests;

    • Downsampling: normal requests (sampling rate can be set from 1% to 10%).

3. Log Data Sampling

  • Configuration capabilities:

    • Use the drop() function in a Pipeline to discard redundant logs, or the sample() function to sample by ratio;

    • Supports blacklist configuration to filter out low-value logs.

  • Typical scenario: apply a low sampling rate to debug logs and collect error logs in full.

Sampling in the Query Phase

At the query phase, Guance provides a smart sampling mechanism that triggers automatically when the queried data volume reaches a preset threshold, ensuring responsive performance for large-scale data queries.

The key sampling thresholds defined by the system are:

  • Dashboard queries: 200 million data points

  • Explorer queries: 100 million data points

  • Facet queries: 5 million data points

  • Other general queries: 200 million data points

Sampling Strategy Selection Guide

Scenario Sampling Type Recommended Configuration Notes
User behavior analysis RUM collection sampling Set the sampling rate based on business importance Ensure full collection of error operations and critical paths
Application performance troubleshooting APM trace sampling Full collection for error/slow requests; 1%–10% sampling rate for normal requests Use TraceID to ensure trace integrity
Long-term log storage Log Pipeline sampling ≤5% sampling rate for high-frequency logs; full collection for error logs Combine with sensitive data masking rules
Dashboard macro trends Query sampling Enable sampling; time range > 24 hours Disable sampling and narrow the time range when investigating specific issues.
Real-time alerting No sampling Calculate based on raw data Avoid false positives/missed alerts caused by sampling

Key Considerations

  1. Data consistency: sampling may dilute extreme values; important decisions should be validated against full data;

  2. Cost and performance balance: collection sampling reduces storage costs, while query sampling improves response speed;

  3. Dynamic tuning: regularly review the statistical distribution of sampled data and adjust strategies to adapt to business changes.

Summary

The Guance data sampling feature is a multi-level, customizable tool for optimizing cost and performance:

  • Collection-side sampling directly reduces data inflow and is suitable for high-frequency data such as RUM, APM, and logs;

  • Query-side sampling ensures smooth interaction with large-scale data and is suitable for dashboards and historical analysis.

By combining business priorities (for example, full collection for errors and downsampling for normal requests) with query requirements (macro trends enabled, precise troubleshooting disabled), you can achieve an optimal balance between resource efficiency and data credibility.

Feedback

Is this page helpful?