WebSphere Application Server & Liberty

WebSphere Application Server & Liberty

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
  • 1.  How to serve only certain context roots via an OpenLibertyApplication deployment

    Posted 4 days ago

    We are running Liberty on RedHat Openshift and are deploying our images using the Liberty operator. In the OpenLibertyApplication we specify `expose: true` so that the OLA-Operator creates an OpenshiftRoute the deployment. For the Route we can specify a path as a string only. 

    If no `path` is  specified or the `path` is specified as "/" all requests matching the route's hostname are served. Which is fine as long as all context roots should be served via the route. But we are seeking advise on how we can block certain context root(s) from being served via the route. 

    For example: Our application exposes the following context roots namely /api and /openapi/ui. But we are using the `microProfile-6.0` feature and therefore the `mpMetrics` feature is loaded implicitly  exposing the /metrics endpoint.

    However we don't want to expose the /metrics to the users and therefore would need for this example a way to configure the environment so that:

    • /api is served 
    • /openapi is served 
    • /metrics is not served

    Thanks a lot in advance for any advise how we can set this up.

    Thanks, Hermann



    ------------------------------
    Hermann Huebler
    Cloud Architect
    Alpium IT Solutions GmbH
    Vienna
    Austria

    #IBMChampion
    ------------------------------


  • 2.  RE: How to serve only certain context roots via an OpenLibertyApplication deployment

    Posted yesterday

    Hi, you can limit the /metrics to authorized users only using a separate config for authentication and authorization

    Brian 



    ------------------------------
    Brian S Paskin
    Sr. Technology Engineer
    IBM Cloud Engineering
    ------------------------------



  • 3.  RE: How to serve only certain context roots via an OpenLibertyApplication deployment

    Posted 4 minutes ago

    Hi Hermann,

    When the mpMetrics feature is enabled, the /metrics endpoint remains active and cannot be disabled. If metrics functionality is not required, the recommended approach is to remove the mpMetrics feature from your server.xml configuration. This prevents unnecessary metrics data generation and improves performance.
    Alternatively, consider upgrading to MicroProfile 7.1, which replaces MicroProfile Metrics with MicroProfile Telemetry. This newer version provides a comprehensive observability solution including logs, traces, and metrics through a unified framework.

    Thanks,

    Emily



    ------------------------------
    Emily Jiang
    Liberty Cloud Native Architect and Chief Advocate
    IBM
    Winchester
    ------------------------------