Skip to content

Commit

Permalink
add the Elastic Collector distribution
Browse files Browse the repository at this point in the history
  • Loading branch information
rogercoll committed Jul 1, 2024
1 parent c8bf5e1 commit a4b8462
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 27 deletions.
7 changes: 7 additions & 0 deletions .env.override
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ IMAGE_NAME=ghcr.io/elastic/opentelemetry-demo
# *********************
AD_SERVICE_DOCKERFILE=./src/adservice/Dockerfile.elastic
FRAUD_SERVICE_DOCKERFILE=./src/frauddetectionservice/Dockerfile.elastic

# *********************
# Elastic Collector
# *********************
COLLECTOR_CONTRIB_IMAGE=docker.elastic.co/beats/elastic-agent:8.15.0-SNAPSHOT
OTEL_COLLECTOR_CONFIG=./src/otelcollector/otelcol-elastic-config.yaml
OTEL_COLLECTOR_CONFIG_EXTRAS=./src/otelcollector/otelcol-elastic-config-extras.yaml
6 changes: 4 additions & 2 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ The following guide describes how to setup the OpenTelemetry demo with Elastic O
- The .NET agent within the [Cart service](../src/cartservice/src/Directory.Build.props) has been replaced with the Elastic distribution of the OpenTelemetry .NET Agent. You can find more information about the Elastic distribution in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-opentelemetry-distribution-dotnet-applications).
- The Elastic distribution of the OpenTelemetry Node.js Agent has replaced the OpenTelemetry Node.js agent in the [Payment service](../src/paymentservice/package.json). Additional details about the Elastic distribution are available in [this blog post](https://www.elastic.co/observability-labs/blog/elastic-opentelemetry-distribution-node-js).

Additionally, the OpenTelemetry Contrib collector has also been changed to the [Elastic OpenTelemetry Collector distribution](https://github.com/elastic/elastic-agent/blob/main/internal/pkg/otel/README.md). This ensures a more integrated and optimized experience with Elastic Observability.

## Docker compose

1. Start a free trial on [Elastic Cloud](https://cloud.elastic.co/) and copy the `endpoint` and `secretToken` from the Elastic APM setup instructions in your Kibana.
1. Open the file `src/otelcollector/otelcol-config-extras.yml` in an editor and replace the following two placeholders:
1. Open the file `src/otelcollector/otelcol-elastic-config-extras.yaml` in an editor and replace the following two placeholders:
- `YOUR_APM_ENDPOINT_WITHOUT_HTTPS_PREFIX`: your Elastic APM endpoint (*without* `https://` prefix) that *must* also include the port (example: `1234567.apm.us-west2.gcp.elastic-cloud.com:443`).
- `YOUR_APM_SECRET_TOKEN`: your Elastic APM secret token.
1. Start the demo with the following command from the repository's root directory:
```
docker-compose up -d
make start
```

## Kubernetes
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.minimal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,8 @@ services:
limits:
memory: 200M
restart: unless-stopped
command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ]
command: ["otel", "--config", "/etc/otelcol-config.yml", "--config", "/etc/otelcol-config-extras.yml" ]
entrypoint: [ /usr/share/elastic-agent/elastic-agent ]
volumes:
- ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml
- ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml
Expand Down
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,8 @@ services:
limits:
memory: 200M
restart: unless-stopped
command: [ "--config=/etc/otelcol-config.yml", "--config=/etc/otelcol-config-extras.yml" ]
command: ["otel", "--config", "/etc/otelcol-config.yml", "--config", "/etc/otelcol-config-extras.yml" ]
entrypoint: [ /usr/share/elastic-agent/elastic-agent ]
volumes:
- ${OTEL_COLLECTOR_CONFIG}:/etc/otelcol-config.yml
- ${OTEL_COLLECTOR_CONFIG_EXTRAS}:/etc/otelcol-config-extras.yml
Expand Down
23 changes: 0 additions & 23 deletions src/otelcollector/otelcol-config-extras.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,3 @@
# pipelines:
# traces:
# exporters: [spanmetrics, otlphttp/example]

exporters:
otlp/elastic:
# !!! Elastic APM https endpoint WITHOUT the "https://" prefix
endpoint: "YOUR_APM_ENDPOINT_WITHOUT_HTTPS_PREFIX"
compression: none
headers:
Authorization: "Bearer YOUR_APM_SECRET_TOKEN"

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [spanmetrics, otlp/elastic]
metrics:
receivers: [otlp, spanmetrics]
processors: [batch]
exporters: [otlp/elastic]
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlp/elastic]
41 changes: 41 additions & 0 deletions src/otelcollector/otelcol-elastic-config-extras.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright The OpenTelemetry Authors
# SPDX-License-Identifier: Apache-2.0

# extra settings to be merged into OpenTelemetry Collector configuration
# do not delete this file

## Example configuration for sending data to your own OTLP HTTP backend
## Note: the spanmetrics exporter must be included in the exporters array
## if overriding the traces pipeline.
##
# exporters:
# otlphttp/example:
# endpoint: <your-endpoint-url>
#
# service:
# pipelines:
# traces:
# exporters: [spanmetrics, otlphttp/example]

exporters:
otlp/elastic:
# !!! Elastic APM https endpoint WITHOUT the "https://" prefix
endpoint: "YOUR_APM_ENDPOINT_WITHOUT_HTTPS_PREFIX"
compression: none
headers:
Authorization: "Bearer YOUR_APM_SECRET_TOKEN"

service:
pipelines:
traces:
receivers: [otlp]
processors: [batch]
exporters: [spanmetrics, otlp/elastic]
metrics:
receivers: [otlp, spanmetrics]
processors: [batch]
exporters: [otlp/elastic]
logs:
receivers: [otlp]
processors: [batch]
exporters: [otlp/elastic]
18 changes: 18 additions & 0 deletions src/otelcollector/otelcol-elastic-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
receivers:
otlp:
protocols:
grpc:
http:
cors:
allowed_origins:
- "http://*"
- "https://*"

exporters:
debug:

processors:
batch:

connectors:
spanmetrics:

0 comments on commit a4b8462

Please sign in to comment.