メトリクス生成プロセッサー
特定のルールに続いて既存のメトリクスを使用して新しいメトリクスを作成します。
Splunk Distribution of the OpenTelemetry Collectorでは、Metrics Generationプロセッサーを使用して、所定のルールに従って既存のメトリクスを使用して新しいメトリクスを作成します。
このプロセッサーは現在、新しいメトリクスを作成するための以下の2つのルールタイプをサポートしています:
-
calculateします。以下の算術演算のいずれかを適用して、2 つの既存のメトリクスから新しいメトリクスを作成します:add、subtract、multiply、divide、またはpercent。-
たとえば、これを使用して、
pod.memory.utilizationメトリクスを等式pod.memory.utilization= (pod.memory.usage.bytes/node.memory.limitで計算します。 -
詳しくは、「calculate ルールの使用」を参照してください。
-
-
scaleします。既存のメトリクスの値を与えられた定数でスケーリングして新しいメトリクスを作成します。-
たとえば、
pod.memory.usageメトリクス値をメガバイトからバイトに変換するには、既存のメトリクス値に 1,048,576 を乗算します。
-
はじめに
以下の手順に従って、コンポーネントの設定とアクティベーションを行ってください:
-
Splunk Distribution of the OpenTelemetry Collector をホストまたはコンテナプラットフォームにデプロイします:
-
次のセクションで説明するように、
metricsgenerationプロセッサーを設定します。 -
Collector を再起動します。
サンプル構成
リソースプロセッサーを有効にするには、設定ファイルの metricsgeneration セクションに processors を追加します。生成ルールのリストを使用して設定を指定します。生成ルールは、指定されたメトリクス名に一致するメトリクスを検索し、指定された操作をそれらのメトリクスに適用します。例:
processors:
metricsgeneration:
# specify the metric generation rules
rules:
# Name of the new metric. This is a required field.
- name: <new_metric_name>
# Unit for the new metric being generated.
unit: <new_metric_unit>
# type describes how the new metric will be generated. It can be one of `calculate` or `scale`. calculate generates a metric applying the given operation on two operand metrics. scale operates only on operand1 metric to generate the new metric.
type: {calculate, scale}
# This is a required field. This must be a gauge or sum metric.
metric1: <first_operand_metric>
# This field is required only if the type is "calculate". When required, this must be a gauge or sum metric.
metric2: <second_operand_metric>
# Operation specifies which arithmetic operation to apply. It must be one of the five supported operations.
operation: {add, subtract, multiply, divide, percent}
設定を完了するには、構成ファイルの service セクションの metrics パイプラインにプロセッサを含めます。例:
service:
pipelines:
metrics:
processors: [metricsgeneration]
設定例:既存の2つのメトリクスを使用して新しいメトリクスを作成する
この例では、pod.cpu.usageとnode.cpu.limitを分割する新しいメトリクスpod.cpu.utilizedを作成しています。
rules:
- name: pod.cpu.utilized
type: calculate
metric1: pod.cpu.usage
metric2: node.cpu.limit
operation: divide
設定例:既存のメトリクスの値をスケーリングして新しいメトリクスを作成する
この例では、メトリクスpod.memory.usage.megabytesから新しいメトリクスpod.memory.usage.bytesを作成します。
rules:
- name: pod.memory.usage.bytes
unit: Bytes
type: scale
metric1: pod.memory.usage.megabytes
operation: multiply
scale_by: 1048576
calculate ルールの使用
calculateメトリクス生成ルールの具体的な動作は以下の通りです:
-
作成されたメトリクスは、最初のメトリクスとして設定されたメトリクスと同じタイプになります。
-
作成されるメトリクスに有効なデータポイントがない場合は、作成されません。これにより、プロセッサが空の新しいメトリクスを生成しないようにします。
-
重複する属性が一致するデータポイントでメトリクス計算を実行するには、機能ゲート
metricsgeneration.MatchAttributesを有効にします。この機能ゲートはデフォルトでオフになっています。つまり、計算中に 2 番目のメトリクスに使用される値は、単に最初のデータポイントの値です。-
機能ゲートの有効化と無効化の方法については、GitHub の「Collector Feature Gates」を参照してください。
-
設定
次の表は、metricsgeneration プロセッサーの構成オプションを示します:
トラブルシューティング
__ ___ ___ _ ______ _____________ _____ ________ ___ ___ ___ ____ __ ___ ____ ____ __ ______ _____________ ______ ___ ___ ___ ____ __ ___ _________ _____
_________ __ ______ _____________ _____ _________
-
______ _ ____ __ ___ ______ _______ _______
-
_______ ______ ________
_________ __ ___________ _________ ___ ____ _____ _____
-
___ _ ________ ___ ___ _______ _______ _________ _______ __ ______ ________
-
____ ___ ______ ______________ ____ _____ _____ _______ __ ___________ ____ __________ _________ ___ ______ _________ __________ __ _____ ___ ____ _______