Este contenido no está disponible en el idioma seleccionado.

Chapter 2. Configuration of a custom trigger for a dynamic recording


When you configure your target application to load the Cryostat agent, you can define one or more custom triggers that are then passed as arguments to the agent.

For more information about configuring a target application to load the Cryostat agent, see Configuring Java applications.

Note

Even if you use the Cryostat Operator to configure the agent automatically, you must still define any custom triggers manually in your application deployment, as described in Options for defining a custom trigger. In this situation, OpenShift Container Platform automatically redeploys any pods that are associated with your reconfigured application deployment, as appropriate.

2.1. Options for defining a custom trigger

You can define a custom trigger in any of the following ways:

Appending a custom trigger to the Cryostat agent’s JAR file path

The following example shows how to append a simple custom trigger to the Cryostat agent’s JAR file path:

JAVA_OPTS="-javaagent:/deployments/app/cryostat-agent-shaded.jar=\"[ProcessCpuLoad > 0.2 ; TargetDuration > duration('30s')]~profile\""

The preceding example trigger instructs the agent to start a JFR recording if the ProcessCpuLoad metric has a value greater than 0.2 for a duration of more than 30 seconds: This example also instructs the agent to use the profile event template for the JFR recording.

Using a JVM system property flag

The following example shows how to specify a simple custom trigger by using a JVM system property flag:

-Dcryostat.agent.smart-trigger.definitions="[ProcessCpuLoad > 0.2 ; TargetDuration > duration(\"30s\")]~profile"

This example uses the same custom trigger criteria as the preceding example.

Using an environment variable

The following example shows how to specify a simple custom trigger by using an environment variable:

- name: CRYOSTAT_AGENT_SMART_TRIGGER_DEFINITIONS
  value: "[ProcessCpuLoad > 0.2 ; TargetDuration > duration(\"30s\")]~profile"

This example uses the same custom trigger criteria as the preceding examples.

2.2. Options for defining file-based custom triggers

From Cryostat 4.1 onward, as an alternative to configuring custom triggers explicitly, you can define custom triggers in one or more text files and specify the file path as a configuration value instead. If you specify a file path, the Cryostat agent checks this location for any files that contain custom trigger definitions.

You can configure a file path for file-based custom triggers in either of the following ways:

Using a JVM system property flag

The following example shows how to specify a file path for file-based custom triggers by using a JVM system property flag:

-Dcryostat.agent.smart-trigger.config.path=__<file_path>__

The default value is an empty string.

Using an environment variable

The following example shows how to specify a file path for file-based custom triggers by using an environment variable:

- name: CRYOSTAT_AGENT_SMART_TRIGGER_CONFIG_PATH
  value: _<file_path>_

The default value is an empty string.

2.3. Common Expression Language

You can use Common Expression Language (CEL) to define a custom trigger condition. CEL is a free-form expression syntax that provides great flexibility in defining rules and constraints for evaluating data. For example, you can use CEL to create relational statements for evaluating if any combination of MBean counter types have current values greater than, equal to, or less than specified configurable values. You can also include any combination of AND (&&) or OR (||) logic statements between different MBean counter types that are part of the same trigger condition.

For more information about CEL, see the CEL language specification.

2.4. General syntax rules for custom triggers

Consider the following syntax guidelines for defining custom triggers:

  • A custom trigger definition must consist of both an expression that defines the overall trigger condition and the name of an event template that is used for the JFR recording.
  • The entire trigger expression must be enclosed in square brackets (for example, [ProcessCpuLoad > 0.2 ; TargetDuration < duration("30s")]).
  • For readability, you may use white space in a trigger expression as shown in the preceding example, but this is not a requirement.
  • The name of the event template must be defined after the trigger expression and preceded by a tilde (~) character (for example, ~profile).
  • A trigger expression can consist of one or more constraints and a target duration. The set of constraints and target duration must be separated by a semicolon (;) character.
  • Each constraint must include: the name of an MBean counter; a relational operator such as > (greater than), = (equal to), < (less than), and so on; and a specified value. The type of relational operator and value that you can specify depends on the associated MBean counter type (for example, ProcessCpuLoad > 0.2).
  • Constraints can be grouped together by using logical operators such as && (AND), || (OR), or ! (NOT) logic. For readability and clarity around the order of operations and operator precedence, grouped constraints may be enclosed in round brackets, but this is not a requirement. For example:

    [(MetricA > value1 && MetricB < value2) || MetricC == 'stringvalue' ; TargetDuration > duration("30s")]
  • The name of each MBean counter that is specified as part of a custom trigger must follow precise syntax rules in terms of spelling and capitalization. For a full list of the MBean metrics that you can specify, see MBean counter types.
  • Only one target duration can be defined for a custom trigger. The target duration is applied to the entire trigger expression that is enclosed within the square brackets.
  • A target duration can be expressed in terms of seconds, minutes, or hours. For example, 30s means 30 seconds, 5m means five minutes, 2h means two hours, and so on.
  • A target duration is optional. If a target duration is not specified, triggering will occur immediately once the trigger conditions are met.
  • Multiple custom trigger definitions can be specified together, each of which relates to a separate JFR recording. Different custom trigger definitions must be separated by a comma (,) character. For example:

    [ProcessCpuLoad>0.2]~profile,[ThreadCount>30]~Continuous
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2026 Red Hat
Volver arriba