Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into add-logs-agent-integ-…
Browse files Browse the repository at this point in the history
…test
  • Loading branch information
varunch77 committed Dec 4, 2024
2 parents 6afee5f + 0d7b114 commit b1b10cd
Show file tree
Hide file tree
Showing 13 changed files with 337 additions and 312 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/PR-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ jobs:
- name: Check out code
if: needs.changes.outputs.lint == 'true'
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Check format
if: needs.changes.outputs.lint == 'true'
Expand All @@ -67,7 +69,7 @@ jobs:
- name: Check license and imports
if: needs.changes.outputs.lint == 'true'
run: make simple-lint
run: make lint

build:
needs: [lint, changes]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ jobs:
uses: nick-fields/retry@v2
with:
max_attempts: 3
timeout_minutes: 30
timeout_minutes: 60
retry_wait_seconds: 5
command: |
if [ "${{ matrix.arrays.terraform_dir }}" != "" ]; then
Expand Down
14 changes: 8 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ output:

# All available settings of specific linters
linters-settings:
revive:
# minimal confidence for issues, default is 0.8
min-confidence: 0.7
gofmt:
# Simplify code: gofmt with `-s` option, true by default
simplify: true
Expand All @@ -49,12 +46,17 @@ linters-settings:
linters:
disable:
- errcheck
enable:
- gofmt
- goimports
enable:
- gosimple
- gosec
- unused
- gosimple
- govet
- ineffassign
- misspell
- revive
- unused
- nonamedreturns

issues:
new-from-rev: 3221f76
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ install-addlicense:
install-golangci-lint:
#Install from source for golangci-lint is not recommended based on https://golangci-lint.run/usage/install/#install-from-source so using binary
#installation
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN_DIR) v1.50.1
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN_DIR) v1.62.2

fmt: install-goimports addlicense
go fmt ./...
Expand Down
8 changes: 8 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
========================================================================
Amazon CloudWatch Agent 1.300050.0 (2024-11-18)
========================================================================
Features:
* [Prometheus] Introduce OTel Prometheus Receiver for publishing to AMP
* [Prometheus] Support Target Allocator with Prometheus Receivers
* [ContainerInsights] Introduce Kueue metrics for Container Insights

========================================================================
Amazon CloudWatch Agent 1.300049.1 (2024-11-06)
========================================================================
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ require (
github.com/dennwc/varint v1.0.0 // indirect
github.com/digitalocean/godo v1.109.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/docker v26.1.4+incompatible // indirect
github.com/docker/docker v26.1.5+incompatible // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/doclambda/protobufquery v0.0.0-20210317203640-88ffabe06a60 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@ github.com/djherbis/times v1.5.0 h1:79myA211VwPhFTqUk8xehWrsEO+zcIZj0zT8mXPVARU=
github.com/djherbis/times v1.5.0/go.mod h1:5q7FDLvbNg1L/KaBmPcWlVR9NmoKo3+ucqUA3ijQhA0=
github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI=
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
github.com/docker/docker v26.1.4+incompatible h1:vuTpXDuoga+Z38m1OZHzl7NKisKWaWlhjQk7IDPSLsU=
github.com/docker/docker v26.1.4+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v26.1.5+incompatible h1:NEAxTwEjxV6VbBMBoGG3zPqbiJosIApZjxlbrG9q3/g=
github.com/docker/docker v26.1.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c=
github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
Expand Down
39 changes: 1 addition & 38 deletions plugins/outputs/cloudwatch/convert_otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func ConvertOtelMetric(m pmetric.Metric, entity cloudwatch.Entity) []*aggregatio
func ConvertOtelMetrics(m pmetric.Metrics) []*aggregationDatum {
datums := make([]*aggregationDatum, 0, m.DataPointCount())
for i := 0; i < m.ResourceMetrics().Len(); i++ {
entity := fetchEntityFields(m.ResourceMetrics().At(i).Resource().Attributes())
entity := entityattributes.CreateCloudWatchEntityFromAttributes(m.ResourceMetrics().At(i).Resource().Attributes())
scopeMetrics := m.ResourceMetrics().At(i).ScopeMetrics()
for j := 0; j < scopeMetrics.Len(); j++ {
metrics := scopeMetrics.At(j).Metrics()
Expand All @@ -184,40 +184,3 @@ func ConvertOtelMetrics(m pmetric.Metrics) []*aggregationDatum {
}
return datums
}

func fetchEntityFields(resourceAttributes pcommon.Map) cloudwatch.Entity {
keyAttributesMap := map[string]*string{}
attributeMap := map[string]*string{}
platformType := ""
if platformTypeValue, ok := resourceAttributes.Get(entityattributes.AttributeEntityPlatformType); ok {
platformType = platformTypeValue.Str()
}
processEntityAttributes(entityattributes.GetKeyAttributeEntityShortNameMap(), keyAttributesMap, resourceAttributes)
processEntityAttributes(entityattributes.GetAttributeEntityShortNameMap(platformType), attributeMap, resourceAttributes)
removeEntityFields(resourceAttributes)
if _, ok := keyAttributesMap[entityattributes.AwsAccountId]; !ok {
return cloudwatch.Entity{}
}
return cloudwatch.Entity{
KeyAttributes: keyAttributesMap,
Attributes: attributeMap,
}
}

// processEntityAttributes fetches the fields with entity prefix and creates an entity to be sent at the PutMetricData call.
func processEntityAttributes(entityMap map[string]string, targetMap map[string]*string, mutableResourceAttributes pcommon.Map) {
for entityField, shortName := range entityMap {
if val, ok := mutableResourceAttributes.Get(entityField); ok {
if strVal := val.Str(); strVal != "" {
targetMap[shortName] = aws.String(strVal)
}
}
}
}

// removeEntityFields so that it is not tagged as a dimension, and reduces the size of the PMD payload.
func removeEntityFields(mutableResourceAttributes pcommon.Map) {
mutableResourceAttributes.RemoveIf(func(s string, _ pcommon.Value) bool {
return strings.HasPrefix(s, entityattributes.AWSEntityPrefix)
})
}
Loading

0 comments on commit b1b10cd

Please sign in to comment.