Create custom index while sending logs from filebeat to elasticsearch

Hi i've setup filebeat(7.17.7) to send logs to elasticsearch(8.5.1)
The logs are getting shipped but to the default index that is filebeat 7.17
Here is my filebeat.yml

output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["43.204.205.20:9200"]

  output.elasticsearch.index: "nexus-%{[agent.version]}-%{+yyyy.MM.dd}"
    setup.template:
     name: 'nexus-%{[agent.version]}-%{+yyyy.MM.dd}'
     pattern: 'nexus-%{[agent.version]}-%{+yyyy.MM.dd}'
     enabled: false
  username: "elastic"
  password: "minutus"
  setup.ilm.enabled: false
  setup.template.overwrite: true

If i add
#index: "nexus-%{[agent.version]}-%{+yyyy.MM.dd}"
filebeat service fails instead of above config giving error attempted to start quickly.