package main
import (
"regexp"
"fmt"
)
func main() {
var re = regexp.MustCompile(`(?m)^(?P<alb_type>(https?|h2|wss?))\s*(?P<alb_timestamp>[^\s]+)\s*(?P<alb_elb>[^\s]+)\s*(?P<alb_client_addr>[^:]+):\s*(?P<alb_client_port>[^\s]+)\s*(?P<alb_target_addr>[^:]+):\s*(?P<alb_target_port>[^\s]+)\s*\s*(?P<alb_request_processing_time>[^\s]+)\s*(?P<alb_target_processing_time>[^\s]+)\s*(?P<alb_response_processing_time>[^\s]+)\s*(?P<alb_elb_status_code>[^\s]+)\s*(?P<alb_target_status_code>[^\s]+)\s*(?P<alb_received_bytes>[^\s]+)\s*(?P<alb_sent_bytes>[^\s]+)\s*"(?P<alb_request>.*?)"\s+"(?P<alb_user_agent>[^\"]+)"\s*(?P<alb_ssl_cipher>[^\s]+)\s*(?P<alb_ssl_protocol>[^\s]+)\s*(?P<alb_target_group_arn>[^\s]+)\s*"(?P<alb_trace_id>[^\"]+)"\s*"(?P<alb_domain_name>[a-zA-Z0-9\.\-:]+)"\s*"(?P<alb_chosen_cert_arn>[^\"]+)"\s*(?P<alb_matched_rule_priority>[^\s]+)\s*(?P<alb_request_creation_time>[^\s]+)\s*\s*"(?P<alb_actions_executed>[^\s]+)"\s*"(?P<alb_redirect_url>[^\s]+)"\s*"(?P<alb_error_reason>[^\"]+)"\s*"?(?P<alb_target_port_list>[0-9 :\.-]+)"?\s*"?(?P<alb_target_status_code_list>[0-9 -]+)"?`)
var str = `https 2021-12-28T08:45:46.363601Z app/k8s-internaltelioalb-0189d12367/7b3deb885c66a05c 10.50.8.89:59718 10.50.16.243:3000 0.000 0.702 -1 502 - 492 272 "POST https://api-internal.prd.telio.me:443/internal/oms/graphql HTTP/1.1" "axios/0.21.1" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 arn:aws:elasticloadbalancing:ap-southeast-1:305671018540:targetgroup/k8s-telio-omsservi-0d37efa96a/62501827cfb001cc "Root=1-61caceb9-7c362e4c422488481a886f20" "api-internal.prd.telio.me" "arn:aws:acm:ap-southeast-1:305671018540:certificate/1389500b-1e0f-4bb9-bfee-2356cf20f40d" 3 2021-12-28T08:45:45.658000Z "forward" "-" "-" "10.50.16.243:3000" "-" "-" "-"
https 2021-12-28T08:46:08.788818Z app/k8s-internaltelioalb-0189d12367/7b3deb885c66a05c 10.50.8.77:46086 10.50.16.243:3000 0.000 3.849 -1 502 - 492 272 "GET https://api-internal.prd.telio.me:443/internal/oms/graphql?query=query%7B%0A++++++++++warehouseByCustomer(%0A++++++++++++verticalId:+%22null%22,%0A++++++++++++customerId:+%2238311%22,%0A++++++++++++addressId:+109138,%0A++++++++++++warId:+119101103,%0A++++++++++)%7B%0A++++++++++++id,%0A++++++++++++storeId,%0A++++++++++++name%0A++++++++%7D%7D HTTP/1.1" "axios/0.19.2" ECDHE-RSA-AES128-GCM-SHA256 TLSv1.2 arn:aws:elasticloadbalancing:ap-southeast-1:305671018540:targetgroup/k8s-telio-omsservi-0d37efa96a/62501827cfb001cc "Root=1-61cacecc-1a87e41c30f7191a28b89096" "api-internal.prd.telio.me" "session-reused" 3 2021-12-28T08:46:04.939000Z "forward" "-" "-" "10.50.16.243:3000" "-" "-" "-"`
for i, match := range re.FindAllString(str, -1) {
fmt.Println(match, "found at index", i)
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Golang, please visit: https://golang.org/pkg/regexp/