Skip to content
Merged
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
12 changes: 6 additions & 6 deletions translator/tocwconfig/sampleConfig/complete_linux_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ extensions:
entitystore:
mode: ec2
region: us-west-2
file_storage/journald:
file_storage/opentelemetry:
compaction:
check_interval: 5s
directory: /var/lib/otelcol/file_storage
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
max_transaction_size: 65536
rebound_needed_threshold_mib: 100
rebound_trigger_threshold_mib: 10
create_directory: true
directory: /opt/aws/amazon-cloudwatch-agent/logs/state
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
directory_permissions: "0750"
timeout: 1s
processors:
Expand Down Expand Up @@ -452,7 +452,7 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
units:
- systemd
Expand All @@ -467,7 +467,7 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
units:
- nginx
Expand Down Expand Up @@ -558,7 +558,7 @@ service:
- agenthealth/statuscode
- agenthealth/logs
- agenthealth/traces
- file_storage/journald
- file_storage/opentelemetry
- entitystore
pipelines:
logs/emf_logs:
Expand Down
12 changes: 6 additions & 6 deletions translator/tocwconfig/sampleConfig/journaldlogs_filters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ extensions:
entitystore:
mode: ec2
region: us-west-2
file_storage/journald:
file_storage/opentelemetry:
compaction:
check_interval: 5s
directory: /var/lib/otelcol/file_storage
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
max_transaction_size: 65536
rebound_needed_threshold_mib: 100
rebound_trigger_threshold_mib: 10
create_directory: true
directory: /opt/aws/amazon-cloudwatch-agent/logs/state
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
directory_permissions: "0750"
timeout: 1s
processors:
Expand Down Expand Up @@ -136,7 +136,7 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
journald/journald_1:
id: journald_input
Expand All @@ -148,13 +148,13 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
service:
extensions:
- agenthealth/logs
- agenthealth/statuscode
- file_storage/journald
- file_storage/opentelemetry
- entitystore
pipelines:
logs/journald/0:
Expand Down
10 changes: 5 additions & 5 deletions translator/tocwconfig/sampleConfig/journaldlogs_matches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ extensions:
entitystore:
mode: ec2
region: us-west-2
file_storage/journald:
file_storage/opentelemetry:
compaction:
check_interval: 5s
directory: /var/lib/otelcol/file_storage
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
max_transaction_size: 65536
rebound_needed_threshold_mib: 100
rebound_trigger_threshold_mib: 10
create_directory: true
directory: /opt/aws/amazon-cloudwatch-agent/logs/state
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
directory_permissions: "0750"
timeout: 1s
processors:
Expand All @@ -83,13 +83,13 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
service:
extensions:
- agenthealth/logs
- agenthealth/statuscode
- file_storage/journald
- file_storage/opentelemetry
- entitystore
pipelines:
logs/journald/0:
Expand Down
10 changes: 5 additions & 5 deletions translator/tocwconfig/sampleConfig/journaldlogs_priority.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ extensions:
entitystore:
mode: ec2
region: us-west-2
file_storage/journald:
file_storage/opentelemetry:
compaction:
check_interval: 5s
directory: /var/lib/otelcol/file_storage
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
max_transaction_size: 65536
rebound_needed_threshold_mib: 100
rebound_trigger_threshold_mib: 10
create_directory: true
directory: /opt/aws/amazon-cloudwatch-agent/logs/state
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
directory_permissions: "0750"
timeout: 1s
processors:
Expand All @@ -80,13 +80,13 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
service:
extensions:
- agenthealth/logs
- agenthealth/statuscode
- file_storage/journald
- file_storage/opentelemetry
- entitystore
pipelines:
logs/journald/0:
Expand Down
10 changes: 5 additions & 5 deletions translator/tocwconfig/sampleConfig/journaldlogs_units.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ extensions:
entitystore:
mode: ec2
region: us-west-2
file_storage/journald:
file_storage/opentelemetry:
compaction:
check_interval: 5s
directory: /var/lib/otelcol/file_storage
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
max_transaction_size: 65536
rebound_needed_threshold_mib: 100
rebound_trigger_threshold_mib: 10
create_directory: true
directory: /opt/aws/amazon-cloudwatch-agent/logs/state
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
directory_permissions: "0750"
timeout: 1s
processors:
Expand All @@ -80,15 +80,15 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
units:
- sshd
service:
extensions:
- agenthealth/logs
- agenthealth/statuscode
- file_storage/journald
- file_storage/opentelemetry
- entitystore
pipelines:
logs/journald/0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ extensions:
entitystore:
mode: ec2
region: us-west-2
file_storage/journald:
file_storage/opentelemetry:
compaction:
check_interval: 5s
directory: /var/lib/otelcol/file_storage
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
max_transaction_size: 65536
rebound_needed_threshold_mib: 100
rebound_trigger_threshold_mib: 10
create_directory: true
directory: /opt/aws/amazon-cloudwatch-agent/logs/state
directory: /opt/aws/amazon-cloudwatch-agent/logs/state/otel
directory_permissions: "0750"
timeout: 1s
processors:
Expand All @@ -80,7 +80,7 @@ receivers:
max_elapsed_time: 5m0s
max_interval: 30s
start_at: end
storage: file_storage/journald
storage: file_storage/opentelemetry
type: journald_input
units:
- sshd
Expand All @@ -89,7 +89,7 @@ service:
extensions:
- agenthealth/logs
- agenthealth/statuscode
- file_storage/journald
- file_storage/opentelemetry
- entitystore
pipelines:
logs/journald/0:
Expand Down
17 changes: 7 additions & 10 deletions translator/translate/otel/extension/filestorage/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@ import (
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/extension"

"github.com/aws/amazon-cloudwatch-agent/tool/paths"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/logs/util"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common"
)

const (
name = "journald"
)

type translator struct {
factory extension.Factory
}

var _ common.ComponentTranslator = (*translator)(nil)

// StorageComponentID returns the component.ID for the file_storage/journald extension.
func StorageComponentID() component.ID {
return component.NewIDWithName(filestorage.NewFactory().Type(), name)
func ComponentID() component.ID {
return component.NewIDWithName(filestorage.NewFactory().Type(), common.OpenTelemetryKey)
}

func NewTranslator() common.ComponentTranslator {
Expand All @@ -37,12 +32,14 @@ func NewTranslator() common.ComponentTranslator {
}

func (t *translator) ID() component.ID {
return component.NewIDWithName(t.factory.Type(), name)
return component.NewIDWithName(t.factory.Type(), common.OpenTelemetryKey)
}

func (t *translator) Translate(_ *confmap.Conf) (component.Config, error) {
cfg := t.factory.CreateDefaultConfig().(*filestorage.Config)
cfg.Directory = filepath.Join(paths.AgentDir, "logs", "state")
dir := filepath.Join(util.GetFileStateFolder(), "otel")
cfg.Directory = dir
cfg.Compaction.Directory = dir
cfg.CreateDirectory = true
return cfg, nil
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (

func TestTranslator(t *testing.T) {
tt := NewTranslator()
assert.Equal(t, "file_storage/journald", tt.ID().String())
assert.Equal(t, "file_storage/opentelemetry", tt.ID().String())

conf := confmap.NewFromStringMap(map[string]interface{}{})
got, err := tt.Translate(conf)
Expand All @@ -25,6 +25,7 @@ func TestTranslator(t *testing.T) {

gotCfg, ok := got.(*filestorage.Config)
require.True(t, ok)
assert.Equal(t, "/opt/aws/amazon-cloudwatch-agent/logs/state", gotCfg.Directory)
assert.Equal(t, "/opt/aws/amazon-cloudwatch-agent/logs/state/otel", gotCfg.Directory)
assert.Equal(t, "/opt/aws/amazon-cloudwatch-agent/logs/state/otel", gotCfg.Compaction.Directory)
assert.True(t, gotCfg.CreateDirectory)
}
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ func (t *translator) Translate(conf *confmap.Conf) (*common.ComponentTranslators
translators.Extensions.Set(agenthealth.NewTranslator(agenthealth.LogsName, []string{agenthealth.OperationPutLogEvents}))
translators.Extensions.Set(agenthealth.NewTranslatorWithStatusCode(agenthealth.StatusCodeName, nil, true))

// Add file storage extension for journald cursor persistence
translators.Extensions.Set(filestorage.NewTranslator())

return &translators, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (t *translator) Translate(_ *confmap.Conf) (component.Config, error) {
copy(cfg.InputConfig.Matches, t.matches)
}

storageID := filestorage.StorageComponentID()
storageID := filestorage.ComponentID()
cfg.StorageID = &storageID

return cfg, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func TestTranslatorWithConfig(t *testing.T) {
assert.Equal(t, tc.want.InputConfig.Priority, gotCfg.InputConfig.Priority)
assert.Equal(t, tc.want.InputConfig.Matches, gotCfg.InputConfig.Matches)
assert.NotNil(t, gotCfg.StorageID)
assert.Equal(t, filestorage.StorageComponentID(), *gotCfg.StorageID)
assert.Equal(t, filestorage.ComponentID(), *gotCfg.StorageID)
})
}
}
Expand Down
Loading