The following is the contents of my Logstash pipeline.conf configuration file:
output {
    elasticsearch {
        hosts => [ "xxx.xxx.xxx.xxx:9200" ]
        index => "%{[@metahostname]}"           # How to write dynamic name
    }
}
How to configure the index section. After the log is sent from Logstash to elasticsearch, I can create an index on her own hostname in elasticsearch.