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

apmpackage: define DLM retention periods in apm package #11539

Merged
merged 6 commits into from
Sep 1, 2023

Conversation

kyungeunni
Copy link
Contributor

@kyungeunni kyungeunni commented Aug 31, 2023

Motivation/summary

Define DLM retention periods corresponding to the default ILM policy's policy.delete.min_age to support DLM when configured.

Checklist

For functional changes, consider:

  • Is it observable through the addition of either logging or metrics?
  • Is its use being published in telemetry to enable product improvement?
  • Have system tests been added to avoid regression?

How to test these changes

  1. Run tilt up

  2. Open Kibana, go to Index Management > Index Template, and choose one of the templates APM server manages, for example: metrics-apm.service_summary.1m

  3. Check the lifecycle is pointing to the ILM policy
    image

  4. Run tilt down, add xpack.fleet.internal.disableILMPolicies: true to the config section in the testing/infra/k8s/base/stack/kibana.yaml file. (This mimics the serverless config https://github.com/elastic/kibana/pull/154460/files#diff-ebeb9e9dc4c3ee5e81f743f0eda3c06f1fc161a11127b374d21f0da5e6368fd9R2)

  5. Run tilt up again, navigate to Index Management, and observe the lifecycle is now using data_rentention rather than the ILM policy.
    image

  6. Now, modify the retention period in apmpackage/apm/data_stream/service_summary_interval_metrics/lifecycle.1m.yml to 1m, and when the apmpackage is reinstalled, generate some load so that the datastream is created.

  7. Go to Dev Tool, and confirm the data_retention for the datastream is correctly set by running the following:

GET _data_stream/metrics-apm.service_summary.1m-default/_lifecycle

Should see

{
  "data_streams": [
    {
      "name": "metrics-apm.service_summary.1m-default",
      "lifecycle": {
        "enabled": true,
        "data_retention": "1m"
      }
    }
  ]
}
  1. See the documents are all deleted after a while (it's not precisely 1 minute to get deleted, so you might need to wait a bit longer than the data_retention period)

Related issues

@mergify
Copy link
Contributor

mergify bot commented Aug 31, 2023

This pull request does not have a backport label. Could you fix it @kyungeunni? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-7.17 is the label to automatically backport to the 7.17 branch.
  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.

NOTE: backport-skip has been added to this pull request.

@mergify mergify bot added the backport-skip Skip notification from the automated backport with mergify label Aug 31, 2023
@kyungeunni kyungeunni marked this pull request as ready for review September 1, 2023 04:31
@kyungeunni kyungeunni requested a review from a team as a code owner September 1, 2023 04:31
@kyungeunni kyungeunni self-assigned this Sep 1, 2023
@kyungeunni kyungeunni changed the title Define DLM retention periods in apm package apmpackage: define DLM retention periods in apm package Sep 1, 2023
@mergify
Copy link
Contributor

mergify bot commented Sep 1, 2023

This pull request is now in conflicts. Could you fix it @kyungeunni? 🙏
To fixup this pull request, you can check out it locally. See documentation: https://help.github.com/articles/checking-out-pull-requests-locally/

git fetch upstream
git checkout -b add-dlm upstream/add-dlm
git merge upstream/main
git push upstream add-dlm

@kyungeunni kyungeunni enabled auto-merge (squash) September 1, 2023 08:43
@kyungeunni kyungeunni merged commit 9b9cfd4 into elastic:main Sep 1, 2023
11 checks passed
@kyungeunni kyungeunni deleted the add-dlm branch September 1, 2023 09:30
bmorelli25 pushed a commit to bmorelli25/apm-server that referenced this pull request Sep 5, 2023
* feat: add DLM definitions for datastreams

* chore: update elastic-package version

* fix: update package format_version to 2.11.0

* chore: update CHANGELOGs
@axw axw self-assigned this Oct 23, 2023
@axw
Copy link
Member

axw commented Oct 23, 2023

Assigning to myself for testing

@axw
Copy link
Member

axw commented Oct 23, 2023

Looks good in serverless project. Here's a jq oneliner that works with the output of GET /_component_template:

jq -S '.[] | map(select(.name | endswith("@package"))) | map({(.name): .component_template.template.lifecycle.data_retention}) | add' component_templates.json 
{
  "logs-apm.app@package": "10d",
  "logs-apm.error@package": "10d",
  "metrics-apm.app@package": "90d",
  "metrics-apm.internal@package": "90d",
  "metrics-apm.service_destination.10m@package": "180d",
  "metrics-apm.service_destination.1m@package": "90d",
  "metrics-apm.service_destination.60m@package": "390d",
  "metrics-apm.service_summary.10m@package": "180d",
  "metrics-apm.service_summary.1m@package": "90d",
  "metrics-apm.service_summary.60m@package": "390d",
  "metrics-apm.service_transaction.10m@package": "180d",
  "metrics-apm.service_transaction.1m@package": "90d",
  "metrics-apm.service_transaction.60m@package": "390d",
  "metrics-apm.transaction.10m@package": "180d",
  "metrics-apm.transaction.1m@package": "90d",
  "metrics-apm.transaction.60m@package": "390d",
  "traces-apm.rum@package": "90d",
  "traces-apm.sampled@package": "1h",
  "traces-apm@package": "10d"
}

ILM policies continue to be installed in stateful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-skip Skip notification from the automated backport with mergify test-plan test-plan-ok v8.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants