Я выполняю этот запрос -
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": "*",
"analyze_wildcard": true
}
},
{
"range": {
"server-status.meta.current-time": {
"lte": "now-91d/d"
}
}
}
],
"must_not": []
}
},
"size": 0,
"_source": {
"excludes": []
},
"aggs": {
"2": {
"date_histogram": {
"field": "server-status.meta.current-time",
"interval": "1h",
"time_zone": "CST6CDT",
"min_doc_count": 1
},
"aggs": {
"4": {
"terms": {
"field": "server-status.type.keyword",
"include": "http-server",
"size": 500,
"order": {
"1": "desc"
}
},
"aggs": {
"1": {
"sum": {
"field": "server-status.status-properties.expanded-tree-cache-hit-rate.value",
"script": "_value/60"
}
},
"3": {
"terms": {
"field": "server-status.name.keyword",
"size": 500,
"order": {
"1": "desc"
}
},
"aggs": {
"1": {
"sum": {
"field": "server-status.status-properties.expanded-tree-cache-hit-rate.value",
"script": "_value/60"
}
}
}
}
}
}
}
}
}
}
, который дает следующий набор результатов.Я вставляю фрагмент набора результатов.
{
"took": 4975,
"timed_out": false,
"_shards": {
"total": 225,
"successful": 225,
"failed": 0
},
"hits": {
"total": 76580901,
"max_score": 0,
"hits": []
},
"aggregations": {
"2": {
"buckets": [
{
"4": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"1": {
"value": 26.905470121166662
},
"3": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"1": {
"value": 19.867822477833336
},
"key": "App-Services",
"doc_count": 304
},
{
"1": {
"value": 6.262844921500001
},
"key": "polaris-content-v11-2-ssl-http",
"doc_count": 304
},
{
"1": {
"value": 0.593010372
},
"key": "polaris-c360-content-ssl-http",
"doc_count": 304
},
{
"1": {
"value": 0.07257377216666668
},
"key": "evisor-content-v11-https",
"doc_count": 304
},
{
"1": {
"value": 0.058457784666666665
},
"key": "ohca-ssl-http",
"doc_count": 304
},
{
"1": {
"value": 0.050760793
},
"key": "ivr-ani-ssl-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "Admin",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "App-Services-ldap",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "App-Services-no-ldap",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "HealthCheck",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "Manage",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "Manage-ldap",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "custom-Manage-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "epmp-admin-rxy-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "epmp-admin-ssl-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "epmp-content-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "epmp-ssl-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "epmp-ssl-http-v2",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "metadata-registry-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "monitoring-alerting-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "ohca-content-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "polaris-c360-content-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "stage-c360-xray-https",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "unstructured-content-http",
"doc_count": 304
},
{
"1": {
"value": 0
},
"key": "unstructured-content-ssl-http",
"doc_count": 304
}
]
},
"key": "http-server",
"doc_count": 7600
}
]
},
"key_as_string": "2018-04-11T09:00:00.000-05:00",
"key": 1523455200000,
"doc_count": 12160
},
Я бы хотел, чтобы результат был преобразован в следующую структуру json.
"_source": {
"server-status": {
"status-properties": {
"request-rate": {
"units": "quantity/sec",
"value": "0.785867"
},
"expanded-tree-cache-miss-rate": {
"units": "misses/sec",
"value": "0"
},
"expanded-tree-cache-hit-rate": {
"units": "hits/sec",
"value": "0"
}
},
"meta": {
"current-time": "2019-03-05T20:15:00.161724-06:00"
},
"name": "App-Services",
"type": "http-server"
}
},
"fields": {
"server-status.meta.current-time": [
1551838500161
]
},
"sort": [
9223372036854776000
]
}
Подойдет также эластичное преобразование наблюдателя.Я хотел бы преобразовать набор результатов в упомянутый формат.Я новичок в упругой.Запрос был получен после того, как я внес изменения в область визуализации и выполнил его в инструментах разработки.Но на самом деле я хочу принять данные после преобразования данных в упомянутый формат.