Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New component: Signal to metrics connector #35930

Open
lahsivjar opened this issue Oct 22, 2024 · 3 comments
Open

New component: Signal to metrics connector #35930

lahsivjar opened this issue Oct 22, 2024 · 3 comments
Labels
Accepted Component New component has been sponsored

Comments

@lahsivjar
Copy link
Member

lahsivjar commented Oct 22, 2024

The purpose and use-cases of the new component

Signal to metrics connector can produce metrics from all signal types (logs, metrics, and traces).

The currently available connectors like countconnector, spanmetricsconnector, sumconnector can perform specific tasks and become a bit hard to use with evolving use-cases. Signal to metrics connector will utilize OTTL expressions to make data manipulation from the incoming signals configurable, thus allowing the component to serve a wider range of use-cases.

The OTTL expressions can be configured depending on the metric types. For example: for histograms and exponential histograms, count and value could be retrieved based on separate OTTL expressions whereas, for sum metric the value could be retrieved from a single value OTTL expression.

Example configuration for the component

Generic configuration

signaltometrics:
  spans:
    - name: span.duration
      description: Span duration as exponential histogram
      unit: us
      attributes: # categorize by attributes
        - key: attribute.foo
      exponential_histogram:
        count: Int(AdjustedCount()) # Adjusted count here is calculated as a custom OTTL converter
        value: Microseconds(end_time - start_time)
  datapoints:
    - name: datapoint.count
      description: Sum all the attribute value on the datapoint with name datapoint.foo
      conditions:
        - IsDouble(attributes["datapoint.foo"]) or IsInt(attributes["datapoint.foo"]) # only evaluate if datapoint.foo is a number
      sum:
        value: Double(attributes["datapoint.foo"])
  logs:
    - name: logrecord.count
      description: Count of log records
      sum:
        value: "1" # increment by 1 for each log record

Count connector use-cases

signaltometrics:
  spans:
    - name: trace.span.count
      description: Counts all spans
      sum:
        value: "1" # count each span as 1
  datapoints:
    - name: metric.datapoint.count
      description: Count of datapoints
      sum:
        value: "1" # count each datapoint as 1
  logs:
    - name: log.record.count
      description: Count of log records
      sum:
        value: "1" # count each log record as 1

Sum connector use-cases

signaltometrics:
  logs:
    - name: my.example.metric.name
      description: Sum of all attribute values with key attribute.with.numerical.value
      sum:
        value: Double(attributes["attribute.with.numerical.value"])

Span metrics connector use-cases

signaltometrics:
  spans:
    - name: calls
      description: Counts all spans
      attributes:
        - key: span.name
        - key: span.kind
        - key: status.code
      sum:
        value: "1" # count each span as 1
    - name: duration
      description: Counts all spans
      attributes:
        - key: span.name
        - key: span.kind
        - key: status.code
      unit: us
      exponential_histogram:
        value: Microseconds(end_time - start_time)

Convert a gauge metric to a histogram

signaltometrics:
  datapoints:
    - name: gauge.to.exphistogram
      description: An exponential histogram created from gague values
      include_resource_attributes:
        - key: resource.foo
      attributes:
        - key: datapoint.foo
      conditions:
        - metric.type == 1 # select all gauges
      exponential_histogram:
        count: "1" # 1 count for each datapoint
        value: Double(value_int) + value_double # handle both int and double

Telemetry data types supported

traces, metrics, and logs

Is this a vendor-specific component?

NO

Code Owner(s)

@lahsivjar

Sponsor (optional)

@ChrsMark

Additional context

We, at Elastic, have a working version of this component with a lot of the features for spans, datapoints, and, logrecords already developed and we would like to contribute the component upstream as we believe it could be useful to the community.

@djaglowski
Copy link
Member

I think this is a great idea. Am I correct in understanding that it depends on #35621?

@lahsivjar
Copy link
Member Author

lahsivjar commented Nov 14, 2024

Am I correct in understanding that it depends on #35621?

Partially. In our current implementation, we have circumvented this by an internal get editor function which we use to create OTTL statement from data expressions - so not exactly a blocker.

@ChrsMark
Copy link
Member

I'm willing to sponsor this.

@ChrsMark ChrsMark added Accepted Component New component has been sponsored and removed Sponsor Needed New component seeking sponsor labels Nov 20, 2024
andrzej-stencel pushed a commit that referenced this issue Nov 25, 2024
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

Adds boilerplate code for a new signal to metrics connector.

<!-- Issue number (e.g. #1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Part of
#35930

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Unit tests provided as required.

<!--Describe the documentation added.-->
#### Documentation

Added basic README. Will add more details with future commits.
<!--Please delete paragraphs that you did not use before submitting.-->


CC: @ChrsMark

---------

Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Accepted Component New component has been sponsored
Projects
None yet
Development

No branches or pull requests

4 participants