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): document jfrEventTypeIds function #208

Open
wants to merge 2 commits into
base: release-40
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions guides/_subsections/create-an-automated-rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,20 @@ Previously, if we wanted to enable always-on `Continuous` monitoring using **JDK
}
{% endhighlight %}
</figure>
The following functions are also available in the <code>Expression</code> execution context:
<figure>
{% highlight typescript %}
/**
* @param target the target context object
* @returns a list of JFR Event Type IDs
*/
jfrEventTypeIds(target: Target): string[]
{% endhighlight %}
</figure>
See also:
<ul>
<li><a href="#view-jfr-event-types">JFR Event Types</a></li>
</ul>
<p>
The <i>alias, connectUrl, labels, annotations.platform,</i> and <i>annotations.cryostat</i> properties are all guaranteed to be present on the <code>target</code> object. <i>alias</i> and <i>connectUrl</i> will be non-empty strings. The <i>jvmId</i> is a hash string computed by Cryostat after it successfully connects to a <code>target</code> <b>JVM</b> and is used to uniquely identify that <b>JVM</b> instance - it will be empty if <b>Cryostat</b> has not yet connected to that <code>target</code> (for example, if its <a href="#add-a-trusted-certificate"><code>SSL/TLS</code> certificate is not trusted</a> or if <a href="#store-credentials"><b>Cryostat</b> is missing the required credentials</a>) The <i>labels</i> and <i>platform annotations</i> may be empty — in <b>OpenShift</b> or <b>Kubernetes</b>, these are populated from the labels and annotations applied to the <code>target</code>’s pod, if any. The <b>Cryostat</b> annotations map will vary per platform, but on <b>OpenShift</b> or <b>Kubernetes</b> you can expect the <i>HOST, PORT, NAMESPACE,</i> and <i>POD_NAME</i> keys to be present and non-empty. Take care to use the `has` or `in` operators when dealing with the <i>labels</i> and <i>annotations</i> map structures where specific keys may not exist.

Expand All @@ -105,6 +119,8 @@ has(target.annotations.cryostat.PORT) && 'io.kubernetes/annotation' in target.an
!('io.kubernetes/annotation' in target.annotations.platform)

target.alias.matches("^customer-login[0-9]\*$")

jfrEventTypeIds(target).exists(x, x.startsWith("myOrg.prefix."))
{% endhighlight %}

</figure>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,21 @@ all. It may be useful to use either of these as a starting point and tailor it
to meet your specific monitoring/profiling needs by including/excluding events,
increasing/decreasing sample rates, raising/lowering thresholds, etc.

Of special note, **JFR** allows for the definition of application-specific custom
events, which would not be captured in either of the default templates above.
Of special note, **JFR** allows for the definition of application-specific or
framework-level custom events, which would not be captured in either of the default
templates above. You can [view all of the **JFR** *Event Types*](#view-jfr-event-types)
for a *Target* application.

**Cryostat** also provides the <code>ALL</code> meta-template, which enables all
event types in the selected `target` application, with default values for each
event option. This is not a true *Event Template* and does not have an `XML`
definition to download.

The steps below assume that you have at least one *Target* discovered. If you select
a discovered *Target* then you can use its templates as starting points for your
customizations. If you do not first select a *Target* then you may still upload and
delete **Custom Event Templates**.

<ol>
<li>
{% include_relative _subsections/common/select-target-application.md
Expand Down
50 changes: 50 additions & 0 deletions guides/_subsections/view-jfr-event-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## [View JFR Event Types](#view-jfr-event-types)
The **JVM** comes with many built-in **JDK Flight Recorder** *Event Types* out-of-the-box.
You can also register new *event types* at the framework- or application-level using the
`jdk.jfr` API. **Cryostat** can list out all of a *Target* **JVM**'s registered *event types*
so you can see what kind of data may be captured by **Flight Recordings**.

<ol>
<li>
{% include_relative _subsections/common/select-target-application.md
select-target-application-additional-content="
The <i>Target</i> selected will provide the base <code>Continuous</code> and
<code>Profiling</code> template definitions to start from. Most target
applications will be interchangeable here.
"
%}
</li>
<li>
{% capture navigate-to-events-include-text %}
<p>
If the <i>Target</i> <b>JVM</b> has <code>SSL/TLS</code> enabled on <b>JMX</b> connections then it may be
necessary to add the <i>Target's</i> certificate to <b>Cryostat's</b> trust store. Go
to <a href="{{ page.url }}#add-a-trusted-certificate">Add a Trusted Certificate</a>
and return to this section after completing that guide.
<a href="{{ site.url }}/images/4.0.0/navigate-to-events-2.png" target="_blank">
<img src="{{ site.url }}/images/4.0.0/navigate-to-events-2.png">
</a>
</p>
{% endcapture %}
{% include howto_step.html
summary="Navigate to Events"
image-name="4.0.0/navigate-to-events-1.png"
caption="
Supply <b>JMX</b> credentials to authenticate to the target, if necessary. If
the target is not configured with <b>JMX</b> authentication then the
connection attempt will continue without prompting for credentials.
"
text=navigate-to-events-include-text
%}
</li>
<li>
{% include howto_step.html
summary="Navigate to Event Types"
image-name="4.0.0/navigate-to-event-types-1.png"
caption="
Select the <i>Event Types</i> tab to view a table listing of all the <b>JDK Flight Recorder</b>
<i>Event Types</i> registered in the <i>Target JVM</i>.
"
%}
</li>
</ol>
2 changes: 2 additions & 0 deletions guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ common actions and workflows of interest and why they are useful.

{% include_relative _subsections/re-upload-a-recording-to-archives.md %}

{% include_relative _subsections/view-jfr-event-types.md %}

{% include_relative _subsections/download-edit-and-upload-a-customized-event-template.md %}

{% include_relative _subsections/edit-template-with-jmc.md %}
Expand Down
Binary file added images/4.0.0/navigate-to-event-types-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.