Splunk Search

regex問題のトラブルシューティング方法について

cwl
Contributor

以下のサーチ文で、regexreplacementプロセッサーがかなりのCPUリソースを使用していることまではわかりましたが、どのように問題のREGEXを特定できますでしょうか。

index=_internal source=*metrics.log* group=pipeline name=typing | timechart limit=50 span=1h per_hour(cpu_seconds) by processor

例えば、どのsourcetypeやhostなどからのREGEXがCPUを使っているかを特定する方法はありますでしょうか。

0 Karma
1 Solution

cwl
Contributor

Splunk Enterprise 6.6 および 7.0 から、limits.conf に以下のパラメータが追加されました。

regex_cpu_profiling = <bool>
* Enable CPU time metrics for RegexProcessor. Output will be in the 
  metrics.log file.
  Entries in metrics.log will appear per_host_regex_cpu, per_source_regex_cpu,
  per_sourcetype_regex_cpu, per_index_regex_cpu.
* Default: false

regex_cpu_profiling を true に設定し、splunk を再起動することにより、metrics.log に per_host_regex_cpu、per_source_regex_cpu、per_sourcetype_regex_cpu、per_index_regex_cpu のような情報が追加されます。
そして、以下のサーチ文を使うことにより、どの sourcetype がもっとも CPU リソースを使用しているかを確認することができます。

index=_internal host=<調査対象ホストサーバ> source=*metrics.log* group=per_sourcetype_regex_cpu | timechart max(cpu) by series

また、以下のサーチ文を使うことにより、event 毎にどの sourcetype がもっとも CPU リソースを使用しているかを確認することができます。

index=_internal host=<調査対象ホストサーバ> source=*metrics.log* group=per_sourcetype_regex_cpu | timechart max(cpupe) by series

なお、デフォルトでは、もっともCPUリソースを使用する上位の10 sourceytypeしかmetrics.logに記録されず、10より多くのsourcetypeを記録したい場合は、記録したい数をmaxseriesに設定する必要があります。

[metrics]
maxseries = <integer>
* The number of series to include in the per_x_thruput reports in metrics.log.
* Default: 10

View solution in original post

cwl
Contributor

Splunk Enterprise 6.6 および 7.0 から、limits.conf に以下のパラメータが追加されました。

regex_cpu_profiling = <bool>
* Enable CPU time metrics for RegexProcessor. Output will be in the 
  metrics.log file.
  Entries in metrics.log will appear per_host_regex_cpu, per_source_regex_cpu,
  per_sourcetype_regex_cpu, per_index_regex_cpu.
* Default: false

regex_cpu_profiling を true に設定し、splunk を再起動することにより、metrics.log に per_host_regex_cpu、per_source_regex_cpu、per_sourcetype_regex_cpu、per_index_regex_cpu のような情報が追加されます。
そして、以下のサーチ文を使うことにより、どの sourcetype がもっとも CPU リソースを使用しているかを確認することができます。

index=_internal host=<調査対象ホストサーバ> source=*metrics.log* group=per_sourcetype_regex_cpu | timechart max(cpu) by series

また、以下のサーチ文を使うことにより、event 毎にどの sourcetype がもっとも CPU リソースを使用しているかを確認することができます。

index=_internal host=<調査対象ホストサーバ> source=*metrics.log* group=per_sourcetype_regex_cpu | timechart max(cpupe) by series

なお、デフォルトでは、もっともCPUリソースを使用する上位の10 sourceytypeしかmetrics.logに記録されず、10より多くのsourcetypeを記録したい場合は、記録したい数をmaxseriesに設定する必要があります。

[metrics]
maxseries = <integer>
* The number of series to include in the per_x_thruput reports in metrics.log.
* Default: 10
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...