0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Splunk: ワイルドカード・正規表現を使用した検索まとめ

Posted at
実施環境: Splunk Free 8.2.2

0. 概要

Splunk では、ワイルドカードや正規表現を使用した検索が可能です。
今回はその方法についてまとめて紹介します。

対象データ
Splunk
| makeresults count=10
| streamstats count AS CNT
| eval TEST = tostring(CNT * 30, "hex")
| table TEST

WS000387.JPG

TEST
0x1E
0x3C
0x5A
0x78
0x96
0xB4
0xD2
0xF0
0x10E
0x12C

1. search コマンド - ワイルドカード使用

search コマンドでは、ワイルドカードとして*が使用可能です。
*は「0文字以上の任意の文字列」として扱われます。

Splunk
| makeresults count=10
| streamstats count AS CNT
| eval TEST = tostring(CNT * 30, "hex")
| table TEST
| search TEST="0x*C"

WS000388.JPG

TEST
0x3C
0x12C

2. where コマンド - ワイルドカード使用

where コマンドや eval コマンドでは、 LIKE 演算子を使用することでワイルドカードが使用可能です。

ワイルドカードとしては%_が使用可能です。
%は「0文字以上の任意の文字列」、_は「任意の1文字」として扱われます。
一般的なワイルドカードとは使用する文字が異なることに注意してください。

Splunk
| makeresults count=10
| streamstats count AS CNT
| eval TEST = tostring(CNT * 30, "hex")
| table TEST
| where TEST LIKE "0_1%"

WS000389.JPG

TEST
0x1E
0x10E
0x12C

LIKE は演算子の他に、関数としても存在します。
書き方が変わるだけで、使用方法はほぼ同じです。

Splunk
| makeresults count=10
| streamstats count AS CNT
| eval TEST = tostring(CNT * 30, "hex")
| table TEST
| where LIKE(TEST, "%x___")

WS000390.JPG

TEST
0x10E
0x12C

3. where コマンド - 正規表現使用

where コマンドや eval コマンドでは、 match 関数を使用することで正規表現が使用可能です。
正規表現はかなり多くの表現方法があるので、詳細は以下のサイトを参照してください。

About Splunk regular expressions

Splunk
| makeresults count=10
| streamstats count AS CNT
| eval TEST = tostring(CNT * 30, "hex")
| table TEST
| where match(TEST, "0x.*[A-C]")

WS000391.JPG

TEST
0x3C
0x5A
0xB4
0x12C
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?