props.conf のEXTRACTを追加して、フィールドを定義したいのですが、どのように記述すればよいかわかりません。
文法書、または、マニュアルなどがありましたら、教えていただきたく。
例えば、
EXTRACT-AAA = ^\w+(\d+\s+)+(\w+\s+)+(\d+\s+)+\w+\d+\w+\d+\w+\d+\w+\d+(?P\w+)
個々の文字が何を意味するのかわかりません。
props.conf内にサーチ時に適応されるフィールド抽出の設定(正規表現)を記載する場合には、EXTRACTを指定しますが、文法は以下のようになっています。詳細はこちらのprops.confのドキュメントを参考にしてみてください。
また、指定する正規表現に関しては、私個人的に以下のサイトをよく利用します。
https://regex101.com/
その他、ざっくりとWikipedia にも質問に書かれている正規表現の意味がかかれているとおもいますので、リンクさせていただきます。
https://ja.wikipedia.org/wiki/%E6%AD%A3%E8%A6%8F%E8%A1%A8%E7%8F%BE
EXTRACT-<class> = [<regex>|<regex> in <src_field>]
* Used to create extracted fields (search-time field extractions) that do
not reference transforms.conf stanzas.
* Performs a regex-based field extraction from the value of the source
field.
* <class> is a unique literal string that identifies the namespace of the
field you're extracting.
**Note:** <class> values do not have to follow field name syntax
restrictions. You can use characters other than a-z, A-Z, and 0-9, and
spaces are allowed. <class> values are not subject to key cleaning.
* The <regex> is required to have named capturing groups. When the <regex>
matches, the named capturing groups and their values are added to the
event.
* dotall (?s) and multiline (?m) modifiers are added in front of the regex.
So internally, the regex becomes (?ms)<regex>.
* Use '<regex> in <src_field>' to match the regex against the values of a
specific field. Otherwise it just matches against _raw (all raw event
data).
* NOTE: <src_field> can only contain alphanumeric characters and underscore
(a-z, A-Z, 0-9, and _).
* If your regex needs to end with 'in <string>' where <string> is *not* a
field name, change the regex to end with '[i]n <string>' to ensure that
Splunk doesn't try to match <string> to a field name.
props.confのEXTRACTは、フィールド抽出の際に利用されます。マニュアルとしましては、http://docs.splunk.com/images/a/a0/Splunk-6.3.0-ja_JP-Data.pdfになりますが、ちょっとわかりづらいです。
これは実際には正規表現の世界になります。^ \w \s \d + ? の意味については外部サイトになりますが、こちらを参照されるのも方法かと思います。http://homepage2.nifty.com/jr-kun/hidemaru_qa/4_regulr.html#BASIC。
実際にはこの正規表現を利用して、キャプチャという機能を利用してフィールド名を定義して、フィールドを決めています。上記の例ではキャプチャの際のフィールド名の定義がありませんが、キャプチャは, (?P ) 内に囲まれたものになります。このにフィールド名を定義しますが、キャプチャ内の正規表現にマッチした文字列が値となります。例えば、実際のデータが、
NETWORK
の場合、フィールド名にaccessvector
値にNETWORKを取りたいとします。
この場合は、EXTRACT-accessvector = (?P[^<]+)
となります。前の文字、はキャプチャの前にヒットする文字です。(?P<フィールド名>実際の値 ) がキャプチャになります。フィールド名は< >で囲まれたものです。そのあとの [^<] は、”<”でない文字列があり、 その後の"+"で"<"ではない文字が続くまで文字を取得するという意味になります。
ありがとうございました。正規表現なんとか理解できました。
props.confのEXTRACTを追加して、保存しましたがうまくフィールドが抽出だきません。
props.confを保存するだけではだめなのでしょうか。