Dynamic Index in ElasticSearch

The input JSON is as following:

{
  "action": "UPLOAD",
  "user": "123",
  "timestamp": "2016 Jun 14 12:00:12",
  "data": {
    "file_id": "2345",
    "file_name": "xyz.pdf"
  },
  "header": {
    "proj_id": "P123",
    "logtype": "httplogs"
  },
  "comments": "Check comments"
}

Here, I tried to generate index in following ways:

  1. index => "%{logtype}"
  2. index => "%{header.logtype}"

But in both the cases, Logstash does not replace the actual value of logtype from JSON.