Files
shuiyisong 5fe9bdc814 feat(prometheus): store Remote Write v1 and v2 exemplars (#9922)
* feat(prometheus): persist Remote Write exemplars

Prometheus Remote Write v1 and v2 now persist valid exemplars in the source schema's metrics_exemplars table. A shared row contract keeps inherited series labels separate from exemplar labels, creates or validates an ordinary sparse append table, and preserves compatible pre-created timestamp precision.

Malformed observations are dropped and counted without discarding valid samples or sibling exemplars. Permissions and admission precede writes, and v2 written-count headers use confirmed storage progress. Includes decoder, HTTP orchestration and physical-table routing coverage. The JSON2 row-schema helper becomes fallible; its three existing trace callers propagate that error in this layer.

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* feat(exemplar): persist source metric identities

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* fix(prometheus): bound exemplar write memory

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* fix(prometheus): correct batching with exemplars

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* fix(exemplar): accept mixed-case sparse encoding

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* perf(exemplar): reduce write preparation overhead

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* perf(prom): reuse exemplar source targets

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* fix: clippy

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

* fix(prometheus): defer exemplar series expansion

Signed-off-by: shuiyisong <xixing.sys@gmail.com>

---------

Signed-off-by: shuiyisong <xixing.sys@gmail.com>
2026-11-03 11:43:33 +00:00

16 lines
697 B
SQL

CREATE TABLE exemplar_source_ids (
__table_id INT UNSIGNED NOT NULL,
__tsid BIGINT UNSIGNED NOT NULL,
greptime_metric STRING,
greptime_timestamp TIMESTAMP(9) TIME INDEX,
greptime_value DOUBLE,
PRIMARY KEY (__table_id, __tsid, greptime_metric)
) WITH ('append_mode'='true', 'primary_key_encoding'='sparse');
INSERT INTO exemplar_source_ids VALUES
(42, 18446744073709551615, 'cpu', 20, 1.0),
(42, 18446744073709551615, 'cpu', 20, 1.0),
(43, 18446744073709551615, 'memory', 10, 2.0);
ADMIN FLUSH_TABLE('exemplar_source_ids');
ALTER TABLE exemplar_source_ids ADD COLUMN job STRING PRIMARY KEY;
INSERT INTO exemplar_source_ids VALUES (42, 7, 'cpu', 30, 3.0, 'api');