TimelessMetrics.DataGenerator (timeless_metrics v6.0.10)

Copy Markdown View Source

Realistic telemetry data generators for benchmarks and testing.

Generates node_exporter-compatible metric names and values that produce realistic compression patterns:

  • Gauges: oscillate around a base with drift and noise
  • Counters: monotonically increase with variable increments
  • Constants: rarely change (filesystem size, boot time, etc.)

Usage

# Generate a list of metric definitions
metrics = TimelessMetrics.DataGenerator.metrics()

# Generate a value for a specific metric at a given timestamp
val = TimelessMetrics.DataGenerator.value("node_load1", ts_ms, device_id)

# Generate a full scrape payload (all metrics for one device)
points = TimelessMetrics.DataGenerator.scrape(:metrics, device_id, timestamp)

Summary

Functions

Return the number of metrics per device.

Return the list of metric names.

Generate count time series points for a single metric + device.

Generate a Prometheus text exposition body for one device scrape.

Generate a realistic value for a metric at a given timestamp and device.

Generate a list of {metric_name, labels, value} tuples for one device.

Functions

metric_count()

Return the number of metrics per device.

metrics()

Return the list of metric names.

points(metric, dev_id, count, start_ts \\ 1_700_000_000, interval \\ 15)

Generate count time series points for a single metric + device.

Returns [{timestamp, value}, ...] sorted by timestamp. Useful for compression benchmarks.

prometheus_body(dev_id, ts_ms)

Generate a Prometheus text exposition body for one device scrape.

Returns a string with one line per metric, ready to POST to /api/v1/import/prometheus.

value(metric, ts_ms, dev_id)

Generate a realistic value for a metric at a given timestamp and device.

Uses deterministic hashing so the same (metric, ts, device) always produces the same value — reproducible benchmarks.

write_batch_entries(dev_id, ts)

Generate a list of {metric_name, labels, value} tuples for one device.

Ready to pass to TimelessMetrics.write_batch/2.