My code looks like this. its do get data, monitoring the total amount of hits and so on.
Preformatted text
def get_last_hour():
i = 0
swc_arr = []
res1 = es.search(index='testindex', body={
"query" : {
"range" : {
"timestamp" : {
"gte" : "now"
}
}
}
})
print("Number of %d Hits:" % res1['hits']['total'])
for hit in res1['hits']['hits']:
print("%(timestamp)s %(build_nb)s: %(swc_name)s: %(metric_name)s" % hit["_source"])
but what i tried to get is something more like this to work.
def get_last_hour():
res1 = es.search(index='testindex', body={
"query" : {
"range" : {
"timestamp" : {
"gte" : "now"
}
}
}
})
print("Number of %d Hits:" % res1['hits']['total'])
for hit in res1['hits']['hits']:
swc_arr = []
swc_arr.append(hit)
print("%(timestamp)s %(build_nb)s: %(swc_name)s: %(metric_name)s: %(metric_value)s" % hit["_source"])
for item in swc_arr:
print(swc_arr[item])