Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added translation logic in tcp and udp emf log receivers to attach network attributes for emf logs #1487

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ receivers:
resource_arn: ""
role_arn: ""
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -214,6 +215,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ receivers:
initial_delay: 1s
timeout: 0s
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 127.0.0.1:25888
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ receivers:
initial_delay: 1s
timeout: 0s
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 127.0.0.1:25888
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ receivers:
initial_delay: 1s
timeout: 0s
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 127.0.0.1:25888
Expand Down
2 changes: 2 additions & 0 deletions translator/tocwconfig/sampleConfig/config_with_env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ processors:
timeout: 5s
receivers:
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -71,6 +72,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -396,23 +396,30 @@ extensions:
operations:
- PutLogEvents
usage_flags:
mode: OP
mode: K8OP
region_type: ACJ
agenthealth/statuscode:
is_status_code_enabled: true
is_usage_data_enabled: true
stats:
usage_flags:
mode: OP
mode: K8OP
region_type: ACJ
entitystore:
kubernetes_mode: K8sOnPrem
mode: onPremise
profile: default
region: us-east-1
shared_credential_file: /root/.aws/credentials
server:
listen_addr: :4311
tls_ca_path: /etc/amazon-cloudwatch-observability-agent-client-cert/tls-ca.crt
tls_cert_path: /etc/amazon-cloudwatch-observability-agent-server-cert/server.crt
tls_key_path: /etc/amazon-cloudwatch-observability-agent-server-cert/server.key
processors:
awsentity/service/emf:
entity_type: Service
kubernetes_mode: K8sOnPrem
platform: onPremise
batch/containerinsights:
metadata_cardinality_limit: 1000
Expand Down Expand Up @@ -467,6 +474,7 @@ receivers:
shared_credentials_file:
- /root/.aws/credentials
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -478,6 +486,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand All @@ -497,6 +506,7 @@ service:
- agenthealth/logs
- agenthealth/statuscode
- entitystore
- server
pipelines:
logs/emf_logs:
exporters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -654,23 +654,30 @@ extensions:
operations:
- PutLogEvents
usage_flags:
mode: OP
mode: K8OP
region_type: ACJ
agenthealth/statuscode:
is_status_code_enabled: true
is_usage_data_enabled: true
stats:
usage_flags:
mode: OP
mode: K8OP
region_type: ACJ
entitystore:
kubernetes_mode: K8sOnPrem
mode: onPremise
profile: default
region: us-east-1
shared_credential_file: /root/.aws/credentials
server:
listen_addr: :4311
tls_ca_path: /etc/amazon-cloudwatch-observability-agent-client-cert/tls-ca.crt
tls_cert_path: /etc/amazon-cloudwatch-observability-agent-server-cert/server.crt
tls_key_path: /etc/amazon-cloudwatch-observability-agent-server-cert/server.key
processors:
awsentity/service/emf:
entity_type: Service
kubernetes_mode: K8sOnPrem
platform: onPremise
batch/containerinsights:
metadata_cardinality_limit: 1000
Expand Down Expand Up @@ -1139,6 +1146,7 @@ receivers:
shared_credentials_file:
- /root/.aws/credentials
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -1150,6 +1158,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand All @@ -1169,6 +1178,7 @@ service:
- agenthealth/logs
- agenthealth/statuscode
- entitystore
- server
pipelines:
logs/emf_logs:
exporters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,23 +476,30 @@ extensions:
operations:
- PutLogEvents
usage_flags:
mode: OP
mode: K8OP
region_type: ACJ
agenthealth/statuscode:
is_status_code_enabled: true
is_usage_data_enabled: true
stats:
usage_flags:
mode: OP
mode: K8OP
region_type: ACJ
entitystore:
kubernetes_mode: K8sOnPrem
mode: onPremise
profile: default
region: us-east-1
shared_credential_file: /root/.aws/credentials
server:
listen_addr: :4311
tls_ca_path: /etc/amazon-cloudwatch-observability-agent-client-cert/tls-ca.crt
tls_cert_path: /etc/amazon-cloudwatch-observability-agent-server-cert/server.crt
tls_key_path: /etc/amazon-cloudwatch-observability-agent-server-cert/server.key
processors:
awsentity/service/emf:
entity_type: Service
kubernetes_mode: K8sOnPrem
platform: onPremise
batch/containerinsights:
metadata_cardinality_limit: 1000
Expand Down Expand Up @@ -556,6 +563,7 @@ receivers:
cluster_name: TestCluster
collection_interval: 1m0s
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -567,6 +575,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand All @@ -586,6 +595,7 @@ service:
- agenthealth/logs
- agenthealth/statuscode
- entitystore
- server
pipelines:
logs/emf_logs:
exporters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ receivers:
cluster_name: TestCluster
collection_interval: 1m0s
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -301,6 +302,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand Down
2 changes: 2 additions & 0 deletions translator/tocwconfig/sampleConfig/log_ecs_metric_only.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ receivers:
resource_arn: ""
role_arn: ""
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -157,6 +158,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ receivers:
resource_arn: ""
role_arn: ""
tcplog/emf_logs:
add_attributes: true
encoding: utf-8
id: tcp_input
listen_address: 0.0.0.0:25888
Expand All @@ -470,6 +471,7 @@ receivers:
max_interval: 0s
type: tcp_input
udplog/emf_logs:
add_attributes: true
encoding: utf-8
id: udp_input
listen_address: 0.0.0.0:25888
Expand Down
3 changes: 3 additions & 0 deletions translator/tocwconfig/tocwconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ func TestEmfAndKubernetesConfig(t *testing.T) {
readCommonConfig(t, "./sampleConfig/commonConfig/withCredentials.toml")
context.CurrentContext().SetRunInContainer(true)
context.CurrentContext().SetMode(config.ModeOnPremise)
context.CurrentContext().SetKubernetesMode(config.ModeK8sOnPrem)
t.Setenv(config.HOST_NAME, "host_name_from_env")
t.Setenv(config.HOST_IP, "127.0.0.1")
expectedEnvVars := map[string]string{}
Expand All @@ -225,6 +226,7 @@ func TestEmfAndKubernetesWithGpuConfig(t *testing.T) {
readCommonConfig(t, "./sampleConfig/commonConfig/withCredentials.toml")
context.CurrentContext().SetRunInContainer(true)
context.CurrentContext().SetMode(config.ModeOnPremise)
context.CurrentContext().SetKubernetesMode(config.ModeK8sOnPrem)
t.Setenv(config.HOST_NAME, "host_name_from_env")
t.Setenv(config.HOST_IP, "127.0.0.1")
expectedEnvVars := map[string]string{}
Expand All @@ -237,6 +239,7 @@ func TestEmfAndKubernetesWithKueueConfig(t *testing.T) {
readCommonConfig(t, "./sampleConfig/commonConfig/withCredentials.toml")
context.CurrentContext().SetRunInContainer(true)
context.CurrentContext().SetMode(config.ModeOnPremise)
context.CurrentContext().SetKubernetesMode(config.ModeK8sOnPrem)
t.Setenv(config.HOST_NAME, "host_name_from_env")
t.Setenv(config.HOST_IP, "127.0.0.1")
expectedEnvVars := map[string]string{}
Expand Down
2 changes: 2 additions & 0 deletions translator/translate/otel/receiver/tcplog/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (t *translator) Translate(conf *confmap.Conf) (component.Config, error) {
return nil, &common.MissingKeyError{ID: t.ID(), JsonKey: fmt.Sprintf("missing %s or tcp service address", baseKey)}
}
cfg := t.factory.CreateDefaultConfig().(*tcplogreceiver.TCPLogConfig)
//Always try to add the network attributes for emf logs, used for building an entity
cfg.InputConfig.BaseConfig.AddAttributes = true
if !conf.IsSet(common.ConfigKey(serviceAddressKey)) {
cfg.InputConfig.BaseConfig.ListenAddress = "0.0.0.0:25888"
} else {
Expand Down
2 changes: 2 additions & 0 deletions translator/translate/otel/receiver/udplog/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ func (t *translator) Translate(conf *confmap.Conf) (component.Config, error) {
return nil, &common.MissingKeyError{ID: t.ID(), JsonKey: fmt.Sprintf("missing %s or udp service address", baseKey)}
}
cfg := t.factory.CreateDefaultConfig().(*udplogreceiver.UDPLogConfig)
//Always try to add the network attributes for emf logs, used for building an entity
cfg.InputConfig.BaseConfig.AddAttributes = true
if !conf.IsSet(common.ConfigKey(serviceAddressKey)) {
cfg.InputConfig.BaseConfig.ListenAddress = "0.0.0.0:25888"
} else {
Expand Down
Loading