> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Git-sync relay metrics

For Deployments that use git-sync to deploy Dags, the git-sync relay emits operational metrics through StatsD. These metrics provide visibility into sync operations, repository size, and sync performance for each Deployment.

Git-sync relay metrics are disabled by default and require configuration at both the platform and cluster levels.

<Warning>
  In APC 2.0, the strict schema validator doesn't recognize git-sync relay metrics. You must disable the strict schema check to use this feature. See the following configuration steps.
</Warning>

## Prerequisites

* Astro Private Cloud 2.0 or later with Helm chart version 2.0.0 or later.
* System Admin access to update the Astro Private Cloud Helm configuration.
* One or more Deployments configured to use git-sync for Dag deployment.

### Enable git-sync relay metrics

<Steps>
  <Step title="Disable the strict schema check">
    Because the strict schema validator in APC 2.0 doesn't recognize git-sync relay metrics fields, you must disable it. Add the following to your platform-level `values.yaml`:

    ```yaml focus={2-3} wrap theme={null}
    astronomer:
      strictSchemaCheck:
        enabled: false
    ```
  </Step>

  <Step title="Enable metrics at the platform level">
    In the same platform-level `values.yaml`, enable git-sync relay metrics globally:

    ```yaml focus={2-3} wrap theme={null}
    global:
      gitSyncRelay:
        metrics:
          enabled: true
    ```
  </Step>

  <Step title="Enable metrics in the cluster configuration">
    In your cluster configuration, enable git-sync relay metrics:

    ```yaml focus={2-3} wrap theme={null}
    helm:
      gitSyncRelay:
        metrics:
          enabled: true
    ```
  </Step>

  <Step title="Apply the configuration">
    Run a Helm upgrade to apply the changes:

    ```bash wrap theme={null}
    helm upgrade -f values.yaml -n <your-namespace> <Release-Name> astronomer/astronomer
    ```
  </Step>

  <Step title="Verify the metrics">
    After a successful Helm upgrade, git-sync relay metrics are available through the Deployment's StatsD exporter. Run the following command to confirm metrics are being emitted:

    ```bash wrap theme={null}
    curl -s http://localhost:9000/metrics | grep git_sync_relay
    ```
  </Step>
</Steps>

## Available metrics

The following metrics are available with the `git_sync_relay_` prefix. All metrics are emitted per Deployment.

### Sync operation metrics

| Metric                                                   | Type    | Description                                        |
| -------------------------------------------------------- | ------- | -------------------------------------------------- |
| `git_sync_relay_git_sync_count`                          | Counter | Total number of git sync operations initiated      |
| `git_sync_relay_git_sync_success_count`                  | Counter | Total number of successful git sync operations     |
| `git_sync_relay_git_sync_duration_seconds`               | Gauge   | Duration of the last git sync operation in seconds |
| `git_sync_relay_git_sync_interval_seconds`               | Gauge   | Git sync polling interval in seconds               |
| `git_sync_relay_last_sync_timestamp`                     | Gauge   | Timestamp of the last successful sync              |
| `git_sync_relay_git_sync_last_successful_sync_timestamp` | Gauge   | Timestamp of the last successful sync operation    |

### Git operation metrics

| Metric                                           | Type    | Description                                                                      |
| ------------------------------------------------ | ------- | -------------------------------------------------------------------------------- |
| `git_sync_relay_git_operations_total`            | Counter | Total git operations (clone, fetch, clean, reset, sync)                          |
| `git_sync_relay_git_operations_duration_seconds` | Summary | Duration of individual git operations with quantile distribution (p50, p90, p99) |
| `git_sync_relay_git_sync_clone_duration`         | Gauge   | Duration of git clone operation in seconds                                       |

### File and repository metrics

| Metric                                       | Type    | Description                                           |
| -------------------------------------------- | ------- | ----------------------------------------------------- |
| `git_sync_relay_files_updated_total`         | Counter | Total files updated during sync operations            |
| `git_sync_relay_git_sync_file_changed_count` | Gauge   | Number of files changed in the last sync              |
| `git_sync_relay_repo_size_bytes`             | Gauge   | Size of the git repository in bytes                   |
| `git_sync_relay_git_dir_size_bytes`          | Gauge   | Size of the `.git` folder in bytes                    |
| `git_sync_relay_repo_total_size_bytes`       | Gauge   | Total repository size including working tree in bytes |
| `git_sync_relay_working_tree_size_bytes`     | Gauge   | Size of the working tree in bytes                     |
| `git_sync_relay_git_sync_repo_size`          | Gauge   | Git repository size in bytes                          |

### Initialization metrics

| Metric                                                  | Type  | Description                                    |
| ------------------------------------------------------- | ----- | ---------------------------------------------- |
| `git_sync_relay_git_sync_init_duration_seconds`         | Gauge | Application initialization duration in seconds |
| `git_sync_relay_git_sync_init_attempt`                  | Gauge | Number of initialization attempts              |
| `git_sync_relay_git_sync_light_init_duration_seconds`   | Gauge | Light initialization duration in seconds       |
| `git_sync_relay_git_sync_deferred_init_start_timestamp` | Gauge | Deferred initialization start timestamp        |

### State metrics

| Metric                                     | Type  | Description                                                        |
| ------------------------------------------ | ----- | ------------------------------------------------------------------ |
| `git_sync_relay_git_sync_ready_state`      | Gauge | Whether the git-sync relay is ready (`1` = ready, `0` = not ready) |
| `git_sync_relay_git_sync_shallow_state`    | Gauge | Whether the repository is in a shallow clone state                 |
| `git_sync_relay_git_sync_configured_depth` | Gauge | Configured git clone depth                                         |
