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

Commit dc0ec6f

Browse files
Merge pull request #2575 from splunk/urbiz-OD6977-metrics-px
[6977]: Metrics generation processor
2 parents ac18727 + 4fe4318 commit dc0ec6f

File tree

3 files changed

+157
-2
lines changed

3 files changed

+157
-2
lines changed

_includes/gdi/collector-available-processors.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@
2424
* - :ref:`kubernetes-attributes-processor` (``k8sattributes``)
2525
- Allows automatic tagging of spans, metrics, and logs with Kubernetes metadata. Formerly known as ``k8s_tagger``.
2626
- Metrics, logs, traces
27-
* - :ref:`memory-limiter-processor` (``memory_limiter``)
27+
* - :ref:`memory-limiter-processor` (``memory_limiter``)
2828
- Prevents out of memory situations on the Splunk Distribution of OpenTelemetry Collector.
2929
- Metrics, logs, traces
30+
* - :ref:`metrics-generation-processor` (``metricsgeneration``)
31+
- Creates new metrics using existing metrics following a given rule.
32+
- Metrics
3033
* - :ref:`metrics-transform-processor` (``metricstransform``)
3134
- Renames metrics, and adds, renames, or deletes label keys and values.
3235
- Metrics

gdi/opentelemetry/components/a-components-processors.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Collector components: Processors
1818
groupbyattrs-processor
1919
kubernetes-attributes-processor
2020
memory-limiter-processor
21+
metrics-generation-processor
2122
metrics-transform-processor
2223
probabilistic-sampler-processor
2324
redaction-processor
@@ -30,7 +31,7 @@ Collector components: Processors
3031

3132
The Splunk Distribution of the OpenTelemetry Collector includes and supports the processors listed on this doc. To see other components, refer to :ref:`otel-components`.
3233

33-
.. note:: The following list might not contain all the latest additions. For a complete list of Collector components, including components that aren't included in the Splunk Distribution of OpenTelemetry Collector, see the ``opentelemetry-contrib`` repository in GitHub.
34+
.. note:: The following list might not contain all the latest additions. For a complete list of Collector components, including components that aren't included in the Splunk Distribution of the OpenTelemetry Collector, see the ``opentelemetry-contrib`` repository in GitHub.
3435

3536
The following processors are available:
3637

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
.. _metrics-generation-processor:
2+
3+
***********************************
4+
Metrics generation processor
5+
***********************************
6+
7+
.. meta::
8+
:description: Creates new metrics using existing metrics following a given rule.
9+
10+
The Splunk Distribution of the OpenTelemetry Collector uses the Metrics Generation processor to create new metrics using existing metrics following a given rule.
11+
12+
This processor currently supports the following two rule types for creating a new metric:
13+
14+
* ``calculate``. Creates a new metric from two existing metrics by applying one of the following arithmetic operations: ``add``, ``subtract``, ``multiply``, ``divide``, or ``percent``.
15+
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.
23+
24+
Get started
25+
======================
26+
27+
Follow these steps to configure and activate the component:
28+
29+
1. Deploy the Splunk Distribution of the OpenTelemetry Collector to your host or container platform:
30+
31+
- :ref:`otel-install-linux`
32+
- :ref:`otel-install-windows`
33+
- :ref:`otel-install-k8s`
34+
35+
2. Configure the ``metricsgeneration`` processor as described in the next section.
36+
3. Restart the Collector.
37+
38+
Sample configuration
39+
--------------------------------------------
40+
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:
42+
43+
.. code-block:: yaml
44+
45+
processors:
46+
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}
66+
67+
To complete the configuration, include the processor in the ``metrics`` pipeline of the ``service`` section of your configuration file. For example:
68+
69+
.. code-block:: yaml
70+
71+
service:
72+
pipelines:
73+
metrics:
74+
processors: [metricsgeneration]
75+
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
91+
92+
.. _metrics-generation-processor-example-new-scaling:
93+
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.
123+
124+
.. _metrics-generation-processor-settings:
125+
126+
Settings
127+
======================
128+
129+
The following table shows the configuration options for the ``metricsgeneration`` processor:
130+
131+
.. raw:: html
132+
133+
<div class="metrics-standard" category="included" url="https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/processor/experimental_metricsgeneration.yaml"></div>
134+
135+
Troubleshooting
136+
======================
137+
138+
.. raw:: html
139+
140+
<div class="include-start" id="troubleshooting-components.rst"></div>
141+
142+
.. include:: /_includes/troubleshooting-components.rst
143+
144+
.. raw:: html
145+
146+
<div class="include-stop" id="troubleshooting-components.rst"></div>
147+
148+
149+
150+
151+

0 commit comments

Comments
 (0)