######## ncfabriccircuits templates ######## # ncfabriccircuits_service_endpoint_dial_logs_v8_tmpl # ncfabriccircuits_service_dial_health_v8_tmpl resource "elasticstack_elasticsearch_script" "ncfabriccircuits_service_endpoint_dial_logs_v8_tmpl" { script_id = "ncfabriccircuits_service_endpoint_dial_logs_v8_tmpl" lang = "mustache" source = <<-EOT { "track_total_hits": true, "sort": [ { "timestamp": { "order": "desc", "unmapped_type": "boolean" } } ], "size": "{{size}}", "query": { "bool": { "must": [ { "range": { "timestamp": { "gte": "{{gte}}", "lte": "{{lte}}", "format": "epoch_millis" } } } {{#endpointId}}, { "match_phrase": { "identity_id.keyword": { "query": "{{endpointId}}" } } } {{/endpointId}} {{#serviceName}}, { "match_phrase": { "service_name.keyword": { "query": "{{serviceName}}" } } } {{/serviceName}} {{#endpointName}}, { "match_phrase": { "identity_name.keyword": { "query": "{{endpointName}}" } } } {{/endpointName}} {{#serviceId}}, { "match_phrase": { "service_id.keyword": { "query": "{{serviceId}}" } } } {{/serviceId}} {{#networkEventType}}, { "match_phrase": { "event_type": { "query": "{{networkEventType}}" } } } {{/networkEventType}} ], "filter": [ { "match_phrase": { "network_group_id": "{{networkGroupId}}" } }, { "match_phrase": { "network_id": "{{networkId}}" } } ] } } } EOT } resource "elasticstack_elasticsearch_script" "ncfabriccircuits_service_dial_health_v8_tmpl" { script_id = "ncfabriccircuits_service_dial_health_v8_tmpl" lang = "mustache" source = jsonencode({ "query": { "bool": { "must": [], "filter": [ { "match_phrase": { "network_id": { "query": "{{networkId}}" } } }, { "match_phrase": { "service_id.keyword": "{{serviceId}}" } }, { "range": { "timestamp": { "format": "strict_date_optional_time", "gte": "{{gte}}", "lte": "{{lte}}" } } } ] } }, "aggs": { "time_buckets": { "date_histogram": { "field": "timestamp", "fixed_interval": "{{aggInterval}}", "time_zone": "{{timeZone}}", "min_doc_count": 1 }, "aggs": { "failure_causes": { "terms": { "field": "failure_cause.keyword", "order": { "_count": "desc" }, "size": "{{aggTermSize}}" } } } } }, "size": "{{size}}" }) } resource "elasticstack_elasticsearch_script" "ncfabriccircuits_identity_traffic_analysis_v8_tmpl" { script_id = "ncfabriccircuits_identity_traffic_analysis_v8_tmpl" lang = "mustache" source = <<-EOT { "track_total_hits": false, "aggs": { "initiator": { "terms": { "field": "initiator_remote_ip.keyword", "order": { "_count": "desc" }, "size": 100 }, "aggs": { "ingress_entity": { "terms": { "field": "identity_name.keyword", "order": { "_count": "desc" }, "size": 100 }, "aggs": { "service_name": { "terms": { "field": "service_name.keyword", "order": { "_count": "desc" }, "size": 100 }, "aggs": { "hosting_entity": { "terms": { "field": "host_name.keyword", "order": { "_count": "desc" }, "size": 100 }, "aggs": { "terminator_remote": { "terms": { "field": "path.terminator_remote_addr.keyword", "order": { "_count": "desc" }, "size": 100 } } } } } } } } } } }, "size": 0, "query": { "bool": { "must": [], "filter": [ { "match_phrase": { "network_id.keyword": "{{networkId}}" } }, { "match_phrase": { "network_group_id.keyword": "{{networkGroupId}}" } }, { "range": { "timestamp": { "format": "strict_date_optional_time", "gte": "{{gte}}", "lte": "{{lte}}" } } } {{#endpointId}}, { "match_phrase": { "identity_id.keyword": "{{endpointId}}" } } {{/endpointId}} {{#serviceId}}, { "match_phrase": { "service_id.keyword": "{{serviceId}}" } } {{/serviceId}} {{#serviceName}}, { "match_phrase": { "service_name.keyword": "{{serviceName}}" } } {{/serviceName}} {{#hostName}}, { "match_phrase": { "host_name.keyword": "{{hostName}}" } } {{/hostName}} {{#terminatorRemoteIp}}, { "terms": { "terminator_remote_ip.keyword": {{#toJson}}terminatorRemoteIp{{/toJson}} } } {{/terminatorRemoteIp}} {{#terminatorRemotePort}}, { "terms": { "terminator_remote_port.keyword": {{#toJson}}terminatorRemotePort{{/toJson}} } } {{/terminatorRemotePort}} {{#initiatorRemoteIp}}, { "terms": { "initiator_remote_ip.keyword": {{#toJson}}initiatorRemoteIp{{/toJson}} } } {{/initiatorRemoteIp}} ] } } } EOT }