YAML File - Metric Objects

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.

Configure `metricObjects`

To configure `metricObjects` in the Prometheus Client, define them in a YAML file. Each metric object has several key properties:

  • name: Unique identifier for the metric.
  • help: Descriptive text explaining the metric.

Optional properties

  • labelNames: An array of labels for the metric. All label names that the metric support needs to be declared here.
  • resetAfterScrape [default: false]: When set to `true`, this property ensures that the metric data and labels are cleared after each scrape by Prometheus. This reset applies specifically to the data stored within the metric object, ensuring it does not persist beyond a single scrape cycle.

Types of Metrics

Table 2. Types of Metrics
Counter
  • `name`, `help`, `labelNames`
  • Increments over time, typically for counting occurrences.-
Gauge
  • `name`, `help`, `labelNames`
  • Represents a value that can increase or decrease.
Histogram
  • `name`, `help`, `labelNames`.
  • `buckets`: Defines ranges for aggregating values
  • Useful for tracking distributions, like request durations.
Summary
  • `name`, `help`, `labelNames`.
  • `percentiles`: Specific quantiles to calculate.
  • Similar to Histogram but for calculating quantiles.
MovingAvgGauge
  • `name`, `help`, `labelNames`
  • `avgWindowSize`: Number of data points for averaging.
  • `rateOfChange`: Boolean to calculate rate of change. Default false.
  • Internal parameters(*not for user to use*): -
    • `oaInternalCalculation`: When set to `true`, in conjunction with `rateOfChange` also being set to `true`, this parameter enables the calculation of the rate of change based on the sum of values within a specified window of data points. This feature is specifically designed for use in the EventsStats script, which monitors WinCC OA statistics, such as the number of messages over a certain period. This specialized calculation is tailored to the unique data handling requirements of WinCC OA monitoring
    . $$

    rateOfChange = \frac{\sum_{i=0}^{avgWindowSize}sampleData[i]}{currentTime-sampleTime[0]}

    $$ ​

    For more information about standard metrics see the online documentation https://github.com/siimon/prom-client).

Examples

 **Counter**:

   ```yaml
   TotalRequests:
     help: "Total number of requests received"
     type: "Counter"
   ```
 **Gauge**:

   ```yaml
   ServerTemperature:
     help: "Current temperature of the server"
     type: "Gauge"
     labelNames: "serverId"
   ```
**Histogram**:

   ```yaml
   RequestDuration:
     help: "Duration of HTTP requests in milliseconds"
     type: "Histogram"
     buckets: [0.1, 0.5, 1, 5, 10]
   ```
**Summary**:

   ```yaml
   ResponseSizes:
     help: "Sizes of HTTP responses"
     type: "Summary"
     percentiles: [0.5, 0.9, 0.99]
   ```
 **MovingAvgGauge**:

   ```yaml
   AverageLoad:
     help: "Average system load over a period"
     type: "MovingAvgGauge"
     avgWindowSize: 5
     rateOfChange: false
   ```