From 09c5f42a473f2d1dd5f419b039882d3f32ef1d49 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:28:44 -0400 Subject: [PATCH 01/10] expression is CEL --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index 9be9893..78a0962 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -58,7 +58,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK
Create your Match Expression

- The Match Expression in a rule definition is a Java-like snippet of code that Cryostat interprets and uses to determine if a rule should be applied to any given target. Match Expressions should thus evaluate to a boolean value. The simplest Match Expressions would be the booleans true or false; if we use true, the rule will apply to every target. The Expression has a target object in global scope, with the following form in JSON notation: + The Match Expression in a rule definition is a Common Expression Language expression that Cryostat interprets and uses to determine if a rule should be applied to any given target. Match Expressions should thus evaluate to a boolean value. The simplest Match Expressions would be the booleans true or false; if we use true, the rule will apply to every target. The Expression has a target object in global scope, with the following form in JSON notation:

{% highlight json %} From af247a9cdae671866dac86b20a0e827b49f72654 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:28:51 -0400 Subject: [PATCH 02/10] target includes jvmId --- guides/_subsections/create-an-automated-rule.md | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index 78a0962..b11d758 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -63,6 +63,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK
{% highlight json %} { + "jvmId": "abcd1234", "alias": "myAppAlias", "connectUrl": "service:jmx:rmi:///jndi/rmi://cryostat:9091/jmxrmi", "labels": { From 12b8efcd9257016c52c55f95bf67b3a185a7ee45 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:29:34 -0400 Subject: [PATCH 03/10] spacing --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index b11d758..b9d1448 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -83,7 +83,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK {% endhighlight %}

- The Alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty—in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. + The Alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. Here are some examples of Match Expressions:

From bb6874a798002ef557d703640f0f30b2cd514db7 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:29:55 -0400 Subject: [PATCH 04/10] formatting --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index b9d1448..1d93b4f 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -83,7 +83,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK {% endhighlight %}

- The Alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. + The Alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. Here are some examples of Match Expressions:

From 5863ad6e4c2561b8a4ec9f6078d82038ddcc829f Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:30:16 -0400 Subject: [PATCH 05/10] capitalization --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index 1d93b4f..d0f9a03 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -83,7 +83,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK {% endhighlight %}

- The Alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. + The alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. Here are some examples of Match Expressions:

From b2e067e8e27467eea5b2f999eaeca5e5a8455409 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:32:48 -0400 Subject: [PATCH 06/10] link other guides --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index d0f9a03..f3e59a2 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -83,7 +83,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK {% endhighlight %}

- The alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. + The alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The jvmId is a hash string computed by Cryostat after it successfully connects to a target JVM and is used to uniquely identify that JVM instance - it will be empty if Cryostat has not yet connected to that target (for example, if its SSL/TLS certificate is not trusted or if Cryostat is missing the required credentials) The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. Here are some examples of Match Expressions:

From 94f111c8ba156652b17db0827507dccec3e47254 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:45:41 -0400 Subject: [PATCH 07/10] correct quotation marks --- guides/_subsections/create-an-automated-rule.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index f3e59a2..13a5343 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -90,19 +90,19 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK
{% highlight bash %} -target.alias == ’com.example.MainClass’ +target.alias == 'com.example.MainClass' -target.alias == ’myAlias’ +target.alias == 'myAlias' -target.labels[‘com.example/service’] == ’customer-login’ +target.labels[‘com.example/service’] == 'customer-login' -target.labels[‘com.example/service’] != ’customer-login’ +target.labels[‘com.example/service’] != 'customer-login' target.annotations.cryostat.PORT > 3000 -target.annotations.cryostat.PORT > 3000 && target.annotations.platform[‘io.kubernetes/annotation’] == ‘enabled’ +target.annotations.cryostat.PORT > 3000 && target.annotations.platform['io.kubernetes/annotation'] == 'enabled' -!!target.annotations.platform[‘io.kubernetes/annotation’] +!!target.annotations.platform['io.kubernetes/annotation'] /^customer-login[0-9]\*$/.test(target.alias) {% endhighlight %} From b3ec0197cff7dc3cd073557831292d2ab4effcde Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 15:45:50 -0400 Subject: [PATCH 08/10] correct regex syntax --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index 13a5343..709eb74 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -104,7 +104,7 @@ target.annotations.cryostat.PORT > 3000 && target.annotations.platform['io.kuber !!target.annotations.platform['io.kubernetes/annotation'] -/^customer-login[0-9]\*$/.test(target.alias) +target.alias.matches("^customer-login[0-9]\*$") {% endhighlight %}
From de509227b571f2b26f4e55b07eb7381f8ccde8f3 Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 16:55:05 -0400 Subject: [PATCH 09/10] correct examples for labels/annotations maps and optional keys --- guides/_subsections/create-an-automated-rule.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index 709eb74..dff4871 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -83,7 +83,7 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK {% endhighlight %}

- The alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The jvmId is a hash string computed by Cryostat after it successfully connects to a target JVM and is used to uniquely identify that JVM instance - it will be empty if Cryostat has not yet connected to that target (for example, if its SSL/TLS certificate is not trusted or if Cryostat is missing the required credentials) The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. + The alias, connectUrl, labels, annotations.platform, and annotations.cryostat properties are all guaranteed to be present on the target object. alias and connectUrl will be non-empty strings. The jvmId is a hash string computed by Cryostat after it successfully connects to a target JVM and is used to uniquely identify that JVM instance - it will be empty if Cryostat has not yet connected to that target (for example, if its SSL/TLS certificate is not trusted or if Cryostat is missing the required credentials) The labels and platform annotations may be empty — in OpenShift or Kubernetes, these are populated from the labels and annotations applied to the target’s pod, if any. The Cryostat annotations map will vary per platform, but on OpenShift or Kubernetes you can expect the HOST, PORT, NAMESPACE, and POD_NAME keys to be present and non-empty. Take care to use the `has` or `in` operators when dealing with the labels and annotations map structures where specific keys may not exist. Here are some examples of Match Expressions:

@@ -94,15 +94,15 @@ target.alias == 'com.example.MainClass' target.alias == 'myAlias' -target.labels[‘com.example/service’] == 'customer-login' +'com.example/service' in target.labels && target.labels[‘com.example/service’] == 'customer-login' -target.labels[‘com.example/service’] != 'customer-login' +'com.example/service' in target.labels && target.labels[‘com.example/service’] != 'customer-login' -target.annotations.cryostat.PORT > 3000 +has(target.annotations.cryostat.PORT) && target.annotations.cryostat.PORT > 3000 -target.annotations.cryostat.PORT > 3000 && target.annotations.platform['io.kubernetes/annotation'] == 'enabled' +has(target.annotations.cryostat.PORT) && 'io.kubernetes/annotation' in target.annotations.platform && target.annotations.cryostat.PORT > 3000 && target.annotations.platform['io.kubernetes/annotation'] == 'enabled' -!!target.annotations.platform['io.kubernetes/annotation'] +!('io.kubernetes/annotation' in target.annotations.platform) target.alias.matches("^customer-login[0-9]\*$") {% endhighlight %} From 2fae8fa5d397f96090ff37e3359e97d524699a9b Mon Sep 17 00:00:00 2001 From: Andrew Azores Date: Mon, 10 Jun 2024 16:57:34 -0400 Subject: [PATCH 10/10] correct example expr --- guides/_subsections/create-an-automated-rule.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/_subsections/create-an-automated-rule.md b/guides/_subsections/create-an-automated-rule.md index dff4871..3388052 100644 --- a/guides/_subsections/create-an-automated-rule.md +++ b/guides/_subsections/create-an-automated-rule.md @@ -178,7 +178,7 @@ We can define a rule that applies to any `target` application that has platform- { "name": "k8sMonitoring", "description": "Enable the Demo template on any target with the jfrMonitoring=true annotation", - "matchExpression": "target.annotations.platform[‘jfrMonitoring’]==’enabled’", + "matchExpression": "'jfrMonitoring' in target.annotations.platform && target.annotations.platform['jfrMonitoring']=='enabled'", "eventSpecifier": "template=Demo,type=CUSTOM", "archivalPeriodSeconds": 300, "preservedArchives": 12