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

EMF Exporter does not forward metrics if IRSA is enabled #915

Merged
merged 14 commits into from
Oct 23, 2023
2 changes: 1 addition & 1 deletion plugins/inputs/logfile/logfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ func createWriteRead(t *testing.T, prefix string, logFile *LogFile, done chan bo
defer close(evts)
// Choose a large enough number of lines so that even high-spec hosts will not
// complete receiving logEvents before the 2nd createWriteRead() goroutine begins.
const numLines int = 1000000
const numLines int = 10000
dchappa marked this conversation as resolved.
Show resolved Hide resolved
const msg string = "this is the best log line ever written to a file"
writeLines(t, file, numLines, msg)
file.Close()
Expand Down
1 change: 1 addition & 0 deletions translator/translate/otel/exporter/awsemf/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) {
if credentialsFileKey, ok := agent.Global_Config.Credentials[agent.CredentialsFile_Key]; ok {
cfg.AWSSessionSettings.SharedCredentialsFile = []string{fmt.Sprintf("%v", credentialsFileKey)}
}
cfg.AWSSessionSettings.RoleARN = agent.Global_Config.Role_arn
SaxyPandaBear marked this conversation as resolved.
Show resolved Hide resolved
cfg.AWSSessionSettings.IMDSRetries = retryer.GetDefaultRetryNumber()

if isEcs(c) {
Expand Down
14 changes: 10 additions & 4 deletions translator/translate/otel/exporter/awsemf/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ import (
"go.opentelemetry.io/collector/confmap"

legacytranslator "github.com/aws/amazon-cloudwatch-agent/translator"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/agent"
)

var nilSlice []string
var nilMetricDescriptorsSlice []awsemfexporter.MetricDescriptor

func TestTranslator(t *testing.T) {
tt := NewTranslator()
agent.Global_Config.Region = "us-east-1"
agent.Global_Config.Role_arn = "global_arn"
require.EqualValues(t, "awsemf", tt.ID().String())
testCases := map[string]struct {
env map[string]string
input map[string]interface{}
want map[string]interface{} // Can't construct & use awsemfexporter.Config as it uses internal only types
wantErr error
env map[string]string
input map[string]interface{}
agentConfig agent.Agent
want map[string]interface{} // Can't construct & use awsemfexporter.Config as it uses internal only types
wantErr error
}{
"GenerateAwsEmfExporterConfigEcs": {
input: map[string]interface{}{
Expand Down Expand Up @@ -675,6 +679,8 @@ func TestTranslator(t *testing.T) {
require.Equal(t, testCase.want["resource_to_telemetry_conversion"], gotCfg.ResourceToTelemetrySettings)
require.ElementsMatch(t, testCase.want["metric_declarations"], gotCfg.MetricDeclarations)
require.ElementsMatch(t, testCase.want["metric_descriptors"], gotCfg.MetricDescriptors)
require.Equal(t, "global_arn", gotCfg.RoleARN)
require.Equal(t, "us-east-1", gotCfg.Region)
}
})
}
Expand Down
Loading