Newbie, I am making a python program, or script, to process logs. After processing and inserting it into elastic search, how to set a dynamic variable that can change with the system time. For example, the variable is num0508 today and will become num0509 tomorrow?
高洛峰2017-05-18 10:54:07
import datetime
>>> datetime.datetime.now().strftime("%Y-%m-%d)
'2017-05-08'
漂亮男人2017-05-18 10:54:07
I guess you want to insert logs or data into an index named after date. If so, you can just use a string
import time
from elasticsearch import Elasticsearch
index_name = 'num_%s' % time.strftime('%m%d', time.localtime())
es = Es()
es.index(index_name, ...(自己补充其他参数内容))
If you explain your scenario more clearly, I believe we will provide a method that better meets your needs