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

feat(rules): implement "archive" rules #648

Merged
merged 12 commits into from
Aug 19, 2021

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Aug 18, 2021

Closes #645

Fixes #643

This implements an alternative and simplified version of the "one-shot" rules.

If a Rule definition is given where "eventSpecifier":"archive", the rule definition will not be persisted, does not require a unique name, may not have archivalPeriodSeconds/preservedArchives/maxAge/maxSize, and rather than starting a new recording will cause a snapshot to be taken, copied to archives, and the snapshot immediately removed.

The motivation is to allow a user to have a workflow such as the following:

POST /api/v2/rules
{
    "name": "monitor",
    "description": "Monitor application, all the time",
    "eventSpecifier": "template=Continuous",
    "matchExpression": "target.labels.app=='MyApp'",
    "archivalPeriodSeconds": 3600,
    "maxAgeSeconds": 300,
    "preservedArchives": 6
}

Wait some time and observe application metrics (JFR or otherwise), either manually or by an external automated process. When some trigger event occurs, such as resource utilization exceeding a threshold for longer than some duration, the user wants to get copies of their application's JFR data at that moment and for the previous lookback window (5min in this case due to maxAgeSeconds).

Note that this rule configuration gives the user a 5min window of data in the recording at any time, and that that 5 minute sample will be copied to archives only once per hour (3600 seconds). 6 such copies will be retained in the archives at any given time. Such a configuration could be used to gather ongoing continuous monitoring data, leaving long gaps in between archival periods to prevent excessive use of disk space, for example.

Alternatively, the rule definition may only start a continuous recording in the targets, without any configuration for periodic archiving.

POST /api/v2/rules
{
    "eventSpecifier": "archive",
    "matchExpression": "target.labels.app=='MyApp'"
}

After POSTing this second rule definition, Cryostat will connect to all of the same original set of targets and perform the snapshot/archive/remove snapshot procedure as explained earlier. The original recordings created by the first rule are still in place and running, so the user may re-POST the second rule definition as many times as they wish in the future as more external trigger events occur.

@andrewazores andrewazores added the feat New feature or request label Aug 18, 2021
@andrewazores andrewazores marked this pull request as ready for review August 18, 2021 19:04
Copy link
Contributor

@jan-law jan-law left a comment

Choose a reason for hiding this comment

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

Looks good otherwise

src/main/java/io/cryostat/rules/Rule.java Show resolved Hide resolved
Copy link
Contributor

@hareetd hareetd left a comment

Choose a reason for hiding this comment

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

Looks good

@andrewazores andrewazores merged commit e46209f into cryostatio:main Aug 19, 2021
@andrewazores andrewazores deleted the archive-rule branch August 19, 2021 16:42
tthvo pushed a commit to tthvo/cryostat-legacy that referenced this pull request Dec 9, 2024
…ryostatio#648)

Bumps [com.nimbusds:nimbus-jose-jwt](https://bitbucket.org/connect2id/nimbus-jose-jwt) from 9.40 to 9.41.1.
- [Changelog](https://bitbucket.org/connect2id/nimbus-jose-jwt/src/master/CHANGELOG.txt)
- [Commits](https://bitbucket.org/connect2id/nimbus-jose-jwt/branches/compare/9.41.1..9.40)

---
updated-dependencies:
- dependency-name: com.nimbusds:nimbus-jose-jwt
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request
Projects
None yet
3 participants