Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Access JFR data faster with Cryostat 2.1's new download APIs

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

May 25, 2022
Hareet Dhillon
Related topics:
ContainersJavaKubernetes
Related products:
Red Hat build of OpenJDK

    Cryostat is a tool for managing JDK Flight Recorder data on Kubernetes. This article explains how new download APIs based on JSON Web Tokens (JWTs) help facilitate a more responsive and efficient download workflow in the Cryostat 2.1 web client.

    The Cryostat web client download workflow

    Previously, the web client download flow for resources such as recordings, reports, and templates consisted of the application firing an HTTP GET request with the appropriate authorization header(s) to the back-end, downloading the returned file into browser memory, creating a local object URL for the blob, and then assigning the URL to an anchor element prompting user response. The file size determined the download speed and when the "Save File" prompt would appear. Once this process was completed, the user would be prompted to save the file to disk or cancel the download even though the file had already been transferred to the user’s machine.

    Cryostat 2.1 improves the download flow by using the HTML 5 download attribute available in most browsers. Specifically, an anchor element is created with the href attribute set to a URL for the resource provided by the back-end, and the download attribute is set to the file name. When the anchor is clicked,  the “Save File” prompt appears (see Figure 1).

    The Recordings view for a sample application in the Cryostat web client. A recording download has been requested causing the "Save File" prompt to show.
    Figure 1: The "Save File" prompt allows users to decide whether they want to save the recording file to disk or not.

    If the user clicks “Save File,” the file downloads directly to disk. If the user clicks "Cancel," the file will not be downloaded. Another benefit is that the time to display the “Save File” dialog is no longer dependent on the file size because nothing is being downloaded into the browser memory.

    However, a limitation of the href attribute is that it is not possible to provide headers with the URL without authorization to retrieve the resource. This is where JSON Web Tokens come in.

    How JSON Web Tokens improve download workflow

    JWTs are credentials that ensure the user sending the server request is the same user that was authenticated (i.e., logged in) previously in the session and also has access to the requested resource. They consist of JSON payloads containing authorization metadata. 

    Cryostat 2.1 has implemented new API handlers to help facilitate JWT downloads. When a user downloads a file through the web client, a POST request containing the required authorization headers and a multipart form attribute identifying the requested resource is sent to the /api/v2.1/auth/token endpoint. The API handler encodes the information into a JWT token, symmetrically encrypts it, and returns a resource URL associated with the token. This is the URL to which the aforementioned href attribute is set. When the anchor element is clicked, the resulting GET request for the file resource will be authorized using the JWT token, solving the problem of not being able to provide any headers with the href attribute.

    Any JWT token-associated GET requests are handled by new version 2.1 API handlers specifically designed for this purpose. The web client extensively uses these because of the improved browser-related performance. However, other API clients, such as user-created automated workflows, can continue using the original version 1 download APIs because they do not require generating JWT tokens which are functionally identical to the new version 2.1 handlers.

    Figure 2 shows the main Cryostat container logs when a recording download request from the web client is received.

    The main Cryostat container logs with the HTTP requests comprising the web client recording download workflow highlighted. There is a POST request to generate the JWT token and a subsequent GET request using the token-associated URL returned by the POST request to retrieve the actual recording file.
    Figure 2: The recording download request in Figure 1 results in the two HTTP requests shown here.

    Conclusion

    New JWT-based download APIs allow the Cryostat web client to provide an improved resource download workflow for users. For more information on Cryostat such as guides and contact information, visit us at cryostat.io.

    Find more Cryostat tutorials on Red Hat Developer:

    • Introduction to Cryostat: JDK Flight Recorder for containers
    • How to build automated JFR rules with Cryostat 2.1's new UI
    • Tutorial: Configuring Java applications to use Cryostat
    Last updated: September 26, 2024

    Related Posts

    • Announcing Cryostat 2.0: JDK Flight Recorder for containers

    • Collect JDK Flight Recorder events at runtime with JMC Agent

    • Custom JFR event templates with Cryostat 2.0

    Recent Posts

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    What’s up next?

    Book cover for Modernizing Enterprise Java

    Modernizing Enterprise Java is a practical guide that examines long-established Java-based models and shows you how to bring these monolithic applications successfully into a modern, cloud-native model with Kubernetes.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.