Skip to content
This repository was archived by the owner on Sep 2, 2025. It is now read-only.

Commit 4fe4318

Browse files
Draft
1 parent 7f6bcdd commit 4fe4318

File tree

1 file changed

+77
-11
lines changed

1 file changed

+77
-11
lines changed

gdi/opentelemetry/components/metrics-generation-processor.rst

Lines changed: 77 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,19 @@ Metrics generation processor
77
.. meta::
88
:description: Creates new metrics using existing metrics following a given rule.
99

10-
The Splunk Distribution of the OpenTelemetry Collector uses the Metrics transform processor to creates new metrics using existing metrics following a given rule.
10+
The Splunk Distribution of the OpenTelemetry Collector uses the Metrics Generation processor to create new metrics using existing metrics following a given rule.
1111

12+
This processor currently supports the following two rule types for creating a new metric:
1213

14+
* ``calculate``. Creates a new metric from two existing metrics by applying one of the following arithmetic operations: ``add``, ``subtract``, ``multiply``, ``divide``, or ``percent``.
1315

16+
* For example, use it to calculate the ``pod.memory.utilization`` metric with the equation ``pod.memory.utilization`` = (``pod.memory.usage.bytes`` / ``node.memory.limit``.
17+
18+
* Learn more at :ref:`metrics-generation-processor-calculate`.
19+
20+
* ``scale``. Creates a new metric by scaling the value of an existing metric with a given constant number.
21+
22+
* For example, use it to convert ``pod.memory.usage`` metric values from Megabytes to Bytes by multiplying the existing metric's value by 1,048,576.
1423

1524
Get started
1625
======================
@@ -29,14 +38,31 @@ Follow these steps to configure and activate the component:
2938
Sample configuration
3039
--------------------------------------------
3140

32-
To activate the resource processor, add ``metricsgeneration`` to the ``processors`` section of your configuration file.
33-
34-
For example:
41+
To activate the resource processor, add ``metricsgeneration`` to the ``processors`` section of your configuration file. Specify the configuration using a list of generation rules. Generation rules find the metrics which match the given metric names and apply the specified operation to those metrics. For example:
3542

3643
.. code-block:: yaml
3744
3845
processors:
3946
metricsgeneration:
47+
# specify the metric generation rules
48+
rules:
49+
# Name of the new metric. This is a required field.
50+
- name: <new_metric_name>
51+
52+
# Unit for the new metric being generated.
53+
unit: <new_metric_unit>
54+
55+
# 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.
56+
type: {calculate, scale}
57+
58+
# This is a required field. This must be a gauge or sum metric.
59+
metric1: <first_operand_metric>
60+
61+
# This field is required only if the type is "calculate". When required, this must be a gauge or sum metric.
62+
metric2: <second_operand_metric>
63+
64+
# Operation specifies which arithmetic operation to apply. It must be one of the five supported operations.
65+
operation: {add, subtract, multiply, divide, percent}
4066
4167
To complete the configuration, include the processor in the ``metrics`` pipeline of the ``service`` section of your configuration file. For example:
4268

@@ -47,28 +73,68 @@ To complete the configuration, include the processor in the ``metrics`` pipeline
4773
metrics:
4874
processors: [metricsgeneration]
4975
50-
.. _metrics-generation-processor-config-example:
76+
.. _metrics-generation-processor-example-new-metrics:
77+
78+
Configuration example: Create a new metric using two existing metrics
79+
------------------------------------------------------------------------------------------------------
80+
81+
This example creates the new metric ``pod.cpu.utilized`` dividing ``pod.cpu.usage`` and ``node.cpu.limit``.
82+
83+
.. code-block:: yaml
84+
85+
rules:
86+
- name: pod.cpu.utilized
87+
type: calculate
88+
metric1: pod.cpu.usage
89+
metric2: node.cpu.limit
90+
operation: divide
5191
52-
Configuration example
53-
----------------------------------
92+
.. _metrics-generation-processor-example-new-scaling:
5493

94+
Configuration example: Create a new metric scaling the value of an existing metric
95+
------------------------------------------------------------------------------------------------------
96+
97+
This example creates the new metric ``pod.memory.usage.bytes`` from the metric ``pod.memory.usage.megabytes``.
98+
99+
.. code-block:: yaml
100+
101+
rules:
102+
- name: pod.memory.usage.bytes
103+
unit: Bytes
104+
type: scale
105+
metric1: pod.memory.usage.megabytes
106+
operation: multiply
107+
scale_by: 1048576
108+
109+
.. _metrics-generation-processor-calculate:
110+
111+
Using the ``calculate`` rule
112+
============================================
113+
114+
Keep in mind the following specific behaviors of the ``calculate`` metric generation rule:
115+
116+
* The created metric has the same type as the metric configured as the first metric.
117+
118+
* If the metric being created doesn't have any valid data points it will not be created. This ensures the processor doesn't emit empty new metrics.
119+
120+
* If you want to have metric calculations done on data points whose overlapping attributes match, enable the feature gate ``metricsgeneration.MatchAttributes``. This feature gate is disabled by default, meaning the value used for the second metric during the calculations is simply the first data point's value.
121+
122+
* To learn how to enable and disable feature gates, see :new-page:`Collector Feature Gates <https://github.com/open-telemetry/opentelemetry-collector/blob/main/featuregate/README.md>` in GitHub.
55123

56124
.. _metrics-generation-processor-settings:
57125

58126
Settings
59127
======================
60128

61-
The following table shows the configuration options for the ``metricstransform`` processor:
129+
The following table shows the configuration options for the ``metricsgeneration`` processor:
62130

63131
.. raw:: html
64132

65-
<div class="metrics-standard" category="included" url="https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/processor/metricstransform.yaml"></div>
133+
<div class="metrics-standard" category="included" url="https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/processor/experimental_metricsgeneration.yaml"></div>
66134

67135
Troubleshooting
68136
======================
69137

70-
71-
72138
.. raw:: html
73139

74140
<div class="include-start" id="troubleshooting-components.rst"></div>

0 commit comments

Comments
 (0)