src/platform/packages/shared/kbn-edot-collector/README.md
EDOT Collector (Elastic Distribution of OpenTelemetry Collector) CLI tool for Kibana development.
This package provides a developer command to easily start an EDOT Collector instance in Gateway mode and connect it to your Elasticsearch cluster.
node scripts/edot_collector.js
This will:
config/kibana.dev.ymlkibana-edot-collector with the EDOT Collector running in Gateway modenode scripts/edot_collector.js --config config/<custom-kibana-config>.yml
If you need to use different ports (e.g., when running multiple collectors or when default ports are already in use):
node scripts/edot_collector.js --grpc-port 14317 --http-port 14318
You can override Elasticsearch connection settings using environment variables:
ELASTICSEARCH_HOST=https://my-cluster.es.cloud:443 \
ELASTICSEARCH_USERNAME=elastic \
ELASTICSEARCH_PASSWORD=secret \
node scripts/edot_collector.js
The command accepts the following CLI flags:
--config, -c: Path to Kibana config file (defaults to config/kibana.dev.yml)--grpc-port: Host port for gRPC endpoint (defaults to 4317)--http-port: Host port for HTTP endpoint (defaults to 4318)The EDOT Collector is configured to collect:
The collector exposes OTLP endpoints for application instrumentation:
http://localhost:4317 (default, customizable with --grpc-port)http://localhost:4318 (default, customizable with --http-port)Configure your OpenTelemetry SDKs to send data to these endpoints.
Create a new directory and initialize:
mkdir my-instrumented-app && cd my-instrumented-app
npm init -y
npm install express winston @opentelemetry/sdk-node @opentelemetry/auto-instrumentations-node @opentelemetry/exporter-trace-otlp-http @opentelemetry/exporter-logs-otlp-http @opentelemetry/instrumentation-winston @opentelemetry/winston-transport --save
Create server.js:
const { NodeSDK } = require('@opentelemetry/sdk-node');
const { getNodeAutoInstrumentations } = require('@opentelemetry/auto-instrumentations-node');
const { OTLPTraceExporter } = require('@opentelemetry/exporter-trace-otlp-http');
const { OTLPLogExporter } = require('@opentelemetry/exporter-logs-otlp-http');
const { WinstonInstrumentation } = require('@opentelemetry/instrumentation-winston');
const sdk = new NodeSDK({
serviceName: 'my-express-app',
traceExporter: new OTLPTraceExporter({ url: 'http://localhost:4318/v1/traces' }),
logExporter: new OTLPLogExporter({ url: 'http://localhost:4318/v1/logs' }),
instrumentations: [getNodeAutoInstrumentations(), new WinstonInstrumentation()],
});
sdk.start();
const express = require('express');
const winston = require('winston');
const { OpenTelemetryTransportV3 } = require('@opentelemetry/winston-transport');
// Create Winston logger with OpenTelemetry transport
const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [new winston.transports.Console(), new OpenTelemetryTransportV3()],
});
const app = express();
app.get('/', (req, res) => {
logger.info('Received request to /');
res.json({ message: 'Hello! Check Kibana for traces and logs.' });
});
app.listen(3000, () => {
logger.info('Server running on http://localhost:3000');
logger.info('Visit http://localhost:3000 to generate traces and logs');
});
Run the app:
node server.js
Visit http://localhost:3000 in your browser. You can now see the logs and traces of my-express-app in Kibana.
The command generates the following files in data/edot_collector/:
docker-compose.yaml - Docker Compose configurationotel-collector-config.yml - OpenTelemetry Collector configurationSecurity Note: These generated configuration files may contain non-default Elasticsearch credentials. The data/ directory is included in .gitignore to prevent accidental commits of sensitive information. As you're using this script, please ensure your credentials are not committed to version control.
If you see errors about ports already in use, you can specify alternative ports:
node scripts/edot_collector.js --grpc-port 14317 --http-port 14318
docker ps | grep kibana-edot-collectordocker logs kibana-edot-collector