# Metrics

![Grafana displaying Prometheus metrics](/files/YgYsoGQUyG3Eord437t0)

This guide assumes you're familiar with [Prometheus](https://prometheus.io) and how to work with its metrics ecosystem. We won't provide guides on how to fetch Kubernetes metrics.

Most components of the Toucan Stack expose Prometheus-compatible metrics endpoints by default, allowing administrators to monitor system performance and health effectively.

## How to enable metrics ports

Override the values of the Helm Charts with:

{% code title="yaml: values.override.yaml" %}

```yaml
canopee:
  metrics:
    enabled: true

layout:
  metrics:
    enabled: true

dataset:
  metrics:
    enabled: true

dataexecution:
  metrics:
    enabled: true

gotenberg:
  metrics:
    enabled: true

spicedb:
  metrics:
    enabled: true

curity:
  admin:
    metrics:
      enabled: true

  runtime:
    metrics:
      enabled: true

vault:
  server:
    metrics:
      enabled: true

postgresql:
  metrics:
    enabled: true

layout-redis:
  metrics:
    enabled: true

laputa-redis:
  metrics:
    enabled: true

impersonate-redis:
  metrics:
    enabled: true

dataexecution-redis:
  metrics:
    enabled: true

garage:
  metrics:
    enabled: true
```

{% endcode %}

{% hint style="info" %}
We are not providing any metrics for MongoDB at the moment. We recommend using [MongoDB Exporter by Percona](https://github.com/percona/mongodb_exporter) as a sidecar container to export metrics from your MongoDB instance.
{% endhint %}

## How to access the metrics endpoints

Here's a list of endpoints (accessible through the associated Kubernetes Service) you can use:

| Component                         | Service port name | Service port number | Path                  |
| --------------------------------- | ----------------- | ------------------- | --------------------- |
| canopee                           | `metrics`         | `8501`              | `/metrics`            |
| postgresql                        | `http-metrics`    | `9187`              | `/metrics`            |
| vault (secret manager)            | `http`            | `8200`              | `/v1/sys/metrics`     |
| curity admin (auth service)       | `metrics`         | `4466`              | `/metrics`            |
| curity runtime (auth service)     | `metrics`         | `4466`              | `/metrics`            |
| dataset                           | `http`            | `3000`              | `/metrics`            |
| dataexecution\[-api/-worker]      | `http`            | `8080`              | `/metrics`            |
| layout                            | `http`            | `3000`              | `/metrics`            |
| spicedb (authz service)           | `metrics`         | `9090`              | `/metrics`            |
| gotenberg (pdf rendering service) | `http`            | `80`                | `/prometheus/metrics` |
| garage (storage)                  | `admin`           | `3903`              | `/metrics`            |
| redis                             | `http-metrics`    | `9121`              | `/metrics`            |

## How to consume the metrics endpoints

### Using Prometheus CRDs (Prometheus Operator, Grafana Alloy)

We highly recommend using Prometheus CRDs such as those provided by [Prometheus Operator](https://github.com/prometheus-operator/prometheus-operator) or [Grafana Alloy](https://grafana.com/docs/alloy/latest/) to dynamically manage scraping targets.

Even if you have an external Prometheus, you can deploy [Grafana Alloy](https://grafana.com/docs/alloy/latest/) to consume the metrics and forward to your external Prometheus.

To dynamically configure scraping rules, you can set these values in the `values.override.yaml` file:

{% code title="yaml: values.override.yaml" %}

```yaml
canopee:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

layout:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

dataset:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

dataexecution:
  metrics:
    enabled: true
    api:
      serviceMonitor:
        enabled: true
    worker:
      podMonitor:
        enabled: true

gotenberg:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

spicedb:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

curity:
  admin:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true

  runtime:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true

vault:
  server:
    metrics:
      enabled: true
      serviceMonitor:
        enabled: true

postgresql:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

layout-redis:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

laputa-redis:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

impersonate-redis:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

dataexecution-redis:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true

garage:
  metrics:
    enabled: true
    serviceMonitor:
      enabled: true
```

{% endcode %}

Which will automatically generate a `ServiceMonitor` object for each component, and configure the Prometheus Operator to scrape them.

### Statically

If you have deployed Prometheus in the same cluster as the Toucan Stack, you can reference the services using `<service name>.<namespace>.svc.cluster.local`. In your prometheus config file, you can add the following:

{% code title="yaml: prometheus.yaml" overflow="wrap" %}

```yaml
scrape_configs:
  - job_name: dataset
    metrics_path: /metrics
    scheme: http
    static_configs:
      - targets:
          - toucan-stack-dataset.toucan.svc.cluster.local:3000
```

{% endcode %}

This approach works if Prometheus is deployed in the same Kubernetes cluster. For external Prometheus instances, again consider using Grafana Alloy as a relay.

More information can be found in the [Prometheus documentation](https://prometheus.io/docs/prometheus/latest/configuration/configuration/#scrape_config).

## Displaying the metrics

If you have deployed Prometheus, you can use [Grafana](https://grafana.com) to display the metrics. You can find dashboards on [Grafana](https://grafana.com/grafana/dashboards/).

{% hint style="warning" %}
We are not providing any dashboards at the moment.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs-v3.toucantoco.com/self-hosted-toucan/maintenance/metrics.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
