{
"_index": "mysql_backup_stat",
"_type": "_doc",
"_id": "addb-m15-2023-03-31T02:31:22.920268+08:00",
"_version": 1,
"_score": null,
"_source": {
"timestamp": "2023-03-31T02:31:22.920268+08:00",
"hostname": "m15",
"dbname": "addb",
"result": "SUCCESS"
},
"fields": {
"timestamp": [
"2023-03-30T18:31:22.920Z"
]
},
"sort": [
1680201082920
]
}
The timezone in ES is UTC, how to set it to local time?
Here is my code:
with Elasticsearch(hosts=hosts, timeout=300) as es:
if not es.indices.exists(index=index_name):
es.indices.create(index=index_name)
doc = {
"timestamp": timestamp,
"hostname": hostname,
"dbname": dbname,
"result": result
}
doc_id = "{}-{}-{}".format(dbname, hostname, timestamp)
es.index(index=index_name, body=doc, id=doc_id)
and the sdk doc:
https://elasticsearch-py.readthedocs.io/en/v7.14.0/api.html#elasticsearch.Elasticsearch.index