{"record":{"id":"4604deaf3a0efb1b","repo":"pinpoint-apm/pinpoint","slug":"hostname-is-empty","errorCode":null,"errorMessage":"hostName is empty","messagePattern":"hostName is empty","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/collector/controller/TelegrafMetricController.java","lineNumber":97,"sourceCode":"            @RequestHeader(value = \"hostGroupName\") String hostGroupName,\n            @RequestBody TelegrafMetrics telegrafMetrics, BindingResult bindingResult\n    ) throws BindException {\n        if (bindingResult.hasErrors()) {\n            SimpleErrorMessage simpleErrorMessage = new SimpleErrorMessage(bindingResult);\n            logger.warn(\"metric binding error. header=hostGroupName:{} errorCount:{} {}\", hostGroupName, bindingResult.getErrorCount(), simpleErrorMessage);\n            throw new BindException(bindingResult);\n        }\n\n        if (!isValidGroupName(hostGroupName)) {\n            logger.warn(\"invalid hostGroupName='{}'\", hostGroupName);\n            return ResponseEntity.badRequest().body(\"invalid hostGroupName='\" + hostGroupName + \"'\");\n        }\n\n        String hostName = getHost(telegrafMetrics);\n        if (StringUtils.isEmpty(hostName)) {\n            // hostname null check\n            logger.info(\"hostName is empty. hostGroupName={}\", hostGroupName);\n            return ResponseEntity.badRequest().body(\"hostName is empty\");\n        }\n\n        if (!isValidHostName(hostName)) {\n            logger.warn(\"invalid hostName='{}', hostGroupName='{}'\", hostName, hostGroupName);\n        }\n\n        if (logger.isDebugEnabled()) {\n            logger.debug(\"hostGroupName:{} host:{} size:{}\", hostGroupName, hostName, telegrafMetrics.size());\n        }\n\n        String tenantId = tenantProvider.getTenantId();\n\n        Metrics systemMetric = toMetrics(tenantId, hostGroupName, hostName, telegrafMetrics);\n\n        updateMetadata(systemMetric);\n        systemMetricService.insert(systemMetric);\n\n        return ResponseEntity.ok(null);","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/metric-module/metric/src/main/java/com/navercorp/pinpoint/metric/collector/controller/TelegrafMetricController.java#L79-L115","documentation":"TelegrafMetricController.saveSystemMetric rejects a telegraf metrics batch when no hostname can be extracted from any of the collected TelegrafMetric entries. Each metric carries a hostGroupName and a set of tags; the controller derives hostName from the first metric's tags, and if every entry lacks it the batch is unusable because Pinpoint's system-metric storage is keyed by (hostGroupName, hostName). It returns HTTP 400 with the body 'hostName is empty' rather than throwing.","triggerScenarios":"POSTing telegraf metrics to the system-metric collect endpoint where getHost(telegrafMetrics) returns null/empty — i.e., the batch is empty, or none of the metrics' tag maps contain the hostname tag (typically 'hostname' as sent by Telegraf's output).","commonSituations":"Telegraf agent configured without the default 'host' tag, a custom tag_filter stripping the hostname tag, or a proxy/relay re-serializing the payload and dropping tags; also misconfigured clients posting hand-built JSON without per-metric tags.","solutions":["Ensure the Telegraf agent sets the hostname tag (verify '[agent]  hostname = \"...\"' and omit_hostname = false in telegraf.conf).","Check the pinot-kafka/metric pipeline or any relays for tag-stripping filters and re-add 'hostname'.","If posting manually, include a non-empty hostname tag on every metric entry.","Log the full request payload when this 400 occurs to confirm which tag key the collector expects and match it exactly (case-sensitive)."],"exampleFix":"// before (telegraf.conf)\n[agent]\n  omit_hostname = true\n\n// after\n[agent]\n  hostname = \"app-server-01\"\n  omit_hostname = false","handlingStrategy":"validation","validationCode":"// client-side, before POSTing to the collector\nboolean hasHost = metrics.stream()\n    .allMatch(m -> m.getTags() != null && StringUtils.isNotBlank(m.getTags().get(\"hostname\")));\nif (!hasHost || metrics.isEmpty()) {\n    throw new IllegalArgumentException(\"telegraf batch must include a non-empty hostname tag\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep omit_hostname=false in telegraf.conf and set an explicit hostname.","Assert the hostname tag exists in an integration test that posts a sample batch to the collector.","Watch for proxies/transformers that strip tags from the payload."],"tags":["http","validation","metrics","bad-request"],"backgroundTag":"empty-required-field","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"}