Documentation ¶
Overview ¶
Package otel provides data structures to represent and generate otel configuration.
Index ¶
- Constants
- Variables
- func AddLabel(key, value string) map[string]interface{}
- func AddPrefix(prefix string, operations ...map[string]interface{}) map[string]interface{}
- func AggregateLabelValues(aggregationType string, label string, new string, old ...string) map[string]interface{}
- func AggregateLabels(aggregationType string, labels ...string) map[string]interface{}
- func ChangePrefix(oldPrefix, newPrefix string) map[string]interface{}
- func CombineMetrics(old, new string, operations ...map[string]interface{}) map[string]interface{}
- func DeleteLabelValue(label, value string) map[string]interface{}
- func DuplicateMetric(old, new string, operations ...map[string]interface{}) map[string]interface{}
- func RegexpRename(regexp string, rename string, operations ...map[string]interface{}) map[string]interface{}
- func RenameLabel(old, new string) map[string]interface{}
- func RenameLabelValues(label string, transforms map[string]string) map[string]interface{}
- func RenameMetric(old, new string, operations ...map[string]interface{}) map[string]interface{}
- func ScaleValue(factor float64) map[string]interface{}
- func UpdateMetric(metric string, operations ...map[string]interface{}) map[string]interface{}
- func UpdateMetricRegexp(metricRegex string, operations ...map[string]interface{}) map[string]interface{}
- type Component
- func CastToSum(metrics ...string) Component
- func CondenseResourceMetrics() Component
- func Filter(dataType, context string, expressions []ottl.Value) Component
- func GCPResourceDetector(override bool) Component
- func GroupByGMPAttrs() Component
- func MetricsFilter(polarity, matchType string, metricNames ...string) Component
- func MetricsOTTLFilter(metricQueries []string, datapointQueries []string) Component
- func MetricsTransform(metrics ...map[string]interface{}) Component
- func ModifyInstrumentationScope(name string, version string) Component
- func NormalizeSums() Component
- func ResourceTransform(attributes map[string]string, override bool) Component
- func Transform(statementType, context string, statements ottl.Statements) Component
- func TransformationMetrics(queries ...TransformQuery) Component
- type ExporterType
- type ModularConfig
- type Pipeline
- type ReceiverPipeline
- type ResourceDetectionMode
- type TransformQuery
- func ConvertFloatToInt(metricName string) TransformQuery
- func ConvertGaugeToSum(metricName string) TransformQuery
- func FlattenResourceAttribute(resourceAttribute, metricAttribute string) TransformQuery
- func RetainResource(resourceAttributeKeys ...string) TransformQuery
- func SetAttribute(metricName, attributeKey, attributeValue string) TransformQuery
- func SetDescription(metricName, metricDescription string) TransformQuery
- func SetName(oldName, newName string) TransformQuery
- func SetUnit(metricName, unit string) TransformQuery
- func SummaryCountValToSum(metricName, aggregation string, isMonotonic bool) TransformQuery
- func SummarySumValToSum(metricName, aggregation string, isMonotonic bool) TransformQuery
Constants ¶
const MetricsPort = 20201
Variables ¶
var ToggleScalarDataType = map[string]interface{}{"action": "toggle_scalar_data_type"}
ToggleScalarDataType transforms int -> double and double -> int.
Functions ¶
func AggregateLabelValues ¶
func AggregateLabelValues(aggregationType string, label string, new string, old ...string) map[string]interface{}
AggregateLabelValues combines the given values into a single value
func AggregateLabels ¶
AggregateLabels removes all labels except those in the passed list, aggregating values using aggregationType.
func ChangePrefix ¶
ChangePrefix returns a config snippet that updates a prefix on all metrics.
func CombineMetrics ¶
CombineMetrics returns a config snippet that renames metrics matching the regex old to new, applying zero or more transformations.
func DeleteLabelValue ¶
DeleteLabelValue removes streams with the given label value
func DuplicateMetric ¶
DuplicateMetric returns a config snippet that copies old to new, applying zero or more transformations.
func RegexpRename ¶
func RegexpRename(regexp string, rename string, operations ...map[string]interface{}) map[string]interface{}
RegexpRename returns a config snippet that renames metrics matching the given regexp. The `rename` argument supports capture groups as `${1}`, `${2}`, and so on.
func RenameLabel ¶
RenameLabel renames old to new
func RenameLabelValues ¶
RenameLabelValues renames label values
func RenameMetric ¶
RenameMetric returns a config snippet that renames old to new, applying zero or more transformations.
func ScaleValue ¶
ScaleValue multiplies the value by factor
func UpdateMetric ¶
UpdateMetric returns a config snippet applies transformations to the given metric name
func UpdateMetricRegexp ¶
func UpdateMetricRegexp(metricRegex string, operations ...map[string]interface{}) map[string]interface{}
UpdateMetricRegexp returns a config snippet that applies transformations to metrics matching the input regex
Types ¶
type Component ¶
type Component struct { // Type is the string type needed to instantiate the OT component (e.g. "windowsperfcounters") 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 CondenseResourceMetrics ¶
func CondenseResourceMetrics() Component
CondenseResourceMetrics merges multiple resource metrics on a slice of metrics to a single resource metrics payload, if they have the same resource.
func Filter ¶
Filter returns a filter processor object that drops dataType.context data matching any of the expressions.
func GCPResourceDetector ¶
GCPResourceDetector returns a resourcedetection processor configured for only GCP.
func GroupByGMPAttrs ¶
func GroupByGMPAttrs() Component
GroupByGMPAttrs moves the "namespace", "cluster", and "location" metric attributes to resource attributes. The googlemanagedprometheus exporter will use these resource attributes to populate metric labels.
func MetricsFilter ¶
MetricsFilter returns a Component that filters metrics. polarity should be "include" or "exclude". matchType should be "strict" or "regexp".
func MetricsOTTLFilter ¶
MetricsOTTLFilter returns a Component that filters metrics using OTTL. OTTL can only be used as an exclude filter, any metrics or datapoints that match one of the provided queries are dropped. Example query: 'name == "jvm.memory.heap.used" and resource.attributes["elasticsearch.node.name"] == nil'
func MetricsTransform ¶
MetricsTransform returns a Component that performs the transformations specified as arguments.
func ModifyInstrumentationScope ¶
ModifyInstrumentationScope sets the instrumentation scope name and version fields which will later be exported to Cloud Monitoring metric labels. The name will always be prefixed with "agent.googleapis.com/".
func NormalizeSums ¶
func NormalizeSums() Component
NormalizeSums returns a Component that performs counter normalization.
func ResourceTransform ¶
ResourceTransform returns a Component that applies changes on resource attributes.
func Transform ¶
func Transform(statementType, context string, statements ottl.Statements) Component
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 ExporterType ¶
type ExporterType int
const ( // N.B. Every ExporterType increases the QPS and thus quota // consumption in consumer projects; think hard before adding // another exporter type. OTel ExporterType = iota System GMP )
func (ExporterType) Name ¶
func (t ExporterType) Name() string
type ModularConfig ¶
type ModularConfig struct { LogLevel string ReceiverPipelines map[string]ReceiverPipeline Pipelines map[string]Pipeline Exporters map[ExporterType]Component // Test-only options: // Don't generate any self-metrics DisableMetrics bool // Emit collector logs as JSON JSONLogs bool }
func (ModularConfig) Generate ¶
func (c ModularConfig) Generate(ctx context.Context) (string, error)
Generate an OT YAML config file for c. Each pipeline gets generated as a receiver, per-pipeline processors, global processors, and then global exporter. For example: metrics/mypipe:
receivers: [hostmetrics/mypipe] processors: [filter/mypipe_1, metrics_filter/mypipe_2, resourcedetection/_global_0] exporters: [googlecloud]
type Pipeline ¶
type Pipeline struct { // Type is "metrics" or "traces". Type string ReceiverPipelineName string Processors []Component }
Pipeline represents one (of potentially many) pipelines consuming data from a ReceiverPipeline.
type ReceiverPipeline ¶
type ReceiverPipeline struct { Receiver Component // Processors is a map with processors for each pipeline type ("metrics" or "traces"). // If a key is not in the map, the receiver pipeline will not be used for that pipeline type. Processors map[string][]Component // ExporterTypes indicates if the pipeline outputs special data (either Prometheus or system metrics) that need to be handled with a special exporter. ExporterTypes map[string]ExporterType // ResourceDetectionModes indicates whether the resource should be forcibly set, set only if not already present, or never set. // If a data type is not present, it will assume the zero value (Override). ResourceDetectionModes map[string]ResourceDetectionMode }
ReceiverPipeline represents a single OT receiver and zero or more processors that must be chained after that receiver.
type ResourceDetectionMode ¶
type ResourceDetectionMode int
const ( Override ResourceDetectionMode = iota SetIfMissing None )
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 ConvertFloatToInt ¶
func ConvertFloatToInt(metricName string) TransformQuery
ConvertFloatToInt returns an expression where a float-valued metric can be converted to an int
func ConvertGaugeToSum ¶
func ConvertGaugeToSum(metricName string) TransformQuery
ConvertGaugeToSum returns an expression where a gauge metric can be converted into a sum
func FlattenResourceAttribute ¶
func FlattenResourceAttribute(resourceAttribute, metricAttribute string) TransformQuery
FlattenResourceAttribute returns an expression that brings down a resource attribute to a metric attribute.
func RetainResource ¶
func RetainResource(resourceAttributeKeys ...string) TransformQuery
RetainResource retains the resource attributes provided, and drops all other attributes.
func SetAttribute ¶
func SetAttribute(metricName, attributeKey, attributeValue string) TransformQuery
func SetDescription ¶
func SetDescription(metricName, metricDescription string) TransformQuery
SetDescription returns a metrics transform expression where the metrics description will be set to what is provided
func SetName ¶
func SetName(oldName, newName string) TransformQuery
SetName returns a metrics transform expression where the metric name is set to provided value
func SetUnit ¶
func SetUnit(metricName, unit string) TransformQuery
SetUnit returns a metrics transform expression where the metric unit is set to provided value
func SummaryCountValToSum ¶
func SummaryCountValToSum(metricName, aggregation string, isMonotonic bool) TransformQuery
SummaryCountValToSum creates a new Sum metric out of a summary metric's count value. The new metric has a name of "<Old Name>_count".
func SummarySumValToSum ¶
func SummarySumValToSum(metricName, aggregation string, isMonotonic bool) TransformQuery
SummarySumValToSum creates a new Sum metric out of a summary metric's sum value. The new metric has a name of "<Old Name>_sum".