Unable to use apm-server dynamic kafka topic with elastic-agent-standalone

Using following config with elastic agent standalone mode

      kafka-output:
        type: kafka
        hosts:
          - 'kafka:9092'
        client_id: kafka-output
        topic: '%{[data_stream.type]}-%{[data_stream.dataset]}-%{[data_stream.namespace]}'

and Getting error

{
  "log.level": "error",
  "@timestamp": "2024-05-20T12:45:50.189Z",
  "message": "runner returned with an error",
  "component": {
    "binary": "apm-server",
    "dataset": "elastic_agent.apm_server",
    "id": "kafka-output",
    "type": "apm"
  },
  "log": {
    "source": "kafka-output"
  },
  "error": {
    "message": "failed to create libbeat output pipeline: topic '%{[data_stream.type]}-%{[data_stream.dataset]}-%{[data_stream.namespace]}' is invalid, it must match '[a-zA-Z0-9._-]' accessing 'output.kafka'"
  },
  "ecs.version": "1.6.0",
  "log.origin": {
    "file.line": 190,
    "file.name": "beatcmd/reloader.go",
    "function": "github.com/elastic/apm-server/internal/beatcmd.(*Reloader).reload.func1"
  },
  "service.name": "apm-server"
}