Size in Records
The metric provides the number of messages present in a desired topic on each Kafka broker at any given time.
Use cases
How many messages are all applications producing to my topic?
It could be beneficial to understand from a business perspective how much is happening within the organization, for example:
-
how many payments are processed on a daily basis
-
how many users are logging in on a daily basis
-
how many fraud cases are reported per month
To do that, just use basic usage with time window of your choice.
Request example for the last day
{ "metric": "io.axual.stream/size_records", "stepSize": "P1D", "timeWindow": "P2D", "filter": { "type": "AND", "filters": [ { "type": "FIELD", "field": "environment", "operation": "EQUALS", "value": "dev" }, { "type": "FIELD", "field": "stream", "operation": "EQUALS", "value": "payment-events-stream" } ] } }
Response example for the last day
{ "type": "UNGROUPED", "dataPoints": [ { "timestamp": "2022-11-14T00:00:00", "value": 200, "labels": {}, "unit": "Records" }, { "timestamp": "2022-11-15T00:00:00", "value": 600, "labels": {}, "unit": "Records" } ] }
The difference between data points will give you the amount of messages produced. It’s possible to make 2 requests and get difference between any 2 points in time
How many messages are there on a topic?
As an owner of a new application consuming messages from a topic, it is good to understand how much data you can expect to be consumed as soon as you start the app from the first time.
To do that, just use sum aggregator with the smallest time window and time step, it will show you number of messages.
Request example
{ "metric": "io.axual.stream/size_records", "stepSize": "PT1M", "timeWindow": "now/-PT1M", "aggregator": "sum", "filter": { "type": "AND", "filters": [ { "type": "FIELD", "field": "environment", "operation": "EQUALS", "value": "dev" }, { "type": "FIELD", "field": "stream", "operation": "EQUALS", "value": "payment-events-stream" } ] } }
Response example
{ "type": "UNGROUPED", "dataPoints": [ { "timestamp": "2022-10-18T15:33:00", "value": 11104, "labels": {}, "unit": "Records" } ] }
Basic usage
Please refer to the example topic size in records metric
provided in the API docs
This request is asking for the size in messages of the topic payment-events-stream
on environment dev
between 2022-10-18T12:20:00Z
and 2022-10-18T13:00:00Z
with the step-size of 10 minutes.
Basic Request
{ "metric": "io.axual.stream/size_records", "stepSize": "PT10M", "timeWindow": "2022-10-18T12:20:00Z/2022-10-18T13:00:00Z", "filter": { "type": "AND", "filters": [ { "type": "FIELD", "field": "environment", "operation": "EQUALS", "value": "dev" }, { "type": "FIELD", "field": "stream", "operation": "EQUALS", "value": "payment-events-stream" } ] } }
The below part of sample response, represents the size of a topic on each kafka broker (pod) in messages.
Basic Response
{ "type": "UNGROUPED", "dataPoints": [ { "timestamp": "2022-10-18T12:30:00", "value": 0, "labels": { "pod": "jupiter-kafka-1" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:40:00", "value": 739, "labels": { "pod": "jupiter-kafka-1" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:50:00", "value": 2712, "labels": { "pod": "jupiter-kafka-1" }, "unit": "Records" }, { "timestamp": "2022-10-18T13:00:00", "value": 3842, "labels": { "pod": "jupiter-kafka-1" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:30:00", "value": 0, "labels": { "pod": "jupiter-kafka-0" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:40:00", "value": 10, "labels": { "pod": "jupiter-kafka-0" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:50:00", "value": 1000, "labels": { "pod": "jupiter-kafka-0" }, "unit": "Records" }, { "timestamp": "2022-10-18T13:00:00", "value": 2060, "labels": { "pod": "jupiter-kafka-0" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:30:00", "value": 0, "labels": { "pod": "jupiter-kafka-2" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:40:00", "value": 722, "labels": { "pod": "jupiter-kafka-2" }, "unit": "Records" }, { "timestamp": "2022-10-18T12:50:00", "value": 2942, "labels": { "pod": "jupiter-kafka-2" }, "unit": "Records" }, { "timestamp": "2022-10-18T13:00:00", "value": 4542, "labels": { "pod": "jupiter-kafka-2" }, "unit": "Records" } ] }
This metric could be used to know how many messages stored in the topic, how they distributed among brokers and how many messages are there.