{
	"script": {
		"lang": "mustache",
		"source": {
			"_source": {
				"excludes": []
			},
			"stored_fields": [
				"*"
			],
			"script_fields": {},
			"docvalue_fields": [
				{
					"field": "@timestamp",
					"format": "date_time"
				},
				{
					"field": "timestamp",
					"format": "date_time"
				}
			],
			"query": {
				"bool": {
					"must": [
						{
							"match_all": {}
						},
						{
							"match_all": {}
						},
						{
							"match_phrase": {
								"networkId": {
									"query": "{{network_id_query_param}}"
								}
							}
						},
						{
							"range": {
								"@timestamp": {
									"gte": "{{timestamp_greater_than_equal_query_param}}",
									"lte": "{{timestamp_lesser_than_equal_query_param}}",
									"format": "yyyy-MM-dd"
								}
							}
						},
						{
							"match_phrase": {
								"networkId": {
									"query": "{{network_id_query_param}}"
								}
							}
						}
					],
					"filter": [],
					"should": [],
					"must_not": [
						{
							"match_phrase": {
								"max": 88888888888
							}
						}
					]
				}
			},
			"size": "{{size_query_param}}",
			"aggs": {
				"routers_bucket": {
					"terms": {
						"field": "router_id.keyword",
						"size": 50,
						"order": {
							"_key": "desc"
						}
					},
					"aggs": {
						"days_bucket": {
							"date_histogram": {
								"field": "@timestamp",
								"interval": "1d",
								"time_zone": "UTC",
								"min_doc_count": 1
							},
							"aggs": {
								"hourly_bucket": {
									"date_histogram": {
										"field": "@timestamp",
										"interval": "1h",
										"time_zone": "UTC",
										"min_doc_count": 1
									},
									"aggs": {
										"avg_max": {
											"avg": {
												"field": "max"
											}
										},
										"avg_mean": {
											"avg": {
												"field": "mean"
											}
										},
										"avg_p99": {
											"avg": {
												"field": "p99"
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}
}