Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

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

 

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

Share:

    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

    • Autoscaling vLLM with OpenShift AI

    • Filtering packets from anywhere in the networking stack

    • PostGIS: A powerful geospatial extension for PostgreSQL

    • Kafka Monthly Digest: September 2025

    • A more secure way to handle secrets in OpenShift

    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
    © 2025 Red Hat

    Red Hat legal and privacy links

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

    Report a website issue