feat(inputs.opentelemetry): Add configurable log record dimensions (#13846)
This commit is contained in:
parent
3bcf72293d
commit
c5aef4e3b9
16
go.mod
16
go.mod
|
|
@ -100,9 +100,9 @@ require (
|
|||
github.com/hashicorp/consul/api v1.24.0
|
||||
github.com/hashicorp/go-uuid v1.0.3
|
||||
github.com/influxdata/go-syslog/v3 v3.0.0
|
||||
github.com/influxdata/influxdb-observability/common v0.5.2
|
||||
github.com/influxdata/influxdb-observability/influx2otel v0.5.0
|
||||
github.com/influxdata/influxdb-observability/otel2influx v0.0.0-20230705233630-3cfabd1d00b9
|
||||
github.com/influxdata/influxdb-observability/common v0.5.6
|
||||
github.com/influxdata/influxdb-observability/influx2otel v0.5.6
|
||||
github.com/influxdata/influxdb-observability/otel2influx v0.5.6
|
||||
github.com/influxdata/line-protocol/v2 v2.2.1
|
||||
github.com/influxdata/tail v1.0.1-0.20210707231403-b283181d1fa7
|
||||
github.com/influxdata/toml v0.0.0-20190415235208-270119a8ce65
|
||||
|
|
@ -184,7 +184,7 @@ require (
|
|||
github.com/xdg/scram v1.0.5
|
||||
github.com/yuin/goldmark v1.5.4
|
||||
go.mongodb.org/mongo-driver v1.12.1
|
||||
go.opentelemetry.io/collector/pdata v1.0.0-rcv0013
|
||||
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.39.0
|
||||
go.opentelemetry.io/otel/sdk/metric v0.39.0
|
||||
go.starlark.net v0.0.0-20220328144851-d1966c6b9fcd
|
||||
|
|
@ -335,7 +335,7 @@ require (
|
|||
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/golang-lru v0.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru v1.0.2 // indirect
|
||||
github.com/hashicorp/packer-plugin-sdk v0.3.2 // indirect
|
||||
github.com/hashicorp/serf v0.10.1 // indirect
|
||||
github.com/huandu/xstrings v1.3.3 // indirect
|
||||
|
|
@ -391,7 +391,7 @@ require (
|
|||
github.com/nats-io/jwt/v2 v2.3.0 // indirect
|
||||
github.com/nats-io/nkeys v0.4.4 // indirect
|
||||
github.com/nats-io/nuid v1.0.1 // indirect
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.79.0 // indirect
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.84.0 // indirect
|
||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||
github.com/opencontainers/image-spec v1.1.0-rc4 // indirect
|
||||
github.com/opencontainers/runc v1.1.5 // indirect
|
||||
|
|
@ -444,8 +444,8 @@ require (
|
|||
github.com/zeebo/xxh3 v1.0.2 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.4 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.opentelemetry.io/collector/consumer v0.81.0 // indirect
|
||||
go.opentelemetry.io/collector/semconv v0.81.0 // indirect
|
||||
go.opentelemetry.io/collector/consumer v0.84.0 // indirect
|
||||
go.opentelemetry.io/collector/semconv v0.84.0 // indirect
|
||||
go.opentelemetry.io/otel v1.16.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.16.0 // indirect
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.39.0 // indirect
|
||||
|
|
|
|||
40
go.sum
40
go.sum
|
|
@ -797,8 +797,8 @@ github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09
|
|||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.6.0 h1:uL2shRDx7RTrOrTCUZEGP/wJUFiUI8QT6E7z5o8jga4=
|
||||
github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c=
|
||||
github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
|
||||
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
|
||||
|
|
@ -820,12 +820,12 @@ github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+h
|
|||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/go-syslog/v3 v3.0.0 h1:jichmjSZlYK0VMmlz+k4WeOQd7z745YLsvGMqwtYt4I=
|
||||
github.com/influxdata/go-syslog/v3 v3.0.0/go.mod h1:tulsOp+CecTAYC27u9miMgq21GqXRW6VdKbOG+QSP4Q=
|
||||
github.com/influxdata/influxdb-observability/common v0.5.2 h1:n4/w+cu+Puva0tEodnrb1Rtb50eEzncdwBYsGYk+bXA=
|
||||
github.com/influxdata/influxdb-observability/common v0.5.2/go.mod h1:4iLh+a678292K5J4pMh8wf2ZplteKfyGCfjHevgiUl0=
|
||||
github.com/influxdata/influxdb-observability/influx2otel v0.5.0 h1:+Boa8sos34aoaPJh+Rqrb6WYmewTD7dorjsGocOB/KY=
|
||||
github.com/influxdata/influxdb-observability/influx2otel v0.5.0/go.mod h1:ALf1LF/Q8UKvKSZzF+Te6QwXPLbV3FlVnV6sGmiK99w=
|
||||
github.com/influxdata/influxdb-observability/otel2influx v0.0.0-20230705233630-3cfabd1d00b9 h1:IAzPIfEMeB21gyiwzon2k1GZN6qbSa/ia784i1MfHP8=
|
||||
github.com/influxdata/influxdb-observability/otel2influx v0.0.0-20230705233630-3cfabd1d00b9/go.mod h1:XpkvWmFSE1OkYUAI70+wXaZKGrwFh0zEUg63V0tB4aU=
|
||||
github.com/influxdata/influxdb-observability/common v0.5.6 h1:Y0vpIzhHh0k9OH9VTo2gagYW18bSUR3uZqJgY6Nvii0=
|
||||
github.com/influxdata/influxdb-observability/common v0.5.6/go.mod h1:ek93NDR7It6j7226Ei04ynhX2jG4wqiPK5NHChxoBdo=
|
||||
github.com/influxdata/influxdb-observability/influx2otel v0.5.6 h1:uA4eKA4FX2xFQ9bkWxKFq6y29jcw0YMVRQykmJc2+bg=
|
||||
github.com/influxdata/influxdb-observability/influx2otel v0.5.6/go.mod h1:9gAv3JTcOmUM2x/Ld6YzOG5OgO1mdXoWn1iVJV2Qbsk=
|
||||
github.com/influxdata/influxdb-observability/otel2influx v0.5.6 h1:nxBxrlOzHFLDojzM73+0d6s1cgDqOGx7GzhSDkzExF8=
|
||||
github.com/influxdata/influxdb-observability/otel2influx v0.5.6/go.mod h1:t8ifGgI5WgEzZ5q+klda+B2UrPykvFsk088hE3mPqL8=
|
||||
github.com/influxdata/line-protocol-corpus v0.0.0-20210519164801-ca6fa5da0184/go.mod h1:03nmhxzZ7Xk2pdG+lmMd7mHDfeVOYFyhOgwO61qWU98=
|
||||
github.com/influxdata/line-protocol-corpus v0.0.0-20210922080147-aa28ccfb8937 h1:MHJNQ+p99hFATQm6ORoLmpUCF7ovjwEFshs/NHzAbig=
|
||||
github.com/influxdata/line-protocol-corpus v0.0.0-20210922080147-aa28ccfb8937/go.mod h1:BKR9c0uHSmRgM/se9JhFHtTT7JTO67X23MtKMHtZcpo=
|
||||
|
|
@ -1202,10 +1202,10 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
|
|||
github.com/onsi/gomega v1.15.0/go.mod h1:cIuvLEne0aoVhAgh/O6ac0Op8WWw9H6eYCriF+tEHG0=
|
||||
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
|
||||
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.79.0 h1:YtkbJjknfMJ4UKXdaUBTw37QLxYXuVMmozqPFTM0XPI=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.79.0/go.mod h1:BFqnTfM5Neh5A5gYtsxh2615yp/t39vUj7oRUcjevFU=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.79.0 h1:Cao5mD7NFJsMLM40lisqJ4Iy3+v+JOq+8cR79/Uki94=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.79.0/go.mod h1:/wfeJfzu3oAkC2boitFR3dZcnwNtwzryI/SW1LIhDLo=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.84.0 h1:NXzx/YViPbapdfI0RZ2RJk4XgKU099Ci9rGBsZ/div8=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatatest v0.84.0/go.mod h1:t7+PIcvZwI9599uzwRVpJbJBUbOLBmvs0cIVse8djaA=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.84.0 h1:Zuk1i/92HvV5cI6dtsG/VWSKwaLGh17q9a26qP9DBbo=
|
||||
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.84.0/go.mod h1:WoSzL9NAVwvEy1lMwM2utn68g0Khoxm591WliToPnDQ=
|
||||
github.com/openconfig/gnmi v0.0.0-20200414194230-1597cc0f2600/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A=
|
||||
github.com/openconfig/gnmi v0.0.0-20200508230933-d19cebf5e7be/go.mod h1:M/EcuapNQgvzxo1DDXHK4tx3QpYM/uG4l591v33jG2A=
|
||||
github.com/openconfig/gnmi v0.0.0-20220503232738-6eb133c65a13/go.mod h1:h365Ifq35G6kLZDQlRvrccTt2LKK90VpjZLMNGxJRYc=
|
||||
|
|
@ -1553,14 +1553,14 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
|||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||
go.opentelemetry.io/collector v0.81.0 h1:pF+sB8xNXlg/W0a0QTLz4mUWyool1a9toVj8LmLoFqg=
|
||||
go.opentelemetry.io/collector v0.81.0/go.mod h1:thuOTBMusXwcTPTwLbs3zwwCOLaaQX2g+Hjf8OObc/w=
|
||||
go.opentelemetry.io/collector/consumer v0.81.0 h1:8R2iCrSzD7T0RtC2Wh4GXxDiqla2vNhDokGW6Bcrfas=
|
||||
go.opentelemetry.io/collector/consumer v0.81.0/go.mod h1:jS7+gAKdOx3lD3SnaBztBjUVpUYL3ee7fpoqI4p/gT8=
|
||||
go.opentelemetry.io/collector/pdata v1.0.0-rcv0013 h1:4sONXE9hAX+4Di8m0bQ/KaoH3Mi+OPt04cXkZ7A8W3k=
|
||||
go.opentelemetry.io/collector/pdata v1.0.0-rcv0013/go.mod h1:x09G/4KjEcDKNuWCjC5ZtnuDE0XEqiRwI+yrHSVjIy8=
|
||||
go.opentelemetry.io/collector/semconv v0.81.0 h1:lCYNNo3powDvFIaTPP2jDKIrBiV1T92NK4QgL/aHYXw=
|
||||
go.opentelemetry.io/collector/semconv v0.81.0/go.mod h1:TlYPtzvsXyHOgr5eATi43qEMqwSmIziivJB2uctKswo=
|
||||
go.opentelemetry.io/collector v0.84.0 h1:zzsegdPlDR0iJufPsHTJhXkv9q2kbpTTTI6nTyya2wA=
|
||||
go.opentelemetry.io/collector v0.84.0/go.mod h1:+cv/zxludfiiDuK3z+5eXkxAJhkCCcy8Chtvv0nOlr0=
|
||||
go.opentelemetry.io/collector/consumer v0.84.0 h1:sz8mXIdPACJArlRyFNXA1SScVoo954IU1qp9V78VUxc=
|
||||
go.opentelemetry.io/collector/consumer v0.84.0/go.mod h1:Mu+KeuorwHHWd6iGxU7DMAhgsHZmmzmQgf3sSWkugmM=
|
||||
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 h1:iT5qH0NLmkGeIdDtnBogYDx7L58t6CaWGL378DEo2QY=
|
||||
go.opentelemetry.io/collector/pdata v1.0.0-rcv0014/go.mod h1:BRvDrx43kiSoUx3mr7SoA7h9B8+OY99mUK+CZSQFWW4=
|
||||
go.opentelemetry.io/collector/semconv v0.84.0 h1:sI1B8ebHhfJPd87iyba66TDnluVFvYu8CEpSjKHqIDc=
|
||||
go.opentelemetry.io/collector/semconv v0.84.0/go.mod h1:j/8THcqVxFna1FpvA2zYIsUperEtOaRaqoLYIN4doWw=
|
||||
go.opentelemetry.io/otel v0.7.0/go.mod h1:aZMyHG5TqDOXEgH2tyLiXSUKly1jT3yqE9PmrzIeCdo=
|
||||
go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s=
|
||||
go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4=
|
||||
|
|
|
|||
|
|
@ -46,6 +46,18 @@ See the [CONFIGURATION.md][CONFIGURATION.md] for more details.
|
|||
## - https://github.com/open-telemetry/opentelemetry-collector/tree/main/semconv
|
||||
# span_dimensions = ["service.name", "span.name"]
|
||||
|
||||
## Override the default log record attributes to be used as line protocol tags.
|
||||
## These are always included as tags, if available:
|
||||
## - trace ID
|
||||
## - span ID
|
||||
## The default values:
|
||||
## - service.name
|
||||
## Other common attributes can be found here:
|
||||
## - https://github.com/open-telemetry/opentelemetry-collector/tree/main/semconv
|
||||
## When using InfluxDB for both logs and traces, be certain that log_record_dimensions
|
||||
## matches the span_dimensions value.
|
||||
# log_record_dimensions = ["service.name"]
|
||||
|
||||
## Override the default (prometheus-v1) metrics schema.
|
||||
## Supports: "prometheus-v1", "prometheus-v2"
|
||||
## For more information about the alternatives, read the Prometheus input
|
||||
|
|
|
|||
|
|
@ -80,10 +80,11 @@ type logsService struct {
|
|||
|
||||
var _ plogotlp.GRPCServer = (*logsService)(nil)
|
||||
|
||||
func newLogsService(logger common.Logger, writer *writeToAccumulator) (*logsService, error) {
|
||||
func newLogsService(logger common.Logger, writer *writeToAccumulator, logRecordDimensions []string) (*logsService, error) {
|
||||
expConfig := otel2influx.DefaultOtelLogsToLineProtocolConfig()
|
||||
expConfig.Logger = logger
|
||||
expConfig.Writer = writer
|
||||
expConfig.LogRecordDimensions = logRecordDimensions
|
||||
exp, err := otel2influx.NewOtelLogsToLineProtocol(expConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -25,9 +25,10 @@ import (
|
|||
var sampleConfig string
|
||||
|
||||
type OpenTelemetry struct {
|
||||
ServiceAddress string `toml:"service_address"`
|
||||
SpanDimensions []string `toml:"span_dimensions"`
|
||||
MetricsSchema string `toml:"metrics_schema"`
|
||||
ServiceAddress string `toml:"service_address"`
|
||||
SpanDimensions []string `toml:"span_dimensions"`
|
||||
LogRecordDimensions []string `toml:"log_record_dimensions"`
|
||||
MetricsSchema string `toml:"metrics_schema"`
|
||||
|
||||
tls.ServerConfig
|
||||
Timeout config.Duration `toml:"timeout"`
|
||||
|
|
@ -73,7 +74,7 @@ func (o *OpenTelemetry) Start(accumulator telegraf.Accumulator) error {
|
|||
return err
|
||||
}
|
||||
pmetricotlp.RegisterGRPCServer(o.grpcServer, metricsSvc)
|
||||
logsSvc, err := newLogsService(logger, influxWriter)
|
||||
logsSvc, err := newLogsService(logger, influxWriter, o.LogRecordDimensions)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -108,10 +109,11 @@ func (o *OpenTelemetry) Stop() {
|
|||
func init() {
|
||||
inputs.Add("opentelemetry", func() telegraf.Input {
|
||||
return &OpenTelemetry{
|
||||
ServiceAddress: "0.0.0.0:4317",
|
||||
SpanDimensions: otel2influx.DefaultOtelTracesToLineProtocolConfig().SpanDimensions,
|
||||
MetricsSchema: "prometheus-v1",
|
||||
Timeout: config.Duration(5 * time.Second),
|
||||
ServiceAddress: "0.0.0.0:4317",
|
||||
SpanDimensions: otel2influx.DefaultOtelTracesToLineProtocolConfig().SpanDimensions,
|
||||
LogRecordDimensions: otel2influx.DefaultOtelLogsToLineProtocolConfig().LogRecordDimensions,
|
||||
MetricsSchema: "prometheus-v1",
|
||||
Timeout: config.Duration(5 * time.Second),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,18 @@
|
|||
## - https://github.com/open-telemetry/opentelemetry-collector/tree/main/semconv
|
||||
# span_dimensions = ["service.name", "span.name"]
|
||||
|
||||
## Override the default log record attributes to be used as line protocol tags.
|
||||
## These are always included as tags, if available:
|
||||
## - trace ID
|
||||
## - span ID
|
||||
## The default values:
|
||||
## - service.name
|
||||
## Other common attributes can be found here:
|
||||
## - https://github.com/open-telemetry/opentelemetry-collector/tree/main/semconv
|
||||
## When using InfluxDB for both logs and traces, be certain that log_record_dimensions
|
||||
## matches the span_dimensions value.
|
||||
# log_record_dimensions = ["service.name"]
|
||||
|
||||
## Override the default (prometheus-v1) metrics schema.
|
||||
## Supports: "prometheus-v1", "prometheus-v2"
|
||||
## For more information about the alternatives, read the Prometheus input
|
||||
|
|
|
|||
Loading…
Reference in New Issue