Skip to content

Conversation

@zmoog
Copy link
Contributor

@zmoog zmoog commented Jan 7, 2025

Proposed commit message

Change the mapping type for the aws.dimensions field from flattened to object.

Currently, all *_metrics data streams but one use the object mapping. The cloudwatch_metrics data stream uses the flattened type instead.

We need to unify the mapping of aws.dimensions across all metrics-related data streams in the AWS integration.
If all data streams use the exact mapping for aws.dimensions, users will be able to query and build a dashboard that correlates data across different data streams.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

Related issues

…c#11883) Change the mapping type for the `aws.dimensions` field from `flattened` to `object`. Currently, all `*_metrics` data streams but one use the `object` mapping. The `cloudwatch_metrics` data stream uses the `flattened` type instead. We need to unify the mapping of `aws.dimensions` across all metrics-related data streams in the AWS integration. If all data streams use the exact mapping for `aws.dimensions`, users will be able to query and build a dashboard that correlates data across different data streams. # Conflicts: #	packages/aws/changelog.yml #	packages/aws/manifest.yml
@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

@zmoog zmoog self-assigned this Jan 7, 2025
@zmoog
Copy link
Contributor Author

zmoog commented Jan 7, 2025

I tested the upgrade from AWS integration 2.30.2 to 2.30.3 (the unreleased changes from this PR) with the following steps:

  • Started a brand new local stack (8.15.4)
  • Installed AWS integration 2.30.2 (with aws.dimensions as flattened)
  • Started sending 1 document every 5 secs, including a field containing a sequence number
  • Upgraded the AWS integration to 2.30.3 (unreleased, this PR)
  • Waited for the rollout to take effect (checking settings.index.time_series | .start_time, .end_time)
  • Checked that the the data stream didn't lose any sequence number

More details on selected steps.

Started sending 1 document every 5 secs

  • create an API key on the local stack
  • export env vars for the es tool.

Set up the es tool config:

export ELASTICSEARCH_ENDPOINTS="https://localhost:9200" export ELASTICSEARCH_API_KEY="[redacted, event if it is not need since it's local]"

I used the following shell script:

sequence=0 while true do cat > metrics.json <<EOF {  "@timestamp": "$(date '+%Y-%m-%dT%H:%M:%S%z')",  "aws": {  "dimensions": {  "name": "Maurizio Branca",  "AutoScalingGroupName": "whatever"  },  "metric": {  "cpu": 10,  "sequence": $sequence  }  } }  EOF ((sequence++)) cat metrics.json | jq -c | es docs bulk -f - -i metrics-aws.cloudwatch_metrics-sdh5390 sleep 5 done

Results in:

2025/01/07 12:54:11 adding a new document: {"@timestamp":"2025-01-07T12:54:11+0100","aws":{"dimensions":{"name":"Maurizio Branca","AutoScalingGroupName":"whatever"},"metric":{"cpu":10,"sequence":0}}} 2025/01/07 12:54:11 closing bulk indexer 2025/01/07 12:54:11 Successfully indexed document 2025/01/07 12:54:11 bulk indexer closed 2025/01/07 12:54:11 getting bulk indexer stats 2025/01/07 12:54:11 Stats: {NumAdded:1 NumFlushed:1 NumFailed:0 NumIndexed:0 NumCreated:1 NumUpdated:0 NumDeleted:0 NumRequests:1}

The scripts sends a document like the following every 5 secs:

{ "@timestamp": "2024-12-31T00:14:58+0100", "aws": { "dimensions": { "name": "Maurizio Branca", "AutoScalingGroupName": "whatever" }, "metric": { "cpu": 10, "sequence": 270 } } }

CleanShot 2025-01-07 at 12 58 58@2x

Upgraded the AWS integration to 2.30.3 (unreleased, this PR)

Upgrade the AWS integration package from 2.30.2 to 2.30.3.

CleanShot 2025-01-07 at 13 02 42@2x

Waited for the rollout to take effect

Right after the upgrade, Fleet/ES creates a new -000002 index, but keeps writing to the -000001 index until the settings.index.time_series.end_time elapses.

Old index -000001:

// GET metrics-aws.cloudwatch_metrics-sdh5390/_settings { ".ds-metrics-aws.cloudwatch_metrics-sdh5390-2025.01.07-000001": { "settings": { "index": { "mapping": { "total_fields": { "limit": "1000", "ignore_dynamic_beyond_limit": "true" } }, "hidden": "true", "time_series": { "end_time": "2025-01-07T12:33:16.000Z", "start_time": "2025-01-07T09:54:11.000Z" },

New index -000002:

// GET metrics-aws.cloudwatch_metrics-sdh5390/_settings { ".ds-metrics-aws.cloudwatch_metrics-sdh5390-2025.01.07-000002": { "settings": { "index": { "mapping": { "total_fields": { "limit": "1000", "ignore_dynamic_beyond_limit": "true" } }, "hidden": "true", "time_series": { "end_time": "2025-01-07T13:03:16.000Z", "start_time": "2025-01-07T12:33:16.000Z" },

Now I need to wait until 2025-01-07T12:33:16.000Z (UTC) to see if the ES smoothly transitions from index -000001 to -000002.

CleanShot 2025-01-07 at 13 07 54@2x

Checked that the the data stream didn't lose any sequence number

At 2025-01-07T12:33:16.000Z, ES successfully transitioned from index -000001 to -000002 and from flattened to object field mapping.

image

@zmoog zmoog marked this pull request as ready for review January 7, 2025 12:45
@zmoog zmoog requested review from a team as code owners January 7, 2025 12:45
@zmoog zmoog changed the title [aws] [cloudwatch_metrics] Map aws.dimensions field as object (#11883) [aws] [cloudwatch_metrics] Map aws.dimensions field as object (backport of #11883) Jan 7, 2025
@andrewkroh andrewkroh added the Team:obs-ds-hosted-services Observability Hosted Services team [elastic/obs-ds-hosted-services] label Jan 7, 2025
Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com> Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co>
@andrewkroh andrewkroh added the enhancement New feature or request label Jan 7, 2025
@zmoog zmoog added the Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] label Jan 7, 2025
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @zmoog

Copy link
Contributor

@muthu-mps muthu-mps left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@zmoog zmoog merged commit 05bd8c4 into elastic:backport-aws-2.30 Jan 8, 2025
5 checks passed
@zmoog zmoog deleted the zmoog/backport-11883-aws-dimensions-mappings branch January 8, 2025 08:32
@elastic-vault-github-plugin-prod

Package aws - 2.30.3 containing this change is available at https://epr.elastic.co/package/aws/2.30.3/

qcorporation pushed a commit that referenced this pull request Feb 4, 2025
…rt of #11883) (#12237) Change the mapping type for the `aws.dimensions` field from `flattened` to `object`. Currently, all `*_metrics` data streams but one use the `object` mapping. The `cloudwatch_metrics` data stream uses the `flattened` type instead. We need to unify the mapping of `aws.dimensions` across all metrics-related data streams in the AWS integration. If all data streams use the exact mapping for `aws.dimensions`, users will be able to query and build a dashboard that correlates data across different data streams. --------- Co-authored-by: muthu-mps <101238137+muthu-mps@users.noreply.github.com> Co-authored-by: Andrew Gizas <andreas.gkizas@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request Integration:aws AWS Team:obs-ds-hosted-services Observability Hosted Services team [elastic/obs-ds-hosted-services] Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

5 participants