同じデータを抽出しようとしています (ただし、文字列から異なる「チャンク」で数回抽出します。ユースケースは、Fluentd で Fastly からの Syslog メッセージを解析することです。
私はこのログ行を持っています:
2015-08-27T12:36:58Z cache-foo1234 Name[123456]: 4.151.22.16 "-" "-" POST /api/v1/foo/61ea23fb-53fb-4364-a892-349fdf5f6dca/event?release_type=store&version=2%2E0%2E1&os=ios&device_os_version=8%2E4&device_type=iphone 304 MISS BC942858-64FA-4101-BAE1-19272490697F iPhone 5S
これまでのところ、この正規表現(Ruby Regex):
^(?<time>[^ ]*) (?<fastly_server>[^ ]*) (?<log_name>[^ ]*) (?<host>[^ ]*) (?<na>[^ ]*) (?<na2>[^ ]*) (?<http_method>[^ ]*) (?<http_request>[^ ]*) (?<http_status>[^ ]*) (?<cache_status>[^ ]*) (?<uuid>[^ ]*) *(?<device_model>.*)$
そしてこれは私に与えます:
time
2015-08-27T12:36:58Zfastly_server
キャッシュ foo1234log_name
名前[123456]:host
4.151.22.16http_method
役職http_request
/api/v1/foo/61ea23fb-53fb-4364-a892-349fdf5f6dca/event?release_type=store&version=2%2E0%2E1&os=ios&device_os_version=8%2E4&device_type=iphonehttp_status
304cache_status
お嬢uuid
BC942858-64FA-4101-BAE1-19272490697Fdevice_model
iPhone 5S
それは完璧ですが、どうすれば元に戻って抽出できますか。61ea23fb-53fb-4364-a892-349fdf5f6dca
、および同じ正規表現を持つ同じ文字列からevent
の値?device_os_version