Creates a new Remote Write client.
Configuration for the client
Stores (sends) time series data to the remote write endpoint.
Array of time series to send
Response from the remote write endpoint
Stores metrics using precompiled templates for maximum performance.
Use precompileLabelTemplates to compile templates once, then reuse them across multiple calls to this method. This is the most efficient approach when generating metrics repeatedly with the same template structure.
Minimum random value for samples
Maximum random value for samples (exclusive)
Timestamp in milliseconds
Start of series ID range (inclusive)
End of series ID range (exclusive)
Precompiled label templates from precompileLabelTemplates
Response from the remote write endpoint
const template = {
__name__: 'k6_metric_${series_id/10}',
series_id: '${series_id}'
};
const compiled = remote.precompileLabelTemplates(template);
// Reuse compiled template in each iteration
export default function() {
client.storeFromPrecompiledTemplates(100, 200, Date.now(), 0, 50, compiled);
}
Generates and stores time series data from a template.
This method is more efficient than store for generating large numbers of metrics because the samples are generated inside the Go extension, avoiding the overhead of passing objects from JavaScript to Go.
The template string values can include special variables that are substituted based on the series ID. This allows you to control label cardinality and distribution patterns.
Minimum random value for samples
Maximum random value for samples (exclusive)
Timestamp in milliseconds
Start of series ID range (inclusive)
End of series ID range (exclusive)
Template for generating metric labels
Response from the remote write endpoint
const template = {
__name__: 'k6_generated_metric_${series_id/4}',
series_id: '${series_id}',
cardinality_1e1: '${series_id/10}',
cardinality_2: '${series_id%2}',
};
client.storeFromTemplates(
100, // min random value
200, // max random value
Date.now(), // timestamp in ms
0, // series id start
100, // series id end (exclusive) - generates IDs 0-99
template
);
MetricTemplate for template variable syntax
Generates and stores time series data with automatic cardinality labels.
This method automatically generates time series with cardinality labels (cardinality_1e1, cardinality_1e2, etc.) based on the total number of series. It's useful for testing scenarios where you need to distribute series across multiple batches or simulate realistic label distributions.
Each series will have:
k6_generated_metric_{series_id}series_id label with the unique series IDTotal number of series to generate across all batches
Total number of batches
Number of series per batch (must divide evenly: totalSeries = batches × batchSize)
Current batch number (1-indexed)
Response from the remote write endpoint
Client for sending metrics to Prometheus Remote Write endpoints.
The Client provides multiple methods for sending metrics, optimized for different use cases:
Example: Basic usage
Example: With authentication