Skip to content

Commit

Permalink
Enable OTEL_EXPORTER_OTLP_ENDPOINT env var
Browse files Browse the repository at this point in the history
  • Loading branch information
crespocarlos committed Jul 14, 2022
1 parent 5c409c4 commit 34f19d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring_collection/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ monitoring_collection.opentelemetry.metrics:
Authorization: "Bearer SECRET_TOKEN"
```

Alternatively, OTLP Exporter can be configured using environment variables `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT`, `OTEL_EXPORTER_OTLP_METRICS_HEADERS`. [See OTLP Exporter docs](https://opentelemetry.io/docs/reference/specification/protocol/exporter/) for details.
Alternatively, OTLP Exporter can be configured using environment variables `OTEL_EXPORTER_OTLP_ENDPOINT`, `OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` and `OTEL_EXPORTER_OTLP_METRICS_HEADERS`. [See OTLP Exporter docs](https://opentelemetry.io/docs/reference/specification/protocol/exporter/) for details.

It's possible to configure logging for the OTLP integration. If not informed, the default will be `info`

Expand Down
7 changes: 5 additions & 2 deletions x-pack/plugins/monitoring_collection/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,15 @@ export class MonitoringCollectionPlugin implements Plugin<MonitoringCollectionSe
metrics.setGlobalMeterProvider(meterProvider);

const otlpConfig = this.config.opentelemetry?.metrics.otlp;
const url = otlpConfig?.url ?? process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT;
const url =
otlpConfig?.url ??
process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT ??
process.env.OTEL_EXPORTER_OTLP_ENDPOINT;
if (url) {
// Add OTLP exporter
// Set Authorization headers
// OTLPMetricExporter internally will look at OTEL_EXPORTER_OTLP_METRICS_HEADERS env variable
// if `headers` are not present in the kibana config file
// if `headers` is not present in the kibana config file
const metadata = new grpc.Metadata();
if (otlpConfig.headers) {
for (const [key, value] of Object.entries(otlpConfig.headers)) {
Expand Down

0 comments on commit 34f19d5

Please sign in to comment.