OpenTelemetry has various open-source combination solutions. We will introduce and demonstrate OpenTelemetry deployments under different technical architectures through three platforms/frameworks.
OTEL is the abbreviation for OpenTelemetry, a CNCF observability project aimed at providing standardized solutions in the observability domain. It addresses standardization issues of observability data models, collection, processing, and export, offering services independent of third-party vendors.
OpenTelemetry is a collection of standards and tools designed to manage observability data such as Traces, Metrics, Logs, etc. (new types of observability data may emerge in the future). It has become an industry standard.
OTLP (full name: OpenTelemetry Protocol) is the native telemetry signal transmission protocol of OpenTelemetry. Although components in the OpenTelemetry project support Zipkin v2 or Jaeger Thrift protocol formats, these are provided as third-party contribution libraries. Only OTLP is natively supported by OpenTelemetry. The data model definition of OTLP is based on ProtoBuf. If you need to implement a backend service that can collect OTLP telemetry data, you need to understand its content; refer to the code repository: opentelemetry-proto (https://github.com/open-telemetry/opentelemetry-proto)
The OpenTelemetry Collector (hereinafter referred to as "otel-collector") provides vendor-neutral implementations for receiving, processing, and exporting telemetry data. It eliminates the need to run, operate, and maintain multiple agents/collectors to support sending open-source observability data formats (such as Jaeger, Prometheus, etc.) to one or more open-source or commercial backends. Additionally, the collector allows end-users to control their data. The collector is the default location where detection libraries export their telemetry data.
Application servers and clients push metric and trace data through otlp-exporter to otel-collector.
Front-end applications send trace information to otel-collector and access application service APIs.
Otel-collector collects and transforms data before pushing it to Jaeger and Zipkin.
Meanwhile, Prometheus pulls data from otel-collector.
There are two ways to push logs:
Method One: Push logs via OTLP
Application servers and clients push logs through otlp-exporter to otel-collector, which then exports them to Elasticsearch. Since OpenTelemetry log handling is not yet stable, it's recommended to handle logs separately without going through otel-collector. During testing, conflicts were found between configuring logs and metrics, primarily on otel-collector, awaiting official fixes.
Method Two: Push logs via Logback-logstash
Application servers and clients push logs through Logback-logstash to logstash.
Note, all applications are deployed on the same machine with IP address 192.168.0.17. If applications and some middleware are deployed separately, ensure corresponding IPs are modified. For cloud servers, ensure relevant ports are opened to avoid access failures.
# Linux-specific configurationsysctl-wvm.max_map_count=262144sysctl-p
# End of Linux configurationmkdir-p~/elk/elasticsearch/plugins
mkdir-p~/elk/elasticsearch/data
mkdir-p~/elk/logstash
chmod777~/elk/elasticsearch/data
version:'3'services:
elasticsearch:
image:docker.elastic.co/elasticsearch/elasticsearch:7.16.2
container_name:elasticsearch
volumes:
-~/elk/elasticsearch/plugins:/usr/share/elasticsearch/plugins# Mount plugin files-~/elk/elasticsearch/data:/usr/share/elasticsearch/data# Mount data filesenvironment:
-"cluster.name=elasticsearch"# Set cluster name to elasticsearch-"discovery.type=single-node"# Start in single-node mode-"ES_JAVA_OPTS=-Xms512m -Xmx512m"# Set JVM memory size-"ingest.geoip.downloader.enabled=false"# Disable GeoIP2 database updatesports:
-9200:9200
logstash:
image:docker.elastic.co/logstash/logstash:7.16.2
container_name:logstash
volumes:
-~/elk/logstash/logstash.conf:/usr/share/logstash/pipeline/logstash.conf# Mount Logstash configuration filedepends_on:
-elasticsearch# Start after Elasticsearchlinks:
-elasticsearch:es# Access Elasticsearch service via es domain nameports:
-4560:4560
kibana:
image:docker.elastic.co/kibana/kibana:7.16.2
container_name:kibana
depends_on:
-elasticsearch# Start after Elasticsearchlinks:
-elasticsearch:es# Access Elasticsearch service via es domain nameenvironment:
-"elasticsearch.hosts=http://es:9200"# Set Elasticsearch access addressports:
-5601:5601
otel.metrics.exporter: otlp # Set metrics exporter type, default is none.
otel.logs.exporter: otlp # Set logs exporter type, default is none.
otel.propagators: Set trace propagator.
Since OpenTelemetry log handling is not mature and stable, it is not recommended for production use. Some bugs were found during testing, only for learning purposes.
constotelExporter=newOTLPTraceExporter({// optional - url default value is http://localhost:55681/v1/tracesurl:'http://192.168.91.11:4318/v1/traces',headers:{},});
Here, the URL is the OTLP reception address of otel-collector (HTTP protocol).
APM and RUM are mainly correlated through header parameters. To maintain consistency, a unified propagator (Propagator) needs to be configured. Here, RUM uses B3, so APM also needs to configure B3. Just add -Dotel.propagators=b3 to the APM startup parameters.
APM and Log correlation primarily involves embedding traceId and spanId in log instrumentation. Different log integration methods result in differences in instrumentation.
"_source":{"@timestamp":"2022-05-18T13:43:34.790Z","port":55630,"serverName":"otlp-server","namespace":"k8sNamespace_IS_UNDEFINED","message":"this is tag\n","@version":"1","severity":"INFO","thread":"http-nio-8080-exec-1","pid":"3975","host":"gateway","class":"c.z.o.server.controller.ServerController","traceId":"a7360264491f074a1b852cfcabb10fdb","spanId":"e4a8f1c4606ca598","podName":"podName_IS_UNDEFINED"},
Through the Logstash-logback method, traceId and spanId need to be manually instrumented.