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

Container insights ssl #822

Merged
merged 16 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ replace github.com/go-kit/kit => github.com/go-kit/kit v0.12.1-0.20220808180842-
replace github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37

require (
github.com/BurntSushi/toml v0.4.1
github.com/BurntSushi/toml v1.3.2
github.com/Jeffail/gabs v1.4.0
github.com/Rican7/retry v0.1.1-0.20160712041035-272ad122d6e5
github.com/aws/aws-sdk-go v1.44.309
Expand Down Expand Up @@ -153,6 +153,8 @@ require (
k8s.io/klog/v2 v2.90.1
)

require github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws v0.24.0
bhanuba marked this conversation as resolved.
Show resolved Hide resolved

require (
cloud.google.com/go/compute v1.19.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
Expand Down
9 changes: 8 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ
github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo=
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
github.com/Azure/go-ntlmssp v0.0.0-20200615164410-66371956d46c h1:/IBSNwUN8+eKzUzbJPqhK839ygXJ82sde8x3ogr6R28=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ClickHouse/clickhouse-go v1.5.4 h1:cKjXeYLNWVJIx2J1K6H2CqyRmfwVJVY1OV1coaaFcI0=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
Expand Down Expand Up @@ -953,6 +954,8 @@ github.com/onsi/gomega v1.23.0 h1:/oxKu9c2HVap+F3PfKort2Hw5DEU+HGlW8n+tguWsys=
github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk=
github.com/open-telemetry/opentelemetry-collector-contrib/exporter/prometheusremotewriteexporter v0.77.0 h1:l4T8p1MOei5MJOheFAJVuSnJcAR1D929I7ycoqMIKPg=
github.com/open-telemetry/opentelemetry-collector-contrib/extension/storage v0.77.0 h1:UU5IzATj3qbO6E3eY27pe5JrP/GiKOal58vWRNzqt94=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws v0.24.0 h1:aAzw1kWnyfQnD7mmd6W4nMUFeB4uIccqDodyAUnVVf8=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws v0.24.0/go.mod h1:cJuh7B7ioJooKFhkrEK2qPd2hRjcs7BPI1Yly1tbb2Q=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics v0.79.0 h1:EXFITXhCONGJ2htxXqujga3ZJaUQj7hqeLlnpYaVU1s=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/metrics v0.79.0/go.mod h1:r03E03RLmrUgq1b/AD1owCVLqsg47sEWHent1PHKmR0=
github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy v0.77.0 h1:c5u+RvQdxzUpZT21c+nekncCVrHxRjKPAyH6fPGoaQA=
Expand Down Expand Up @@ -1279,18 +1282,22 @@ go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0/go.mod h1:
go.opentelemetry.io/contrib/propagators/b3 v1.17.0 h1:ImOVvHnku8jijXqkwCSyYKRDt2YrnGXD4BbhcpfbfJo=
go.opentelemetry.io/contrib/propagators/b3 v1.17.0/go.mod h1:IkfUfMpKWmynvvE0264trz0sf32NRTZL4nuAN9AbWRc=
go.opentelemetry.io/contrib/zpages v0.42.0 h1:hFscXKQ9PTjyIVmAr6zIV8cMoiEeR9lPIwPVqHi8+5Q=
go.opentelemetry.io/otel v0.19.0/go.mod h1:j9bF567N9EfomkSidSfmMwIwIBuP37AMAIzVW85OxSg=
go.opentelemetry.io/otel v1.16.0 h1:Z7GVAX/UkAXPKsy94IU+i6thsQS4nb7LviLpnaNeW8s=
go.opentelemetry.io/otel v1.16.0/go.mod h1:vl0h9NUa1D5s1nv3A5vZOYWn8av4K8Ml6JDeHrT/bx4=
go.opentelemetry.io/otel/bridge/opencensus v0.39.0 h1:YHivttTaDhbZIHuPlg1sWsy2P5gj57vzqPfkHItgbwQ=
go.opentelemetry.io/otel/bridge/opencensus v0.39.0/go.mod h1:vZ4537pNjFDXEx//WldAR6Ro2LC8wwmFC76njAXwNPE=
go.opentelemetry.io/otel/exporters/prometheus v0.39.0 h1:whAaiHxOatgtKd+w0dOi//1KUxj3KoPINZdtDaDj3IA=
go.opentelemetry.io/otel/exporters/prometheus v0.39.0/go.mod h1:4jo5Q4CROlCpSPsXLhymi+LYrDXd2ObU5wbKayfZs7Y=
go.opentelemetry.io/otel/metric v0.19.0/go.mod h1:8f9fglJPRnXuskQmKpnad31lcLJ2VmNNqIsx/uIwBSc=
go.opentelemetry.io/otel/metric v1.16.0 h1:RbrpwVG1Hfv85LgnZ7+txXioPDoh6EdbZHo26Q3hqOo=
go.opentelemetry.io/otel/metric v1.16.0/go.mod h1:QE47cpOmkwipPiefDwo2wDzwJrlfxxNYodqc4xnGCo4=
go.opentelemetry.io/otel/oteltest v0.19.0/go.mod h1:tI4yxwh8U21v7JD6R3BcA/2+RBoTKFexE/PJ/nSO7IA=
go.opentelemetry.io/otel/sdk v1.16.0 h1:Z1Ok1YsijYL0CSJpHt4cS3wDDh7p572grzNrBMiMWgE=
go.opentelemetry.io/otel/sdk v1.16.0/go.mod h1:tMsIuKXuuIWPBAOrH+eHtvhTL+SntFtXF9QD68aP6p4=
go.opentelemetry.io/otel/sdk/metric v0.39.0 h1:Kun8i1eYf48kHH83RucG93ffz0zGV1sh46FAScOTuDI=
go.opentelemetry.io/otel/sdk/metric v0.39.0/go.mod h1:piDIRgjcK7u0HCL5pCA4e74qpK/jk3NiUoAHATVAmiI=
go.opentelemetry.io/otel/trace v0.19.0/go.mod h1:4IXiNextNOpPnRlI4ryK69mn5iC84bjBWZQA5DXz/qg=
go.opentelemetry.io/otel/trace v1.16.0 h1:8JRpaObFoW0pxuVPapkgH8UhHQj+bJW8jJsCZEu5MQs=
go.opentelemetry.io/otel/trace v1.16.0/go.mod h1:Yt9vYq1SdNz3xdjZZK7wcXv1qv2pwLkqr2QVwea0ef0=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
connectors: {}
exporters:
awscloudwatchlogs/emf_logs:
certificate_file_path: ""
certificate_file_path: "sampleConfig/public_amazon_cert.pem"
emf_only: true
endpoint: "https://fake_endpoint"
local_mode: false
Expand Down Expand Up @@ -38,8 +38,8 @@ exporters:
disable_metric_extraction: true
version: "0"
eks_fargate_container_insights_enabled: false
certificate_file_path: ""
endpoint: ""
certificate_file_path: "sampleConfig/public_amazon_cert.pem"
endpoint: "https://fake_endpoint"
enhanced_container_insights: false
local_mode: false
retain_initial_value_of_delta_metric: false
Expand Down Expand Up @@ -194,8 +194,8 @@ service:
processors:
- batch/emf_logs
receivers:
- udplog/emf_logs
- tcplog/emf_logs
- udplog/emf_logs
metrics/containerinsights:
exporters:
- awsemf/containerinsights
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exporters:
disable_metric_extraction: true
eks_fargate_container_insights_enabled: false
certificate_file_path: ""
endpoint: ""
endpoint: "https://fake_endpoint"
SaxyPandaBear marked this conversation as resolved.
Show resolved Hide resolved
enhanced_container_insights: true
local_mode: false
log_group_name: /aws/containerinsights/{ClusterName}/performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exporters:
dimension_rollup_option: NoDimensionRollup
disable_metric_extraction: true
eks_fargate_container_insights_enabled: false
endpoint: ""
endpoint: "https://fake_endpoint"
enhanced_container_insights: true
local_mode: false
log_group_name: /aws/containerinsights/{ClusterName}/performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exporters:
disable_metric_extraction: false
eks_fargate_container_insights_enabled: false
certificate_file_path: ""
endpoint: ""
endpoint: "https://fake_endpoint"
enhanced_container_insights: false
local_mode: false
log_group_name: /aws/ecs/containerinsights/{ClusterName}/performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ exporters:
dimension_rollup_option: NoDimensionRollup
disable_metric_extraction: false
eks_fargate_container_insights_enabled: false
endpoint: ""
endpoint: "https://fake_endpoint"
enhanced_container_insights: true
local_mode: false
log_group_name: /aws/containerinsights/{ClusterName}/performance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exporters:
retain_initial_value_of_delta_metric: false
eks_fargate_container_insights_enabled: false
certificate_file_path: ""
endpoint: ""
endpoint: "https://fake_endpoint"
enhanced_container_insights: false
local_mode: false
log_group_name: /aws/ecs/containerinsights/TestCluster/prometheus
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exporters:
retain_initial_value_of_delta_metric: false
eks_fargate_container_insights_enabled: false
certificate_file_path: ""
endpoint: ""
endpoint: "https://fake_endpoint"
enhanced_container_insights: false
local_mode: false
log_group_name: /aws/ecs/containerinsights/TestCluster/prometheus
Expand Down
9 changes: 8 additions & 1 deletion translator/tocwconfig/tocwconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/aws/amazon-cloudwatch-agent/cfg/envconfig"
"io/fs"
"os"
"path/filepath"
Expand Down Expand Up @@ -50,7 +51,13 @@ func TestBaseContainerInsightsConfig(t *testing.T) {
context.CurrentContext().SetRunInContainer(true)
t.Setenv(config.HOST_NAME, "host_name_from_env")
t.Setenv(config.HOST_IP, "127.0.0.1")
expectedEnvVars := map[string]string{}
t.Setenv(envconfig.AWS_CA_BUNDLE, "sampleConfig/public_amazon_cert.pem")
defer func() {
bhanuba marked this conversation as resolved.
Show resolved Hide resolved
t.Setenv(envconfig.AWS_CA_BUNDLE, "")
}()
SaxyPandaBear marked this conversation as resolved.
Show resolved Hide resolved
expectedEnvVars := map[string]string{
"AWS_CA_BUNDLE": "sampleConfig/public_amazon_cert.pem",
}
checkTranslation(t, "base_container_insights_config", "linux", expectedEnvVars, "")
checkTranslation(t, "base_container_insights_config", "darwin", nil, "")
}
Expand Down
9 changes: 8 additions & 1 deletion translator/translate/otel/exporter/awsemf/translator.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ package awsemf
import (
_ "embed"
"fmt"
"os"

"github.com/open-telemetry/opentelemetry-collector-contrib/exporter/awsemfexporter"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/confmap"
"go.opentelemetry.io/collector/exporter"
"gopkg.in/yaml.v3"

"github.com/aws/amazon-cloudwatch-agent/cfg/envconfig"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/agent"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/common"
"github.com/aws/amazon-cloudwatch-agent/translator/translate/otel/receiver/awscontainerinsight"
Expand All @@ -32,6 +34,7 @@ var (
kubernetesBasePathKey = common.ConfigKey(common.LogsKey, common.MetricsCollectedKey, common.KubernetesKey)
prometheusBasePathKey = common.ConfigKey(common.LogsKey, common.MetricsCollectedKey, common.PrometheusKey)
emfProcessorBasePathKey = common.ConfigKey(prometheusBasePathKey, common.EMFProcessorKey)
endpointOverrideKey = common.ConfigKey(common.LogsKey, common.EndpointOverrideKey)
)

type translator struct {
Expand Down Expand Up @@ -78,6 +81,11 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) {
}
}
cfg.AWSSessionSettings.Region = agent.Global_Config.Region
if c.IsSet(endpointOverrideKey) {
cfg.AWSSessionSettings.Endpoint, _ = common.GetString(c, endpointOverrideKey)
}
cfg.AWSSessionSettings.CertificateFilePath = os.Getenv(envconfig.AWS_CA_BUNDLE)
bhanuba marked this conversation as resolved.
Show resolved Hide resolved
cfg.AWSSessionSettings.Region = agent.Global_Config.Region
if profileKey, ok := agent.Global_Config.Credentials[agent.Profile_Key]; ok {
cfg.AWSSessionSettings.Profile = fmt.Sprintf("%v", profileKey)
}
Expand All @@ -98,7 +106,6 @@ func (t *translator) Translate(c *confmap.Conf) (component.Config, error) {
return nil, err
}
}

return cfg, nil
}

Expand Down