How to set timezone on index using rest-api


(Morten Bjoernsvik) #1

I try to set the timezone on the @timestamp index as we do in logstash:

20181116091132.106 - root:139 - ERROR - put index 'proxylogs-mb-pc-2018-10-16' with data:'{
    "mappings": {
        "proxylog": {
            "properties": {
                "@timestamp": {
                    "type": "date",
                    "format": "yyyy-MM-dd HH:mm:ss.SSS",
                    "timezone": "Europe/Oslo"
                },
                "host": {
                    "type": "text"
                },
                "loglevel": {
                    "type": "text"
                },
                "message": {
                    "type": "text"
                },
                "operationId": {
                    "type": "text"
                },
                "tags": {
                    "type": "text"
                },
                "id": {
                    "type": "long"
                }
            }
        }
    },
    "settings": {
        "number_of_shards": "3",
        "number_of_replicas": "1"
    }
    }' returned: {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"Mapping definition for [@timestamp] has unsupported parameters:  [timezone : Europe/Oslo]"}],"type":"mapper_parsing_exception","reason":"Failed to parse mapping [proxylog]: Mapping definition for [@timestamp] has unsupported parameters:  [timezone : Europe/Oslo]","caused_by":{"type":"mapper_parsing_exception","reason":"Mapping definition for [@timestamp] has unsupported parameters:  [timezone : Europe/Oslo]"}},"status":400}

(Morten Bjoernsvik) #2

Since data was in 'Europe/Oslo' Timezone, I just added '+0100' to the end so it converts i properly to UTC

"format": "yyyy-MM-dd HH:mm:ss.SSSZ"

I do not have time to do proper timestamp conversion since I need to insert more than 4000/sec