Skip to content

Commit 0e868f4

Browse files
authored
[com.influxdata.telegraf] Add OpenTelemetry Output plugin (#66)
1 parent 6edcf46 commit 0e868f4

File tree

5 files changed

+154
-1
lines changed

5 files changed

+154
-1
lines changed

packages/com.influxdata.telegraf/PklProject

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ dependencies {
2222
}
2323

2424
package {
25-
version = "1.1.1"
25+
version = "1.2.0"
2626
}

packages/com.influxdata.telegraf/Telegraf.pkl

+7
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import "plugins/inputs/SolrInput.pkl"
5252
import "plugins/outputs/FileOutput.pkl"
5353
import "plugins/outputs/DiscardOutput.pkl"
5454
import "plugins/outputs/PrometheusClientOutput.pkl"
55+
import "plugins/outputs/OpenTelemetryOutput.pkl"
5556
import "plugins/processors/StarlarkProcessor.pkl"
5657

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

91+
/// This plugin starts a [Prometheus](https://prometheus.io) Client.
92+
///
93+
/// Tt exposes all metrics on `/metrics` (default) to be polled by a Prometheus server.
9094
prometheus_client: Listing<PrometheusClientOutput>?
95+
96+
/// This plugin sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC.
97+
opentelemetry: Listing<OpenTelemetryOutput>?
9198
}
9299

93100
open class Inputs {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
amends "../Telegraf.pkl"
17+
18+
outputs {
19+
opentelemetry {
20+
new {
21+
service_address = "localhost:4312"
22+
timeout = 10.s
23+
tls_ca = "/path/to/ca/cert"
24+
tls_cert = "/path/to/cert"
25+
tls_key = "/path/to/key"
26+
tls_server_name = "tls-server.com"
27+
compression = "gzip"
28+
coralogix {
29+
application = "myapp"
30+
private_key = "my secret value"
31+
subsystem = "my subsystem"
32+
}
33+
attributes {
34+
["service.name"] = "foo"
35+
["service.version"] = "1.0.0"
36+
}
37+
headers {
38+
["x-api-key"] = "my-api-key"
39+
}
40+
}
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//===----------------------------------------------------------------------===//
2+
// Copyright © 2024 Apple Inc. and the Pkl project authors. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// https://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//===----------------------------------------------------------------------===//
16+
/// Sends metrics to [OpenTelemetry](https://opentelemetry.io) servers and agents via gRPC.
17+
///
18+
/// <https://github.com/influxdata/telegraf/tree/master/plugins/outputs/opentelemetry>
19+
@ModuleInfo { minPklVersion = "0.24.0" }
20+
open module com.influxdata.telegraf.plugins.outputs.OpenTelemetryOutput
21+
22+
extends "Output.pkl"
23+
24+
/// The endpoint to which the metrics will be sent.
25+
///
26+
/// Default: `"localhost:4317"`
27+
service_address: String?
28+
29+
/// The timeout for the connection.
30+
///
31+
/// Default: `5.s`
32+
timeout: Duration?
33+
34+
/// Optional TLS Config.
35+
/// All variables should specify full path to the file.
36+
/// Root certificates for verifying server certificates encoded in PEM format.
37+
tls_ca: String?
38+
39+
/// Path to the TLS certificate for the client encoded in PEM format.
40+
/// May contain intermediate certificates.
41+
tls_cert: String?
42+
43+
/// Path to the TLS private key for the client encoded in PEM format.
44+
tls_key: String?
45+
46+
/// Send the specified TLS server name via SNI.
47+
tls_server_name: String?
48+
49+
/// Insecure option to skip TLS server cert verification.
50+
///
51+
/// Warning: it is insecure to enable this option.
52+
/// If enabled, crypto/tls accepts any certificate presented by the server and any host name in that certificate.
53+
///
54+
/// Default: `false`
55+
insecure_skip_verify: Boolean?
56+
57+
/// Send data to a [Coralogix](https://coralogix.com) server.
58+
coralogix: Coralogix?
59+
60+
/// Set the compression method used to send data.
61+
///
62+
/// Default: `"none"`
63+
compression: ("none"|"gzip")?
64+
65+
/// Additional OpenTelemetry resource attributes
66+
attributes: Mapping<String,String>?
67+
68+
/// Additional gRPC request metadata headers
69+
headers: Mapping<String,String>?
70+
71+
class Coralogix {
72+
/// The private key, which can be found in Settings > Send Your Data.
73+
private_key: String
74+
75+
/// The application name, which will be added to metric attributes.
76+
application: String
77+
78+
/// The subsystem name, which will be added to metric attributes.
79+
subsystem: String
80+
}

packages/com.influxdata.telegraf/tests/Telegraf.pkl-expected.pcf

+24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
examples {
2+
["opentelemetry-output.toml"] {
3+
"""
4+
[[outputs.opentelemetry]]
5+
service_address = "localhost:4312"
6+
timeout = "10s"
7+
tls_ca = "/path/to/ca/cert"
8+
tls_cert = "/path/to/cert"
9+
tls_key = "/path/to/key"
10+
tls_server_name = "tls-server.com"
11+
compression = "gzip"
12+
13+
[outputs.opentelemetry.coralogix]
14+
private_key = "my secret value"
15+
application = "myapp"
16+
subsystem = "my subsystem"
17+
18+
[outputs.opentelemetry.attributes]
19+
"service.name" = "foo"
20+
"service.version" = "1.0.0"
21+
22+
[outputs.opentelemetry.headers]
23+
x-api-key = "my-api-key"
24+
"""
25+
}
226
["simple.toml"] {
327
"""
428
[[outputs.file]]

0 commit comments

Comments
 (0)