YAML File - Metric Data Section

The YAML file used by this client is divided into several sections, each serving a distinct purpose:

Table 1. YAML File Structure
globalVariables Defines global variables that can be used throughout the YAML file.
defaultLabels Sets default labels to be applied to all metrics.
metricObjects Defines the metrics to be exposed to Prometheus, including their types and specific labels.
metricData Specifies the data points to be collected, along with any processing functions to be applied.

Overview

The `metricData` section in the YAML configuration file specifies how each metric's data is fetched and processed.

Configuration

Define under `metricData`.- For each entry in the `metricData` section of the Prometheus client's YAML configuration, the following parameters are typically necessary:

  • objectType: The name of the metric object.
  • value: How the metric's value is fetched, using YAML commands like `!dpGet` or `!dpQuery`. Constant value is not supported.
  • labels: Optional additional labels specific to the metric.
  • function: Defines the operation to apply to the metric (e.g., `set`, `inc`, `dec`, `observe`).

Purpose

To dynamically retrieve and process data for each metric.

Example

```yaml
metricData:
  - objectType: SystemLoad
    value: !dpGet
      dpId: "System.Load:_online.._value"
    labels:
      server: "Server1"
    function: set
  - objectType: DatabaseHealth
    value: !dpQuery
      select: "SELECT '_online.._value' FROM 'DB_Health'"
    labels:
      db: "DB1"
    

In this example, `SystemLoad` and `DatabaseHealth` are defined with specific data retrieval methods and label configurations. This setup allows for granular control over how each metric's data is sourced and labeled.

The `function` parameter in `metricData` defines how new data is processed and stored for each metric object. It specifies the operation to be applied when updating the metric's value. For example:

  • `set`: Sets the metric to a specific value, like `gauge.set(10)`.
  • `inc`: Increments the metric, either by 1 (`gauge.inc()`) or by a specified amount (`gauge.inc(10)`).-
  • `dec`: Decrements the metric, similar to `inc`, but transformations the value.
  • `observe`: Used in histograms and summaries to record a new observation, such as `histogram.observe(10)` or `summary.observe(10)`.

These functions allow for precise control over how metric values are updated in response to new data.

For more detailed information and specific examples on how to use these functions with various metric types, please refer to the online documentation of the `prom-client` library available at https://github.com/siimon/prom-client.