Main Content

prodserver.metrics.setGauge

Create Prometheus gauge metric

Since R2022a

    Description

    prodserver.metrics.setGauge(metricName,metricValue) creates a custom Prometheus® gauge metric. Prometheus gauge values can increase or decrease over time. The metric is created when the following conditions are true:

    • prodserver.metrics.setGauge is present in the MATLAB® function that you deploy to MATLAB Production Server™.

    • A client invokes the deployed MATLAB function that contains prodserver.metrics.setGauge.

    The server collects the metric when the deployed MATLAB function executes. The output of the GET Metrics (MATLAB Production Server) API returns information about the metric name and the metric value.

    example

    Examples

    collapse all

    Create a custom gauge metric that a Prometheus server can monitor.

    Write a MATLAB function that sets the gauge to a specific value. In practice, you create metrics related to your application that help you instrument your code.

    function rc = test_metric_value()
    prodserver.metrics.setGauge("requests_in_progress",4);
    rc = 0;
    end

    Package and deploy the MATLAB function to the server.

    When a client executes the deployed function, the value of the requests_in_progress metric is set to 4.

    For a detailed example, see Create Custom Prometheus Metrics.

    Input Arguments

    collapse all

    Name of the Prometheus gauge metric, specified as a character array or string scalar. The name must be a valid MATLAB variable name.

    Example: requests_in_progress

    Numeric value of the gauge metric, specified as a scalar. The value can increase or decrease over time.

    Example: 4

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Version History

    Introduced in R2022a

    See Also

    Topics

    External Websites