From c7f73b90082dc76773fed59ef6ecfc5836055f2d Mon Sep 17 00:00:00 2001 From: Aleksandr Razumov Date: Fri, 29 Sep 2023 13:31:07 +0300 Subject: [PATCH] docs(metrics): add example --- docs/metrics.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/docs/metrics.md b/docs/metrics.md index f8269f4c..7af0c522 100644 --- a/docs/metrics.md +++ b/docs/metrics.md @@ -61,6 +61,49 @@ fetch all points needed for query execution. Probably we can replace hashes by integers, but this complicates implementation of query ingestion where we should perform "insert or do nothing" operation with id lookup. +### Example + +Having metric like that: + +```yaml +name: http.request.duration +attributes: + foo: 1 + bar: baz +resource: + tenant.id: 1 + service.name: api +timestamp: 2021-01-01T00:00:00Z +value: 10 +``` + +We compute hashes from attribute sets: + +| name | value | +|------------|----------------------------------| +| attributes | 3b52e723db6a5e0aaee48e0a984d33f9 | +| resource | 4bfe5ab10b4f64a45383b67c222d962c | + +Attribute set is represented by an ordered list attributes to make hash deterministic. + +#### `resource` + +| key | value | +|----------------------------------|---------------------------------------------| +| 4bfe5ab10b4f64a45383b67c222d962c | `{"tenant.id": "1", "service.name": "api"}` | + +#### `attributes` + +| metric | key | value | +|-----------------------|----------------------------------|----------------------------| +| http.request.duration | 3b52e723db6a5e0aaee48e0a984d33f9 | `{"foo": 1, "bar": "baz"}` | + +#### `points` + +| name | resource_hash | attribute_hash | timestamp | value | +|-----------------------|----------------------------------|----------------------------------|----------------------|-------| +| http.request.duration | 4bfe5ab10b4f64a45383b67c222d962c | 3b52e723db6a5e0aaee48e0a984d33f9 | 2021-01-01T00:00:00Z | 10 | + ## Partitioning and sharding Data should be sharded by time (e.g. per day, week or similar, can be heterogeneous) and tenant id.