{"record":{"id":"b53ac287889905e7","repo":"apache/skywalking","slug":"metric-ttl-should-be-at-least-2-days-current-valu","errorCode":null,"errorMessage":"Metric TTL should be at least 2 days, current value is {}","messagePattern":"Metric TTL should be at least 2 days, current value is (.+?)","errorType":"exception","errorClass":"ModuleStartException","httpStatus":null,"severity":"critical","filePath":"oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java","lineNumber":391,"sourceCode":"        this.registerServiceImplementation(OALEngineLoaderService.class, oalEngineLoaderService);\n\n        annotationScan.registerListener(new StreamAnnotationListener(getManager()));\n\n        if (moduleConfig.isGRPCSslEnabled()) {\n            this.remoteClientManager = new RemoteClientManager(getManager(), moduleConfig.getRemoteTimeout(),\n                                                               moduleConfig.getGRPCSslTrustedCAPath()\n            );\n        } else {\n            this.remoteClientManager = new RemoteClientManager(getManager(), moduleConfig.getRemoteTimeout());\n        }\n        this.registerServiceImplementation(RemoteClientManager.class, remoteClientManager);\n\n        // Management\n        this.registerServiceImplementation(\n            UITemplateManagementService.class, new UITemplateManagementService(getManager()));\n\n        if (moduleConfig.getMetricsDataTTL() < 2) {\n            throw new ModuleStartException(\n                \"Metric TTL should be at least 2 days, current value is \" + moduleConfig.getMetricsDataTTL());\n        }\n        setBootingParameter(\"TTL.metrics\", moduleConfig.getMetricsDataTTL());\n        if (moduleConfig.getRecordDataTTL() < 2) {\n            throw new ModuleStartException(\n                \"Record TTL should be at least 2 days, current value is \" + moduleConfig.getRecordDataTTL());\n        }\n        setBootingParameter(\"TTL.record\", moduleConfig.getRecordDataTTL());\n\n        final MetricsStreamProcessor metricsStreamProcessor = MetricsStreamProcessor.getInstance();\n        metricsStreamProcessor.setL1FlushPeriod(moduleConfig.getL1FlushPeriod());\n        metricsStreamProcessor.setStorageSessionTimeout(moduleConfig.getStorageSessionTimeout());\n        RecordStreamProcessor.getInstance().setRecordDataTTL(moduleConfig.getRecordDataTTL());\n        TopNStreamProcessor.getInstance().setTopNWorkerReportCycle(moduleConfig.getTopNReportPeriod());\n        apdexThresholdConfig = new ApdexThresholdConfig(this);\n        ApdexMetrics.setDICT(apdexThresholdConfig);\n        loggingConfigWatcher = new LoggingConfigWatcher(this);\n","sourceCodeStart":373,"sourceCodeEnd":409,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/CoreModuleProvider.java#L373-L409","documentation":"ModuleStartException thrown by CoreModuleProvider.start() when core.metrics-data-ttl in application.yml is below 2 days. Metrics data in storage (BanyanDB/ES/...) is rolled up and down-sampled over multi-day windows, so a 0- or 1-day TTL would destroy data before roll-up completes; startup aborts as a guard. The check is a simple int comparison on moduleConfig.getMetricsDataTTL().","triggerScenarios":"Setting core.metrics-data-ttl: 0 or 1 (or a placeholder resolving to those) in application.yml. Also triggered by removing the key if a profile/default leaves it below 2 — the provider throws before MetricsStreamProcessor is tuned.","commonSituations":"Developers shrinking TTLs on local/ephemeral environments to save disk; unit-of-moment confusion (TTL is in DAYS, some assume minutes); overwriting the shipped application.yml with a minimal config that drops the TTL block, leaving a low default.","solutions":["Set core.metrics-data-ttl to at least 2 (days): metrics-data-ttl: 7 is the shipped default; use larger values for roll-up retention","If disk pressure motivated the change, address it via storage retention policies or reduced metric sets instead of TTL < 2","Validate any env-var substitution produces a number >= 2","Restart OAP"],"exampleFix":"# before\ncore:\n  metrics-data-ttl: 1\n\n# after\ncore:\n  metrics-data-ttl: 7","handlingStrategy":"validation","validationCode":"int ttl = Integer.parseInt(System.getenv().getOrDefault(\"SW_CORE_METRICS_DATA_TTL\", \"7\"));\nif (ttl < 2) {\n    throw new IllegalStateException(\"core.metrics-data-ttl must be >= 2 days, got \" + ttl);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a config-lint rule: metrics-data-ttl >= 2 and record-data-ttl >= 2 in every environment's application.yml","Remember the unit is DAYS; never set these keys when thinking in hours","In ephemeral/dev environments, disable unwanted metrics at the source instead of shrinking TTL below the floor"],"tags":["configuration","ttl","storage","startup","oap-server"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}