Documentation
¶
Overview ¶
Package otel provides data structures to represent and generate otel configuration.
Index ¶
- Variables
- func AddLabel(key, value string) map[string]interface{}
- func AggregateLabels(aggregationType string, labels ...string) map[string]interface{}
- func CombineMetrics(old, new string, operations ...map[string]interface{}) map[string]interface{}
- func ExtractCountMetric(monotonic bool, metricName string) []string
- func RenameLabel(old, new string) map[string]interface{}
- func RenameMetric(old, new string, operations ...map[string]interface{}) map[string]interface{}
- type Component
- func AddResourceAttr(key, from string) Component
- func GCPResourceDetector() Component
- func GroupByGMPAttrs() Component
- func MetricsFilter(polarity, matchType string, metricNames ...string) Component
- func MetricsTransform(metrics ...map[string]interface{}) Component
- func Transform(statementType, context string, statements []string) Component
- func TransformationMetrics(queries ...TransformQuery) Component
- type ModularConfig
- type ReceiverPipeline
- type TransformQuery
- func AddMetricLabel(key, val string) TransformQuery
- func DeleteMetricAttribute(metricAttribute string) TransformQuery
- func FlattenResourceAttribute(resourceAttribute, metricAttribute string) TransformQuery
- func GroupByAttribute(resourceAttribute, metricAttribute string) TransformQuery
- func PrefixResourceAttribute(destResourceAttribute, srcResourceAttribute, delimiter string) TransformQuery
Constants ¶
This section is empty.
Variables ¶
var ToggleScalarDataType = map[string]interface{}{"action": "toggle_scalar_data_type"}
ToggleScalarDataType transforms int -> double and double -> int.
Functions ¶
func AggregateLabels ¶
AggregateLabels removes all labels except those in the passed list, aggregating values using aggregationType.
func CombineMetrics ¶
CombineMetrics returns a config snippet that renames metrics matching the regex old to new, applying zero or more transformations.
func ExtractCountMetric ¶
ExtractCountMetric creates a new metric based on the count value of a Histogram metric
func RenameLabel ¶
RenameLabel renames old to new
func RenameMetric ¶
RenameMetric returns a config snippet that renames old to new, applying zero or more transformations.
Types ¶
type Component ¶
type Component struct {
// Type is the string type needed to instantiate the OT component.
Type string
// Config is an object which can be serialized by mapstructure into the configuration for the component.
// This can either be a map[string]interface{} or a Config struct from OT.
Config interface{}
}
Component represents a single OT component (receiver, processor, exporter, etc.)
func AddResourceAttr ¶
AddResourceAttr adds a resource attribute using a processor.
func GCPResourceDetector ¶
func GCPResourceDetector() Component
GCPResourceDetector returns a resourcedetection processor configured for only GCP.
func GroupByGMPAttrs ¶
func GroupByGMPAttrs() Component
GroupByGMPAttrs moves the "namespace" and "cluster" metric attributes to resource attributes.
Metrics coming from run-gmp-sidecar are written against the `prometheus_target` monitored resource in Cloud Monitoring. The labels for these monitored resources come from the OTel resource labels. As a result, this processor needs to promote certain metric labels to resource labels so the translation can happen correctly.
See https://cloud.google.com/monitoring/api/resources#tag_prometheus_target for more information about the monitored resource used.
func MetricsFilter ¶
MetricsFilter returns a Component that filters metrics. polarity should be "include" or "exclude". matchType should be "strict" or "regexp".
func MetricsTransform ¶
MetricsTransform returns a Component that performs the transformations specified as arguments.
func Transform ¶
Transform returns a transform processor object that executes statements on statementType data.
func TransformationMetrics ¶
func TransformationMetrics(queries ...TransformQuery) Component
TransformationMetrics returns a transform processor object that contains all the queries passed into it.
type ModularConfig ¶
type ModularConfig struct {
LogLevel string
ReceiverPipelines map[string]ReceiverPipeline
Exporter Component
SelfMetricsPort int
}
func (ModularConfig) Generate ¶
func (c ModularConfig) Generate() (string, error)
type ReceiverPipeline ¶
ReceiverPipeline represents a single OT receiver and zero or more processors that must be chained after that receiver.
type TransformQuery ¶
type TransformQuery string
TransformQuery is a type wrapper for query expressions supported by the transform processor found here: https://github.com/open-telemetry/opentelemetry-collector-contrib/tree/main/processor/transformprocessor
func AddMetricLabel ¶
func AddMetricLabel(key, val string) TransformQuery
AddMetricLabel adds a new metric attribute. If it already exists, then it is overwritten.
func DeleteMetricAttribute ¶
func DeleteMetricAttribute(metricAttribute string) TransformQuery
DeleteMetricAttribute returns an expression that removes the metric attribute specified.
func FlattenResourceAttribute ¶
func FlattenResourceAttribute(resourceAttribute, metricAttribute string) TransformQuery
FlattenResourceAttribute returns an expression that brings down a resource attribute to a metric attribute.
func GroupByAttribute ¶
func GroupByAttribute(resourceAttribute, metricAttribute string) TransformQuery
GroupByAttribute returns an expression that makes a metric attribute into a resource attribute.
func PrefixResourceAttribute ¶
func PrefixResourceAttribute(destResourceAttribute, srcResourceAttribute, delimiter string) TransformQuery
PrefixResourceAttribute prefixes the resource attribute with another resource attribute.
Note: Mutating the resource attribute results in this update happening for each data point. Since the OTTL statement uses the resource attribute in both the target and the source labels, we must make sure after the first mutation, the subsequent transformations for the same resource is a no-op.