Dataway Metrics Aggregation¶
Features¶
Dataway provides aggregation upload capability, with the external interface being /v1/aggregate.
This capability is primarily used to first receive aggregated metrics data on the Dataway side, then organize them by window and forward them to the center. Currently, two working modes are supported:
standalone: The current Dataway directly receives aggregation packets, writes them to the local aggregation cache, and sends them to Kodo's/v1/write/metricafter the window expires.proxy: The current Dataway does not perform local aggregation, only forwards the/v1/aggregaterequest to backend Dataway nodes.
The basic processing flow is as follows:
sequenceDiagram
autonumber
participant dk as Datakit/Client
participant dw as Dataway
participant cache as Aggregate Cache
participant kodo as Kodo
dk ->> dw: POST /v1/aggregate
alt standalone
dw ->> cache: write aggregate batch
cache ->> dw: expired windows
dw ->> kodo: POST /v1/write/metric
else proxy
dw ->> dw: pick backend endpoint
dw ->> kodo: forward request
end
Working Modes¶
standalone¶
In standalone mode, Dataway decodes the request body into aggregate.Batchs and writes it to the local aggregate.Cache.
In the current implementation:
- The aggregation cache window is 1 minute.
- Dataway checks for expired windows every 1 second.
- Window data is grouped by workspace
token. - Each
tokensends/v1/write/metricseparately.
This mode is suitable for centralizing aggregation capability on the Dataway side, with Dataway responsible for writing the final metrics to the center.
proxy¶
In proxy mode, Dataway does not process the aggregation content itself, but forwards the request to a backend node based on the request header Guance-Pick-Key:
Therefore, in proxy mode:
aggregator_endpointmust be configured.- The client must carry a valid
Guance-Pick-Key. - The current node is only responsible for forwarding and does not hold the aggregation window state.
This mode is suitable for load distribution at the entry layer, fixing the aggregation state to backend nodes.
Warning
In Kubernetes deployments, if the front-end Dataway needs to stably forward /v1/aggregate requests to fixed back-end nodes, then aggregator_endpoint must be filled with stable, unchanging backend addresses. It is more appropriate to deploy the back-end Dataway using StatefulSet here, so that each Pod has a fixed network identity, making it easier for the front-end Dataway to forward to fixed endpoints.
Configuration¶
The aggregation-related configuration items are as follows:
Field description:
aggregator_mode- Optional values:
standalone,proxy - Defaults to
proxyif empty. aggregator_endpoint- List of backend nodes in
proxymode. - May not be configured in
standalonemode.
The corresponding environment variables are:
Warning
If aggregator_mode is empty, Dataway will process it as proxy. However, if aggregator_endpoint is not configured simultaneously at this time, the aggregation capability will not be initialized, and the corresponding /v1/aggregate route will not take effect.
Configuration Examples¶
Single-machine aggregation:
Entry forwarding to backend aggregation nodes:
aggregator_mode: proxy
aggregator_endpoint:
- http://dataway-0.dataway:9528
- http://dataway-1.dataway:9528
In Kubernetes, the above addresses typically correspond to the stable DNS names of StatefulSet Pods.
API Description¶
Aggregation interface:
Description:
- The authentication method is consistent with other Dataway write interfaces, still using standard token validation logic.
- In
standalonemode, the request body needs to be protobuf-encodedaggregate.Batchs. - In
proxymode, the client needs to additionally carry the request headerGuance-Pick-Key.
Return behavior:
- In
standalonemode, success is returned after data is successfully written to the local aggregation cache. - In
proxymode, the current node forwards the request to the target backend, and the response status code is based on the target node's return.
Built-in Metrics¶
Dataway maintains a set of built-in statistical metrics when processing aggregation requests. Metrics directly related to aggregation currently include:
| Metric Name | Type | Tags | Description |
|---|---|---|---|
dataway_http_api_body_size_bytes_total |
Counter | api, token |
Cumulative bytes of /v1/aggregate request body |
dataway_http_aggr_point_total |
Counter | api, token |
Cumulative number of points written in aggregation packets |
Tag description:
api: Interface path, currently/v1/aggregatefor aggregation scenarios.token: The workspace token to which the current data belongs.
These metrics are used to observe aggregation entry traffic, write volume, and request distribution across different workspaces.
Automatic Metric Reporting¶
apis/metrics_special.go periodically converts the aforementioned built-in metrics into metric points and continues reporting them through Dataway itself.
Current behavior:
- Collects current cumulative values every 1 minute.
- Automatically converts to the measurement
dataway_aggregate. - Reports to
/v1/write/metricusing Dataway's default workspace token. - Resets the current round's cumulative count after successful reporting.
Field mapping rules:
Countermetrics:- The metric name is directly used as the field name.
Summarymetrics:- Generates
<metric>_sum - Generates
<metric>_count - Generates
<metric>_quantile_<quantile>
Tag mapping rules:
- Prometheus metric tags are converted as-is to metric point tags.
For example, dataway_http_api_body_size_bytes_total{api="/v1/aggregate",token="tkn_xxx"} is converted to a dataway_aggregate metric point with the field name dataway_http_api_body_size_bytes_total.
Info
The current automatic conversion logic already supports Counter and Summary. Types like Gauge and Histogram are not yet converted to reporting points in the current implementation.
Use Cases¶
- Need to perform metric aggregation near the entry point before uniformly writing to the center.
- Need to separate aggregation traffic from actual write nodes.
- Need to observe aggregation request volume, request body size, and point count.