feat: add coralogix dialect to opentelemetry (#11622)
This commit is contained in:
parent
7bd9c91ebe
commit
ce2053d26d
|
|
@ -32,6 +32,17 @@ and agents via gRPC.
|
|||
## Supports: "gzip", "none"
|
||||
# compression = "gzip"
|
||||
|
||||
## Configuration options for the Coralogix dialect
|
||||
## Enable the following section of you use this plugin with a Coralogix endpoint
|
||||
# [outputs.opentelemetry.coralogix]
|
||||
# ## Your Coralogix private key (required).
|
||||
# ## Please note that this is sensitive data!
|
||||
# private_key = "your_coralogix_key"
|
||||
#
|
||||
# ## Application and subsystem names for the metrics (required)
|
||||
# application = "$NAMESPACE"
|
||||
# subsystem = "$HOSTNAME"
|
||||
|
||||
## Additional OpenTelemetry resource attributes
|
||||
# [outputs.opentelemetry.attributes]
|
||||
# "service.name" = "demo"
|
||||
|
|
@ -41,6 +52,23 @@ and agents via gRPC.
|
|||
# key1 = "value1"
|
||||
```
|
||||
|
||||
## Supported dialects
|
||||
|
||||
### Coralogix
|
||||
|
||||
This plugins supports sending data to a [Coralogix](https://coralogix.com)
|
||||
server by enabling the corresponding dialect by uncommenting
|
||||
the `[output.opentelemetry.coralogix]` section.
|
||||
|
||||
There, you can find the required setting to interact with the server.
|
||||
|
||||
- The `private_key` is your Private Key, which you can find in Settings > Send Your Data.
|
||||
- The `application`, is your application name, which will be added to your metric attributes.
|
||||
- The `subsystem`, is your subsystem, which will be added to your metric attributes.
|
||||
|
||||
More information in the
|
||||
[Getting Started page](https://coralogix.com/docs/guide-first-steps-coralogix/).
|
||||
|
||||
### Schema
|
||||
|
||||
The InfluxDB->OpenTelemetry conversion [schema][] and [implementation][] are
|
||||
|
|
|
|||
|
|
@ -4,8 +4,12 @@ package opentelemetry
|
|||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
ntls "crypto/tls"
|
||||
|
||||
"github.com/influxdata/influxdb-observability/common"
|
||||
"github.com/influxdata/influxdb-observability/influx2otel"
|
||||
"go.opentelemetry.io/collector/pdata/pmetric/pmetricotlp"
|
||||
|
|
@ -23,6 +27,8 @@ import (
|
|||
"github.com/influxdata/telegraf/plugins/outputs"
|
||||
)
|
||||
|
||||
var userAgent = fmt.Sprintf("telegraf (%s/%s)", runtime.GOOS, runtime.GOARCH)
|
||||
|
||||
// DO NOT REMOVE THE NEXT TWO LINES! This is required to embed the sampleConfig data.
|
||||
//go:embed sample.conf
|
||||
var sampleConfig string
|
||||
|
|
@ -35,6 +41,7 @@ type OpenTelemetry struct {
|
|||
Compression string `toml:"compression"`
|
||||
Headers map[string]string `toml:"headers"`
|
||||
Attributes map[string]string `toml:"attributes"`
|
||||
Coralogix *CoralogixConfig `toml:"coralogix"`
|
||||
|
||||
Log telegraf.Logger `toml:"-"`
|
||||
|
||||
|
|
@ -44,6 +51,12 @@ type OpenTelemetry struct {
|
|||
callOptions []grpc.CallOption
|
||||
}
|
||||
|
||||
type CoralogixConfig struct {
|
||||
AppName string `toml:"application"`
|
||||
SubSystem string `toml:"subsystem"`
|
||||
PrivateKey string `toml:"private_key"`
|
||||
}
|
||||
|
||||
func (*OpenTelemetry) SampleConfig() string {
|
||||
return sampleConfig
|
||||
}
|
||||
|
|
@ -60,6 +73,14 @@ func (o *OpenTelemetry) Connect() error {
|
|||
if o.Compression == "" {
|
||||
o.Compression = defaultCompression
|
||||
}
|
||||
if o.Coralogix != nil {
|
||||
if o.Headers == nil {
|
||||
o.Headers = make(map[string]string)
|
||||
}
|
||||
o.Headers["ApplicationName"] = o.Coralogix.AppName
|
||||
o.Headers["ApiName"] = o.Coralogix.SubSystem
|
||||
o.Headers["Authorization"] = "Bearer " + o.Coralogix.PrivateKey
|
||||
}
|
||||
|
||||
metricsConverter, err := influx2otel.NewLineProtocolToOtelMetrics(logger)
|
||||
if err != nil {
|
||||
|
|
@ -71,11 +92,14 @@ func (o *OpenTelemetry) Connect() error {
|
|||
return err
|
||||
} else if tlsConfig != nil {
|
||||
grpcTLSDialOption = grpc.WithTransportCredentials(credentials.NewTLS(tlsConfig))
|
||||
} else if o.Coralogix != nil {
|
||||
// For coralogix, we enforce GRPC connection with TLS
|
||||
grpcTLSDialOption = grpc.WithTransportCredentials(credentials.NewTLS(&ntls.Config{}))
|
||||
} else {
|
||||
grpcTLSDialOption = grpc.WithTransportCredentials(insecure.NewCredentials())
|
||||
}
|
||||
|
||||
grpcClientConn, err := grpc.Dial(o.ServiceAddress, grpcTLSDialOption)
|
||||
grpcClientConn, err := grpc.Dial(o.ServiceAddress, grpcTLSDialOption, grpc.WithUserAgent(userAgent))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,17 @@
|
|||
## Supports: "gzip", "none"
|
||||
# compression = "gzip"
|
||||
|
||||
## Configuration options for the Coralogix dialect
|
||||
## Enable the following section of you use this plugin with a Coralogix endpoint
|
||||
# [outputs.opentelemetry.coralogix]
|
||||
# ## Your Coralogix private key (required).
|
||||
# ## Please note that this is sensitive data!
|
||||
# private_key = "your_coralogix_key"
|
||||
#
|
||||
# ## Application and subsystem names for the metrics (required)
|
||||
# application = "$NAMESPACE"
|
||||
# subsystem = "$HOSTNAME"
|
||||
|
||||
## Additional OpenTelemetry resource attributes
|
||||
# [outputs.opentelemetry.attributes]
|
||||
# "service.name" = "demo"
|
||||
|
|
|
|||
Loading…
Reference in New Issue