microsoft/garnet · error · Exception
LatencyMonitor requires MetricsSamplingFrequency to be set
Error message
LatencyMonitor requires MetricsSamplingFrequency to be set
What it means
Latency tracking (LatencyMonitor) depends on the periodic metrics sampling task, which is driven by MetricsSamplingFrequency in seconds. If you enable latency monitoring but leave the sampling frequency at 0, the sampling task never runs, so the check at GetSettings refuses to start rather than silently producing no latency data.
Source
Thrown at libs/server/Servers/GarnetServerOptions.cs:755
logger?.LogInformation("[Store] Hash index max size is optimized for up to ~{distinctKeys} distinct keys", PrettySize(AdjustedIndexMaxCacheLines * 4L));
}
logger?.LogInformation("[Store] Using log mutable percentage of {MutablePercent}%", MutablePercent);
if (DeviceType == DeviceType.Default)
DeviceType = Devices.GetDefaultDeviceType();
DeviceFactoryCreator ??= new LocalStorageNamedDeviceFactoryCreator(
deviceType: DeviceType,
ioBackend: DeviceIoBackend,
numCompletionThreads: DeviceCompletionThreads,
throttleLimit: DeviceThrottleLimit > 0 ? DeviceThrottleLimit : null,
logger: logger);
if (DeviceType == DeviceType.Native && OperatingSystem.IsLinux())
logger?.LogInformation("Using device type {deviceType} (io-backend={ioBackend}, completion-threads={ct}, throttle-limit={tl})", DeviceType, DeviceIoBackend, DeviceCompletionThreads, DeviceThrottleLimit > 0 ? DeviceThrottleLimit.ToString() : "device-default");
else
logger?.LogInformation("Using device type {deviceType} (throttle-limit={tl})", DeviceType, DeviceThrottleLimit > 0 ? DeviceThrottleLimit.ToString() : "device-default");
if (LatencyMonitor && MetricsSamplingFrequency == 0)
throw new Exception("LatencyMonitor requires MetricsSamplingFrequency to be set");
// Read cache related settings
if (EnableReadCache)
{
if (!EnableStorageTier)
throw new Exception("Read cache requires storage tiering to be enabled");
kvSettings.ReadCacheEnabled = true;
if (ReadCachePageCount != 0)
kvSettings.ReadCachePageCount = ReadCachePageCount;
kvSettings.ReadCachePageSize = 1L << ReadCachePageSizeBits();
kvSettings.ReadCacheMemorySize = ParseSize(ReadCacheMemorySize, out _);
if (kvSettings.ReadCacheMemorySize > 0)
{
var pageCount = kvSettings.ReadCacheMemorySize / kvSettings.ReadCachePageSize;
if (kvSettings.PageCount > pageCount)View on GitHub (pinned to 951b0fc683)
Solutions
- Set a positive --metrics-sampling-freq (seconds), e.g. --metrics-sampling-freq 1, alongside --latency-monitor.
- If you do not actually need latency tracking, drop --latency-monitor.
- Document the pairing in your deployment config so the two flags are always set together.
Example fix
# before (fails) garnet-server --latency-monitor # after garnet-server --latency-monitor --metrics-sampling-freq 1
Defensive patterns
Strategy: validation
Validate before calling
if (options.LatencyMonitor && options.MetricsSamplingFrequency == 0) {
throw new InvalidOperationException("LatencyMonitor requires MetricsSamplingFrequency > 0");
} Prevention
- Always pair --latency-monitor with a positive --metrics-sampling-freq.
- Add a deployment-template check that the two are set together.
When it happens
Trigger: Starting with --latency-monitor but with --metrics-sampling-freq unset or 0. Thrown at GarnetServerOptions.cs:754-755.
Common situations: Enabling latency monitoring in isolation without also turning on the metrics sampling cadence; assuming --latency-monitor self-schedules.
Related errors
- VectorSetReplayTaskCount should be in range [0,{Environment.
- VectorSetQuantizationTaskCount should be in range [0,{Enviro
- MutablePercent must be between 10 and 95
- Store Log Memory size or PageCount must be specified
- Index size {IndexMemorySize} should not be less than index m
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/10247dadd0541c98.
Report an issue: GitHub.