Main Content


Create Prometheus counter metric



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

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

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

    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.


    collapse all

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

    Write a MATLAB function that increments the counter. In practice, you create metrics related to your application that help you instrument your code.

    function rc = test_metric_value()
    rc = 0;

    Package and deploy the MATLAB function to the server.

    When a client executes the deployed function, the value of the test_requests_processed metric is incremented by 1.

    For a detailed example, see Create Custom Prometheus Metrics.

    Input Arguments

    collapse all

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

    Example: test_requests_processed

    Numeric value of the counter metric, specified as a scalar. The value must be positive. The value can only increase over time.

    Example: 1

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

    Version History

    Introduced in R2022a

    See Also


    External Websites