Skip to content

Commit

Permalink
[ecs-ec2] Update default configs (#343)
Browse files Browse the repository at this point in the history
* Update logging.yaml

* Update config.yaml

* Update CHANGELOG.md
  • Loading branch information
royfur authored Dec 13, 2023
1 parent c300129 commit 80b36cb
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 35 deletions.
3 changes: 3 additions & 0 deletions otel-agent/ecs-ec2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## OpenTelemtry-Agent

### v0.0.31 / 2023-12-13
* [FIX] fix config example files

### v0.0.31 / 2023-10-17
* [FIX] log.file.path removal from coralogix exporter subsystem attributes

Expand Down
58 changes: 42 additions & 16 deletions otel-agent/ecs-ec2/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,26 @@ receivers:
http:
endpoint: "0.0.0.0:4318"

prometheus:
config:
scrape_configs:
- job_name: otel-collector-metrics
scrape_interval: 60s
static_configs:
- targets: ['localhost:8888']

filelog:
start_at: end
include:
- /hostfs/var/lib/docker/containers/*/*.log

include_file_path: true

# add log.file.name to resource attributes
# add log.file.path to resource attributes
operators:
- type: move
from: attributes["log.file.name"]
to: resource["log.file.name"]
from: attributes["log.file.path"]
to: resource["log.file.path"]

# add metrics
awsecscontainermetricsd:
Expand All @@ -32,16 +40,7 @@ processors:
ecsattributes:
container_id:
sources:
- "log.file.name"

# only allow logs with container.name label
filter/ecslogs:
logs:
include:
match_type: regexp
resource_attributes:
- key: aws.ecs.container.name
value: '.*'
- "log.file.path"

transform/logs:
error_mode: ignore
Expand All @@ -54,7 +53,13 @@ processors:
- delete_key(attributes, "image.id")

batch:


# otel-collector resource detection for collector
resourcedetection/otel-collector:
detectors: [ecs, ec2]
timeout: 2s
override: false

exporters:
logging:
coralogix:
Expand All @@ -63,20 +68,28 @@ exporters:
application_name: "$APP_NAME"
subsystem_name: "$SUB_SYS"
application_name_attributes:
- "aws.ecs.cluster"
- "aws.ecs.cluster.name"
- "aws.ecs.task.definition.family"
subsystem_name_attributes:
- "aws.ecs.container.name"
- "aws.ecs.docker.name"
- "docker.name"
timeout: 30s

extensions:
health_check:

service:
extensions:
- health_check
pipelines:
logs:
receivers:
- filelog
processors:
- resourcedetection
- ecsattributes
- filter/ecslogs
- transform/logs
exporters:
- coralogix
Expand All @@ -95,4 +108,17 @@ service:
processors:
- batch
exporters:
- coralogix
- coralogix

metrics/otel-collector:
receivers:
- prometheus
processors:
- resourcedetection/otel-collector
exporters:
- coralogix

telemetry:
metrics:
address: 0.0.0.0:8888
level: detailed
77 changes: 58 additions & 19 deletions otel-agent/ecs-ec2/logging.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
receivers:
otlp:
protocols:
grpc:
endpoint: "0.0.0.0:4317"
http:
endpoint: "0.0.0.0:4318"

prometheus:
config:
scrape_configs:
- job_name: otel-collector-metrics
scrape_interval: 60s
static_configs:
- targets: ['localhost:8888']

filelog:
start_at: end
include:
- /hostfs/var/lib/docker/containers/*/*.log

include_file_path: true

# add log.file.name to resource attributes
# add log.file.path to resource attributes
operators:
- type: move
from: attributes["log.file.name"]
to: resource["log.file.name"]
from: attributes["log.file.path"]
to: resource["log.file.path"]

processors:
resourcedetection:
Expand All @@ -20,22 +35,9 @@ processors:
override: false

ecsattributes:
attributes:
- ^image$
- ^aws.*
- ^labels.*
container_id:
sources:
- "log.file.name"

# only allow logs with container.name label
filter/ecslogs:
logs:
include:
match_type: regexp
resource_attributes:
- key: aws.ecs.container.name
value: .*
- "log.file.path"

transform/logs:
error_mode: ignore
Expand All @@ -44,29 +46,66 @@ processors:
statements:
- set(attributes["cx_container_id"], attributes["docker.id"])
- set(attributes["aws_ecs_task_family"], attributes["aws.ecs.task.definition.family"])

- set(attributes["image_id"], attributes["image.id"])
- delete_key(attributes, "image.id")

# otel-collector resource detection for collector
resourcedetection/otel-collector:
detectors: [ecs, ec2]
timeout: 2s
override: false

exporters:
logging:
verbosity: detailed
coralogix:
domain: "$CORALOGIX_DOMAIN"
private_key: "$PRIVATE_KEY"
application_name: "$APP_NAME"
subsystem_name: "$SUB_SYS"
application_name_attributes:
- "aws.ecs.cluster"
- "aws.ecs.cluster.name"
- "aws.ecs.task.definition.family"
subsystem_name_attributes:
- "aws.ecs.container.name"
- "aws.ecs.docker.name"
- "docker.name"
timeout: 30s

extensions:
health_check:

service:
extensions:
- health_check

pipelines:
logs:
receivers:
- filelog
processors:
- resourcedetection
- ecsattributes
- filter/ecslogs
- transform/logs
exporters:
- coralogix

traces:
receivers:
- otlp
exporters:
- coralogix

metrics/otel-collector:
receivers:
- prometheus
processors:
- resourcedetection/otel-collector
exporters:
- coralogix

telemetry:
metrics:
address: 0.0.0.0:8888
level: detailed

0 comments on commit 80b36cb

Please sign in to comment.