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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...