> For the complete documentation index, see [llms.txt](https://docs.cennso.com/components/cgw/latest/llms.txt) (all documentation: [llms.txt](https://docs.cennso.com/llms.txt)). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.cennso.com/components/cgw/latest/configuration/monitoring.md).

# Monitoring configuration

The monitoring component of Connectivity Gateway (CGW) supports ICMP echoes to the defined endpoints and exposes them through an
HTTP endpoint in the Prometheus format.

The component sends pings from the address configured in **ipsec.local_ping_endpoint** to the address stated in **ipsec.remote_ping_endpoint**. A service is exposed and scraped automatically by common configured Prometheus instances.

By default, the service is called `<release name>-cgw` and the metrics are available at
`http://<release name>-cgw:9427/metrics`.

## Configuration parameters

The following configuration parameters are available:

```yaml
version: "1.0"                # Configuration version 
web:
  listen-address: ":9427"     # Address on which HTPPS server listens 
  telemetry-path: "/metrics"  # Path where metrics are exposed
ping:
  interval: "5s"              # Interval for ICMP requests 
  timeout: "4s"               # Timeout for ICMP requests 
  source:
    ipv4: "0.0.0.0"           # Source address of ICMP requests
    ipv6: "::"                # Source address of ICMP requests
  target:
  - 192.0.2.1
  - 192.0.2.2
dns:
  refresh: "1m"               # Interval for refreshing DNS records and updating targets accordingly (0 if disabled)
```

>**NOTE:** All parameters except **ping.target** are required. 

## Multiple ping configurations

If you want to use multiple configurations for the ping target, for example, to use multiple source IP addresses, set up the **ping.configuration** parameter. See the configuration example:

```yaml
version: "1.0"                     # Configuration version (mandatory)
ping:
  configurations:
    - sourceV4: 192.0.2.1          # Source address of ICMP requests
      sourceV6: "2001:0DB8:1::1"   # Source address of ICMP requests
      pingInterval: 5s             # Interval for ICMP requests
      pingTimeout: 4s              # Timeout for ICMP requests
      pingTargets:                 # List of ICMP targets
        - pingTarget: 192.0.2.10
        - pingTarget: 198.51.100.1
    - sourceV4: 192.0.2.2
      sourceV6: "2001:0DB8:2::2"
      pingInterval: 5s
      pingTimeout: 4s
      pingTargets:
        - pingTarget: 203.0.113.1
        - pingTarget: "2001:0DB8:2::10"
```

### Use additional labels

You can add additional labels to the configuration. The labels (both source and target) are added to the resulting metrics.
The label names must be different between source and target.

See the example of a working configuration:

```yaml
version: "1.0"                       # Configuration version (mandatory)
ping:
  configurations:
    - sourceV4: 192.0.2.1            # Source address of ICMP requests
      sourceV6: "2001:0DB8:1::1"     # Source address of ICMP requests
      sourceLabels:
        source_name: server1         # Source label
        source_company: tier1prov    # Another source label
      pingInterval: 5s               # Interval for ICMP requests
      pingTimeout: 4s                # Timeout for ICMP requests
      pingTargets:                   # List of ICMP targets
        - pingTarget: 192.0.2.10
          targetLabels:
            target_name: server11    # Target label
        - pingTarget: 198.51.100.1
          targetLabels:
            target_name: server12    # Another target label
```

>**CAUTION:** Target and source label names must be the same within the configuration. Otherwise, a runtime error occurs.

Even in the case of two different configurations with different source IP address, the labels for source and targets must match.
For example, the following configuration is not valid:

```yaml
version: "1.0"                          # Configuration version (mandatory)
ping:
  configurations:
    - sourceV4: 192.0.2.1               # Source address of ICMP requests
      sourceV6: "2001:0DB8:1::1"        # Source address of ICMP requests
      sourceLabels:
        source_name: server1            # Source label
        source_company: tier1prov       # Another source label
      pingInterval: 5s                  # Interval for ICMP requests
      pingTimeout: 4s                   # Timeout for ICMP requests
      pingTargets:                      # List of ICMP targets
        - pingTarget: 192.0.2.10
          targetLabels:
            target_name: server11       # Target label
        - pingTarget: 198.51.100.1
          targetLabels:
            target_company: server12    # NOT VALID configuration 
```
