Custom Metrics

Overview

You can configure custom metrics and query them with OpenTelemetry.

This feature is available in:

Procedure

  1. Connect to the command line on the Check Point server.

  2. Log in to the Expert mode.

  3. Create a shell script to configure the required objects for your custom metrics.

    Create this script file in any directory.

    Example: /home/admin/script_with_custom_metrics.sh

    Notes:

    • You can use this script file as a template:

      /opt/CPotlpAgent/custom_scripts_template.bash

    • To create a script file, run:

      vi /path/to/your/script_file

    This shell script file must contain the lines described below.

  4. Prepare the required payload in a JSON file for your custom metric.

    Create this JSON file in any directory.

    Example: /home/admin/payload_with_custom_metrics.json

    This JSON file must contain these lines (replace the placeholder strings "<...>" with your actual strings):

    {
      "state" : "<State>",
      "command" : "<Command>",
      "desc" : "<Description>",
      "name" : "<Name>",
      "type" : "<Type>",
      "unit" : "<Unit>",
      "interval" : <Interval>
    }

    Where:

    Parameter

    Description

    "state"

    The state of the collector:

    • "enabled"

    • "disabled"

    "command"

    The command that the Skyline Agent needs to run to get the values and labels of the custom metric.

    The collected data will be in the JSON format - a batch of metric values (real value and label values).

    "desc"

    A description of this custom metric.

    "name"

    The name of the custom metric.

    Must be unique.

    Must contain only lowercase Latin letters (a-z).

    Use the period character "." as a separator between each name part.

    Example: system.cpu.util

    Best Practice - For the metric convention name, refer to https://opentelemetry.io/docs/specs/semconv/general/metrics/.

    "type"

    Can be one of these:

    • "Counter"

      To count something by recording a delta value.

      • If the value is monotonic, use "Counter".

      • Otherwise, use "UpDownCounter".

    • "UpDownCounter"

      To measure something by recording an absolute value that is additive / summable.

    • "Gauge"

      To measure something by recording an absolute value that is not additive / summable.

    Best Practice - For the metric types, refer to https://uptrace.dev/opentelemetry/metrics.html.

    "unit"

    The measurement unit for the custom metric.

    For example, the unit for the metric "hardware.memory.util" is "bytes".

    If the custom metric uses a non-standard unit, you must enclose it in curly braces { }.

    For example : "{interval}".

    Best Practice - For the unit convention, refer to https://github.com/open-telemetry/semantic-conventions/blob/main/docs/general/metrics.md#instrument-units.

    "interval"

    How frequently (in seconds) the Skyline Agent needs to run the command.

    Example:

    {
      "state" : "enabled",
      "command" : "cat /home/admin/HW_sensors_data.json",
      "desc" : "The current temperature in the appliance",
      "name" : "hardware.sensors.temperature",
      "type" : "Gauge",
      "unit" : "{celcius}",
      "interval" : 2
    }
  5. Run the configuration command to apply the JSON payload:

    sklnctl otlp add –name /<Path>/<Shell Script File> --path /<Path>/<JSON File>

    Example:

    sklnctl otlp add –name /home/admin/script_with_custom_metrics.sh --path /home/admin/payload_with_custom_metrics.json

  6. Restart the OpenTelemetry Agent:

    /opt/CPotlpAgent/CPotlpagentCli.sh stop

    /opt/CPotlpAgent/CPotlpagentCli.sh start

  7. Examine the currently exported metrics:

    sklnctl otelcol metrics --show

Notes

  • During an upgrade, the Gaia OS automatically moves your shell script to this directory:

    /var/log/CPotlpAgent/backup/scripts

  • If there are issues with your custom metrics, then:

    1. Restart the OpenTelemetry Agent:

      /opt/CPotlpAgent/CPotlpagentCli.sh stop

      /opt/CPotlpAgent/CPotlpagentCli.sh start

    2. Examine these log files:

      • /opt/CPotelcol/sklnctl.log

      • /opt/CPotlpAgent/otlp_agent.log