All Products
Search
Document Center

Serverless App Engine:Prometheus monitoring

Last Updated:Dec 04, 2025

You can send custom monitoring metrics from your Serverless App Engine (SAE) application to Managed Service for Prometheus. Simply instrument metrics in your application code and enable Prometheus monitoring after the application is deployed to SAE. SAE then automatically collects the metrics.

Note

Only the Standard Edition and Professional Edition support Prometheus monitoring.

1. Instrument your code

This example shows how to use the Micrometer framework in a Spring Boot application to collect monitoring metrics. By importing the Actuator and Prometheus dependencies, you can expose a metrics endpoint that Prometheus automatically collects.

  1. Import the Actuator and Prometheus dependencies:

    # pom.xml
    
    ...
    	<dependencies>
    		<!-- Actuator dependency -->
    		<dependency>
    			<groupId>org.springframework.boot</groupId>
    			<artifactId>spring-boot-starter-actuator</artifactId>
    		</dependency>
    		<!-- Prometheus dependency -->
    		<dependency>
    			<groupId>io.micrometer</groupId>
    			<artifactId>micrometer-registry-prometheus</artifactId>
    		</dependency>
    	</dependencies>
    ...
  2. Configure the collection port and metric labels:

    # src/main/resources/application.properties
    
    # Server port configuration
    # Set the listener port for the Spring Boot application to 8080
    server.port=8080
    
    # Application name configuration
    # Set the application name. This name is used as a label in the monitoring metrics.
    spring.application.name=frontend
    
    # Actuator management port configuration
    # Set the management endpoint to use a separate port, 8091, from the main application port to improve security.
    management.server.port=8091
    
    # Actuator endpoint exposure configuration
    # An asterisk (*) exposes all available management endpoints, such as health, info, metrics, and prometheus.
    # After you import the micrometer-registry-prometheus dependency, the /actuator/prometheus endpoint is exposed for metric collection.
    management.endpoints.web.exposure.include=*
    
    # Monitoring metric label configuration
    # Add the application name as a common label to all metrics. This helps distinguish metrics from different applications in the monitoring system.
    management.metrics.tags.application=${spring.application.name}
  3. Define custom monitoring metrics with Micrometer:

    // src/main/java/com/example/webframework/WebFrameworkApplication.java
    
    import io.micrometer.core.annotation.Timed;
    ...
        @GetMapping("/")
        // In this example, the response to a request for the current path is defined as a monitoring metric. For more information, see https://javadoc.io/doc/io.micrometer/micrometer-core/1.3.1/io/micrometer/core/annotation/Timed.html. For other instrumentation methods, see the relevant API documentation.
        @Timed(value = "main_page_request_duration", description = "Time taken to return main page", histogram = true)
        public ResponseEntity<String> welcome() {...}
    ...

2. Deploy the application

Package your application into a JAR file and deploy it to SAE. An example JAR file is provided for quick deployment and testing:

  1. In the SAE Application List, select a destination region and namespace at the top of the page, and then click Create Application.

    1. Enter a custom Application Name.

    2. Set Application Deployment Method to Code Package-based Deployment, and then click Configure Code Package-based Deployment.

      1. Set Technology Stack Programming Language to Java.

      2. Set Code Package Type to JAR Package Deployment.

      3. For Java Environment, select the Java version that matches your code. The example JAR file requires Open JDK 8.

      4. In the Upload JAR Package section, upload your application's JAR file or the example JAR file.

  2. Click Create Application and wait for the application to be created.

3. Enable Prometheus monitoring

  1. In the SAE Application List, select a destination region and namespace at the top of the page, and then click the Application ID of the target application.

  2. Click Prometheus Monitoring, then click Configure Prometheus, and turn on the Prometheus Monitoring switch.

    1. Set Collection Interval (seconds) as required. For example, enter 10.

    2. Set Destination Port to 8091.

    3. Set Metrics Path to /actuator/prometheus.

  3. Wait for the configuration to take effect. Then, click Prometheus Monitoring again to go to the Prometheus monitoring Instances page.

  4. Click Metric Management > Metric Explorer. In the query box, enter the name of your custom monitoring metric, such as main_page_request_duration from the example code. Select the desired metric, select a Time Range, and click Query. A chart of the monitoring metric is displayed, indicating a successful configuration.