{"record":{"id":"959a0b5de0c5eb48","repo":"pinpoint-apm/pinpoint","slug":"failed-to-register-custommetric-message-not-a","errorCode":null,"errorMessage":"Failed to register CustomMetric({}). message:not allowed metric","messagePattern":"Failed to register CustomMetric\\((.+?)\\)\\. message:not allowed metric","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/monitor/metric/DefaultCustomMetricRegistryService.java","lineNumber":61,"sourceCode":"    private final CustomMetricIdGenerator customMetricIdGenerator;\n    private final CustomMetricRegistryFilter filter;\n\n    public DefaultCustomMetricRegistryService(int limitIdNumber) {\n        this(limitIdNumber, new DefaultCustomMetricRegistryFilter());\n    }\n\n    public DefaultCustomMetricRegistryService(int limitIdNumber, CustomMetricRegistryFilter filter) {\n        this.customMetricIdGenerator = new CustomMetricIdGenerator(limitIdNumber);\n        this.filter = Objects.requireNonNull(filter, \"filter\");\n    }\n\n    @Override\n    public boolean register(IntCounter intCounter) {\n        Objects.requireNonNull(intCounter, \"intCount\");\n\n        boolean filter = this.filter.filter(intCounter);\n        if (filter) {\n            LOGGER.warn(\"Failed to register CustomMetric({}). message:not allowed metric\", intCounter);\n            return false;\n        }\n\n        int id = customMetricIdGenerator.create(intCounter.getName());\n        if (id == CustomMetricIdGenerator.NOT_REGISTERED) {\n            LOGGER.warn(\"Failed to create metricId. metric:{}\", intCounter);\n            return false;\n        }\n\n        IntCounterWrapper customMetricWrapper = customMetricWrapperFactory.create(id, intCounter);\n        return add(customMetricWrapper);\n    }\n\n    @Override\n    public boolean register(LongCounter longCounter) {\n        Objects.requireNonNull(longCounter, \"longCount\");\n\n        boolean filter = this.filter.filter(longCounter);","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/context/monitor/metric/DefaultCustomMetricRegistryService.java#L43-L79","documentation":"DefaultCustomMetricRegistryService.register(IntCounter) first runs the configured metric-name filter; if the filter rejects the counter, it logs \"Failed to register CustomMetric ... not allowed metric\" and returns false. The profiler's allow/deny list for custom metric names blocked registration — the metric will not be sent to the collector.","triggerScenarios":"Registering an IntCounter whose name matches the deny pattern or is absent from the allow pattern configured for custom metrics (profiler.custommetric filter settings); also triggered when the filter's default policy disallows unlisted names.","commonSituations":"Deploying an app with custom metrics whose names were not added to the profiler's custom-metric allow configuration; copying metric names across services where only some are whitelisted; typos between configured patterns and code.","solutions":["Add the metric name pattern to the profiler's custom metric allow configuration (or remove it from the deny list) and restart the agent.","Align the counter name in code with an already-allowed pattern.","Check register()'s boolean return and log rejected metrics in your application.","Review DefaultCustomMetricRegistryService's filter implementation to see the exact matching rules."],"exampleFix":"// before: name not whitelisted\nregistryService.register(new IntCounterCounterAdapter(\"internal.debug.counter\"));\n// after: use an allowed name or extend the allow list in profiler config\nregistryService.register(new IntCounterCounterAdapter(\"allowed.metric.prefix\"));","handlingStrategy":"validation","validationCode":"// Confirm the name matches your configured allow-list before registering\nboolean allowed = yourAllowListPatterns.stream().anyMatch(p -> p.matcher(name).matches());","typeGuard":null,"tryCatchPattern":"if (!registryService.register(counter)) {\n    logger.warn(\"custom metric {} was rejected by profiler filter\", counter.getName());\n}","preventionTips":["Keep metric names and profiler allow-list config in sync (config-as-code, reviewed together).","Check register()'s boolean return and log rejections.","Restart the agent after changing filter configuration."],"tags":["metrics","filter","whitelist","custom-metric","configuration"],"backgroundTag":"operation-not-permitted","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}