Skip to content

Commit

Permalink
[com.influxdata.telegraf] Add OpenTelemetry Output plugin (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
bioball authored Jun 27, 2024
1 parent 6edcf46 commit 0e868f4
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/com.influxdata.telegraf/PklProject
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ dependencies {
}

package {
version = "1.1.1"
version = "1.2.0"
}
7 changes: 7 additions & 0 deletions packages/com.influxdata.telegraf/Telegraf.pkl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import "plugins/inputs/SolrInput.pkl"
import "plugins/outputs/FileOutput.pkl"
import "plugins/outputs/DiscardOutput.pkl"
import "plugins/outputs/PrometheusClientOutput.pkl"
import "plugins/outputs/OpenTelemetryOutput.pkl"
import "plugins/processors/StarlarkProcessor.pkl"

import "plugins/Plugin.pkl"
Expand Down Expand Up @@ -87,7 +88,13 @@ open class Outputs {
/// It is only meant to be used for testing purposes.
discard: Listing<DiscardOutput>?

/// This plugin starts a [Prometheus](https://prometheus.io) Client.
///
/// Tt exposes all metrics on `/metrics` (default) to be polled by a Prometheus server.
prometheus_client: Listing<PrometheusClientOutput>?

/// This plugin sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC.
opentelemetry: Listing<OpenTelemetryOutput>?
}

open class Inputs {
Expand Down
42 changes: 42 additions & 0 deletions packages/com.influxdata.telegraf/examples/opentelemetry-output.pkl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//
amends "../Telegraf.pkl"

outputs {
opentelemetry {
new {
service_address = "localhost:4312"
timeout = 10.s
tls_ca = "/path/to/ca/cert"
tls_cert = "/path/to/cert"
tls_key = "/path/to/key"
tls_server_name = "tls-server.com"
compression = "gzip"
coralogix {
application = "myapp"
private_key = "my secret value"
subsystem = "my subsystem"
}
attributes {
["service.name"] = "foo"
["service.version"] = "1.0.0"
}
headers {
["x-api-key"] = "my-api-key"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
//===----------------------------------------------------------------------===//
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//===----------------------------------------------------------------------===//
/// Sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC.
///
/// <https://github.com/influxdata/telegraf/tree/master/plugins/outputs/opentelemetry>
@ModuleInfo { minPklVersion = "0.24.0" }
open module com.influxdata.telegraf.plugins.outputs.OpenTelemetryOutput

extends "Output.pkl"

/// The endpoint to which the metrics will be sent.
///
/// Default: `"localhost:4317"`
service_address: String?

/// The timeout for the connection.
///
/// Default: `5.s`
timeout: Duration?

/// Optional TLS Config.
/// All variables should specify full path to the file.
/// Root certificates for verifying server certificates encoded in PEM format.
tls_ca: String?

/// Path to the TLS certificate for the client encoded in PEM format.
/// May contain intermediate certificates.
tls_cert: String?

/// Path to the TLS private key for the client encoded in PEM format.
tls_key: String?

/// Send the specified TLS server name via SNI.
tls_server_name: String?

/// Insecure option to skip TLS server cert verification.
///
/// Warning: it is insecure to enable this option.
/// If enabled, crypto/tls accepts any certificate presented by the server and any host name in that certificate.
///
/// Default: `false`
insecure_skip_verify: Boolean?

/// Send data to a [Coralogix](https://coralogix.com) server.
coralogix: Coralogix?

/// Set the compression method used to send data.
///
/// Default: `"none"`
compression: ("none"|"gzip")?

/// Additional OpenTelemetry resource attributes
attributes: Mapping<String,String>?

/// Additional gRPC request metadata headers
headers: Mapping<String,String>?

class Coralogix {
/// The private key, which can be found in Settings > Send Your Data.
private_key: String

/// The application name, which will be added to metric attributes.
application: String

/// The subsystem name, which will be added to metric attributes.
subsystem: String
}
24 changes: 24 additions & 0 deletions packages/com.influxdata.telegraf/tests/Telegraf.pkl-expected.pcf
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
examples {
["opentelemetry-output.toml"] {
"""
[[outputs.opentelemetry]]
service_address = "localhost:4312"
timeout = "10s"
tls_ca = "/path/to/ca/cert"
tls_cert = "/path/to/cert"
tls_key = "/path/to/key"
tls_server_name = "tls-server.com"
compression = "gzip"

[outputs.opentelemetry.coralogix]
private_key = "my secret value"
application = "myapp"
subsystem = "my subsystem"

[outputs.opentelemetry.attributes]
"service.name" = "foo"
"service.version" = "1.0.0"

[outputs.opentelemetry.headers]
x-api-key = "my-api-key"
"""
}
["simple.toml"] {
"""
[[outputs.file]]
Expand Down

0 comments on commit 0e868f4

Please sign in to comment.