Local Quick Setup of Kibana Integrated with OpenTelemetry for Distributed Log Tracing
This article demonstrates the deployment of components on a Windows 11 system (excluding Fleet). The versions of Elasticsearch and Kibana used are both the latest version, 8.13.0.
Note: The Elastic OpenTelemetry Collector Exporter was deprecated in version 7.13, and was replaced by native support for OpenTelemetry Line Protocol within Elastic Observability (OTLP). This resulted in some differences in configuration options. Please refer to the official documentation for specific versions.
Step 1: Deploy Elasticsearch
Before starting Elasticsearch, run the command to set passwords for each component. Kibana requires a username and password to connect to Elasticsearch, otherwise it may crash.
.\bin\elasticsearch-setup-passwords.bat interactive
It’s recommended to run the startup script in PowerShell as a terminal, so you can see error logs.
There is no need to make any other changes to the elasticsearch.yml
configuration file in the config directory.
Start Elasticsearch by entering .\bin\elasticsearch.bat
, and you can check if it started successfully by visiting http://localhost:9200
.
Step 2: Deploy Kibana
Before starting Kibana, modify the password for Elasticsearch in the configuration file:
codeelasticsearch.username: "kibana_system"
elasticsearch.password: "password"
Enter the command .\bin\kibana.bat
to start Kibana. You can now access the Kibana interface via http://127.0.0.1:5601
.
Step 3: Deploy APM Server
First, add the APM integration in Kibana: Add integrations > Elastic APM
, and follow the prompts.
Install APM server using .\install-service.ps1
. If you encounter permission issues, try:
PowerShell.exe -ExecutionPolicy UnRestricted -File .\install-service.ps1
Configure the apm-server.yml
file:
apm-server:
host: "127.0.0.1:8200"
output.elasticsearch:
hosts: ["localhost:9200"]
username: "elastic"
password: "password"
Run ./apm-server -e
to start APM server, where -e
displays running logs.
You can also check if APM started successfully in the APM Server status section in Kibana.
Step 4: Integrate APM Agent and OpenTelemetry into Java Projects
Simply download elastic-apm-agent-1.48.1.jar
and opentelemetry-javaagent-1.28.0.jar
locally, and add the following VM options:
-javaagent:path/to/opentelemetry-javaagent-1.28.0.jar
-Dotel.traces.exporter=otlp
-Dotel.exporter.otlp.endpoint=http://127.0.0.1:8200
-Dotel.resource.attributes=service.name=service-name,env=local
-javaagent:path/to/elastic-apm-agent-1.48.1.jar
-Delastic.apm.service_name=local-apm-service
-Delastic.apm.application_packages=local-package
-Delastic.apm.server_url=http://127.0.0.1:8200
otel.traces.exporter
: Protocol for traces tracking logs.
otel.exporter.otlp.endpoint
: Address and port of the log collector.
elastic.apm.server_url
: Address and port of the APM log collector.
After startup, you can check if the APM Agent started successfully in the APM section of Kibana.
Now, calling project interfaces will display trace records in Kibana.
Summary
Throughout the setup process, Elasticsearch provides data storage, Kibana displays data on pages, Kibana integrates with APM to collect data provided by APM agents as collectors, while OpenTelemetry generates data within the project system.
Reference Documentation
https://www.elastic.co/guide/en/observability/current/apm-installing.html