YAML File - Global Variables
The YAML file used by this client is divided into several sections, each serving a distinct purpose:
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
Global Variables in the Prometheus Client configuration are key-value pairs that provide a centralized way to define values which can be reused across the configuration.
Define Global Variables
- Specified in the YAML configuration file under `globalVariables`.
- Used for values that need to be consistent across various metric configurations.
Usage
- Refer to these variables in other parts of the YAML file to maintain consistency and ease of updates.
- Particularly useful for setting default values. See section [globalVariable].
Example
```yaml
globalVariables:
environment: "production"
serviceVersion: "1.2.3"
version: !dpGet
dpId:
- "_DatabaseVersion.Major:_original.._value"
- "_DatabaseVersion.Minor:_original.._value"
- "_DatabaseVersion.Sub:_original.._value"
fetch: onetime
transformation: v => v.join('.')
reduNum: ${this.wccoa.myReduHostNum()}
systemNum: ${this.wccoa.getSystemId()}
```
This configuration for global variables in Prometheus integrates both static values and dynamic data fetching:
- Static values like `environment` and `serviceVersion` are directly set.
- Dynamic data fetching is used for `version` using `!dpGet`, combining major, minor, and sub-version numbers from the WinCC OA.
-
`reduNum` and `systemNum` leverage WinCC OA functions (`wccoa.myReduHostNum()` and `wccoa.getSystemId()`) to dynamically assign values.