Skip to content

Implement dimension settings using MetricDeclarations #2

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

Closed
wants to merge 50 commits into from

Conversation

kohrapha
Copy link
Collaborator

@kohrapha kohrapha commented Oct 13, 2020

Description
This PR implements the necessary functionality to perform dimension setting for exported metrics, as required by the ECS team. Specifically, this PR accomplishes the following:

  1. Create a new metric_declarations attribute in the config file which specifies the rules used for dimension setting.
  2. Apply rules to metrics whose metric names match at least one of the specified metric_name_selectors for that rule. If no selectors are defined, this rule is dropped as invalid.
  3. Set exported dimensions (within _aws field) using the dimensions specified by the metric declaration rules. If the metric does not match any rules or specified dimensions, drop the metric (i.e. don't include the _aws field). If any specified dimensions exceed 10 elements, drop them as CW does not support them.
  4. Ensure that dimension rollup works well with dimension setting.
  5. Implement tests for the new functionality.

Additionally, the following sanity checks for user-defined metric declarations are implemented:

  1. Duplicated dimensions in a dimension set are removed (i.e. ['dim1', 'dim2', 'dim1'] -> ['dim1', 'dim2'])
  2. Duplicated dimension sets in a metric declaration are removed (i.e. [['dim1', 'dim2'], ['dim2', 'dim1']] -> [['dim1', 'dim2']])
  3. Dimension sets with more than 10 dimensions are removed.

In all 3 cases, we output a warning message informing the user of the dropped elements. More information about this dedup logic can be found in #6.

Testing
This code change has been tested with unit tests and in a sample environment using an NGINX server on EKS. Given the following config:

exporters:
  awsemf:
    log_group_name: 'awscollector-test'
    region: 'us-west-2'
    log_stream_name: metric-declarations
    dimension_rollup_option: 'NoDimensionRollup'
    metric_declarations:
    - dimensions: [['Service', 'Namespace'], ['pod_name', 'container_name']]
      metric_name_selectors:
      - '^go_memstats_alloc_bytes_total$'
    - dimensions: [['app_kubernetes_io_component', 'Namespace'], ['app_kubernetes_io_name'], ['Invalid', 'Namespace']]
      metric_name_selectors:
      - '^go_goroutines$'
    - dimensions: [['Namespace', 'Service', 'Namespace']]
      metric_name_selectors:
      - '^go_mem.+$'

The exported CW logs look like this:

1 matching rule (w/ 1 unmatched dimension):
go_goroutines:

{
    "Namespace": "eks-aoc",
    "Service": "my-nginx-ingress-nginx-controller-metrics",
    "_aws": {
        "CloudWatchMetrics": [
            {
                "Namespace": "metric-declarations",
                "Dimensions": [
                    [
                        "Namespace",
                        "app_kubernetes_io_component"
                    ],
                    [
                        "app_kubernetes_io_name"
                    ]
                ],
                "Metrics": [
                    {
                        "Name": "go_goroutines",
                        "Unit": ""
                    }
                ]
            }
        ],
        "Timestamp": 1604431600752
    },
    "app_kubernetes_io_component": "controller",
    "app_kubernetes_io_instance": "my-nginx",
    "app_kubernetes_io_managed_by": "Helm",
    "app_kubernetes_io_name": "ingress-nginx",
    "app_kubernetes_io_version": "0.40.2",
    "container_name": "controller",
    "go_goroutines": 93,
    "helm_sh_chart": "ingress-nginx-3.7.1",
    "kubernetes_node": "ip-192-168-69-5.us-west-2.compute.internal",
    "pod_name": "my-nginx-ingress-nginx-controller-77d5fd6977-mlc8k"
}

1 matching rule (w/ dedup):
go_memstats_alloc_bytes:

{
    "Namespace": "eks-aoc",
    "Service": "my-nginx-ingress-nginx-controller-metrics",
    "_aws": {
        "CloudWatchMetrics": [
            {
                "Namespace": "metric-declarations",
                "Dimensions": [
                    [
                        "Namespace",
                        "Service"
                    ]
                ],
                "Metrics": [
                    {
                        "Name": "go_memstats_alloc_bytes",
                        "Unit": "By"
                    }
                ]
            }
        ],
        "Timestamp": 1604431600752
    },
    "app_kubernetes_io_component": "controller",
    "app_kubernetes_io_instance": "my-nginx",
    "app_kubernetes_io_managed_by": "Helm",
    "app_kubernetes_io_name": "ingress-nginx",
    "app_kubernetes_io_version": "0.40.2",
    "container_name": "controller",
    "go_memstats_alloc_bytes": 6938768,
    "helm_sh_chart": "ingress-nginx-3.7.1",
    "kubernetes_node": "ip-192-168-69-5.us-west-2.compute.internal",
    "pod_name": "my-nginx-ingress-nginx-controller-77d5fd6977-mlc8k"
}

2 matching rules w/ dedup):

{
    "Namespace": "eks-aoc",
    "Service": "my-nginx-ingress-nginx-controller-metrics",
    "_aws": {
        "CloudWatchMetrics": [
            {
                "Namespace": "metric-declarations",
                "Dimensions": [
                    [
                        "Namespace",
                        "Service"
                    ],
                    [
                        "container_name",
                        "pod_name"
                    ]
                ],
                "Metrics": [
                    {
                        "Name": "go_memstats_alloc_bytes_total",
                        "Unit": ""
                    }
                ]
            }
        ],
        "Timestamp": 1604431600752
    },
    "app_kubernetes_io_component": "controller",
    "app_kubernetes_io_instance": "my-nginx",
    "app_kubernetes_io_managed_by": "Helm",
    "app_kubernetes_io_name": "ingress-nginx",
    "app_kubernetes_io_version": "0.40.2",
    "container_name": "controller",
    "go_memstats_alloc_bytes_total": 0,
    "helm_sh_chart": "ingress-nginx-3.7.1",
    "kubernetes_node": "ip-192-168-69-5.us-west-2.compute.internal",
    "pod_name": "my-nginx-ingress-nginx-controller-77d5fd6977-mlc8k"
}

No matching rule:

{
    "Namespace": "eks-aoc",
    "Service": "my-nginx-ingress-nginx-controller-metrics",
    "app_kubernetes_io_component": "controller",
    "app_kubernetes_io_instance": "my-nginx",
    "app_kubernetes_io_managed_by": "Helm",
    "app_kubernetes_io_name": "ingress-nginx",
    "app_kubernetes_io_version": "0.40.2",
    "container_name": "controller",
    "go_info": 1,
    "helm_sh_chart": "ingress-nginx-3.7.1",
    "kubernetes_node": "ip-192-168-69-5.us-west-2.compute.internal",
    "pod_name": "my-nginx-ingress-nginx-controller-77d5fd6977-mlc8k",
    "version": "go1.15.2"
}

Documentation
The documentation in the README for the awsemfexporter is also updated to include this new API change.

@kohrapha kohrapha self-assigned this Oct 13, 2020
@kohrapha kohrapha requested a review from hdj630 October 14, 2020 22:00
@kohrapha
Copy link
Collaborator Author

Tagging @mxiamxia

@kohrapha kohrapha marked this pull request as draft October 21, 2020 21:08
Base automatically changed from kohrapha/datapoints to master October 21, 2020 22:25
@kohrapha kohrapha marked this pull request as ready for review October 28, 2020 19:30
#1446)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.35.17 to 1.35.19.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.35.17...v1.35.19)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@kohrapha kohrapha force-pushed the kohrapha/metric-declarations branch from 8936787 to 6a0c283 Compare November 2, 2020 21:09
@kohrapha kohrapha changed the base branch from master to development November 2, 2020 21:11
dependabot bot and others added 16 commits November 2, 2020 13:42
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.35.17 to 1.35.20.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.35.17...v1.35.20)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.32.0 to 1.33.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.32.0...v1.33.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.32.0 to 1.33.1.
- [Release notes](https://github.com/grpc/grpc-go/releases)
- [Commits](grpc/grpc-go@v1.32.0...v1.33.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [github.com/golang/protobuf](https://github.com/golang/protobuf) from 1.4.2 to 1.4.3.
- [Release notes](https://github.com/golang/protobuf/releases)
- [Commits](golang/protobuf@v1.4.2...v1.4.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [go.opencensus.io](https://github.com/census-instrumentation/opencensus-go) from 0.22.4 to 0.22.5.
- [Release notes](https://github.com/census-instrumentation/opencensus-go/releases)
- [Commits](census-instrumentation/opencensus-go@v0.22.4...v0.22.5)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…#1457)

Bumps [go.opencensus.io](https://github.com/census-instrumentation/opencensus-go) from 0.22.4 to 0.22.5.
- [Release notes](https://github.com/census-instrumentation/opencensus-go/releases)
- [Commits](census-instrumentation/opencensus-go@v0.22.4...v0.22.5)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [github.com/klauspost/compress](https://github.com/klauspost/compress) from 1.11.1 to 1.11.2.
- [Release notes](https://github.com/klauspost/compress/releases)
- [Changelog](https://github.com/klauspost/compress/blob/master/.goreleaser.yml)
- [Commits](klauspost/compress@v1.11.1...v1.11.2)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [k8s.io/client-go](https://github.com/kubernetes/client-go) from 0.19.2 to 0.19.3.
- [Release notes](https://github.com/kubernetes/client-go/releases)
- [Changelog](https://github.com/kubernetes/client-go/blob/master/CHANGELOG.md)
- [Commits](kubernetes/client-go@v0.19.2...v0.19.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

Bumps [gopkg.in/DataDog/dd-trace-go.v1](https://github.com/DataDog/dd-trace-go) from 1.26.0 to 1.27.1.
- [Release notes](https://github.com/DataDog/dd-trace-go/releases)
- [Commits](DataDog/dd-trace-go@v1.26.0...v1.27.1)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.34.9 to 1.35.20.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.34.9...v1.35.20)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.32.0 to 0.34.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/master/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.32.0...v0.34.0)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.35.17 to 1.35.20.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.35.17...v1.35.20)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.35.17 to 1.35.20.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.35.17...v1.35.20)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…or (#1472)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.35.2 to 1.35.20.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.35.2...v1.35.20)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
#1452)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.35.19 to 1.35.20.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/master/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.35.19...v1.35.20)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
bogdandrutu and others added 11 commits November 3, 2020 10:01
* Move test as per CR comments

* Fix getting cached value

* Remove unneeded dependencies and config sections
Fix an error for the config file part.
* initial commit of ecs translation

* reverted trace ID change

* added unit tests

* addressed comments and unit test issues

* fixed breaking API changes
Resolves: open-telemetry/opentelemetry-collector#1841

This uses the new Span Status Code/DeprecatedCode from core repo.

Changes to Span Status are described in more details in this core PR:
open-telemetry/opentelemetry-collector#2031
* Fix the race condition issue for xray receiver

* Fix the race condition issue for xray receiver

* Fix the race condition issue for xray receiver

* Fix the race condition issue for xray receiver
Adds resource detection of hostname and host information when running on a bare host.

**Link to tracking Issue:** #1292 

**Testing:** Unit tests were added; processor was tested on a Linux and macOS host.

**Documentation:** 
- Updated README with the information gathered by this detector
- Updated examples
@kohrapha kohrapha force-pushed the kohrapha/metric-declarations branch from 5d8cbbd to a736ad0 Compare November 5, 2020 20:07
jchengsfx and others added 10 commits November 5, 2020 19:00
This adds a make target 'generate' that runs 'go generate' for all
modules.

It also adds a circle CI check under 'lint' that makes sure the
generated modules are up to date.
* Bump github.com/golangci/golangci-lint from 1.31.0 to 1.32.2

Bumps [github.com/golangci/golangci-lint](https://github.com/golangci/golangci-lint) from 1.31.0 to 1.32.2.
- [Release notes](https://github.com/golangci/golangci-lint/releases)
- [Changelog](https://github.com/golangci/golangci-lint/blob/master/CHANGELOG.md)
- [Commits](golangci/golangci-lint@v1.31.0...v1.32.2)

Signed-off-by: dependabot[bot] <[email protected]>

* Bump gopsutil to 3.20.10 instead

Signed-off-by: Juraci Paixão Kröhling <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Juraci Paixão Kröhling <[email protected]>
* Pass around config

* Attach logger to Config

* Add check for unhandled data type

* Format code
* Implement dimension dedup logic when adding rolledup dimensions

* Remove duplicated dimensions in metric declaration
@kohrapha kohrapha force-pushed the kohrapha/metric-declarations branch from a736ad0 to e6c1ff3 Compare November 6, 2020 18:13
@kohrapha
Copy link
Collaborator Author

kohrapha commented Nov 6, 2020

Opened PR to upstream: open-telemetry#1503

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.