# Osservabilità

> Traccia ogni chiamata LLM con Langfuse e monitora l'intero sistema con Grafana e OpenTelemetry: due stack opzionali accanto alla dashboard integrata.

Due stack opzionali mostrano cosa sta facendo PentAGI: Langfuse per le chiamate ai modelli e Grafana con OpenTelemetry per il resto del sistema.

La **Dashboard** integrata di PentAGI include già grafici di [flows](https://pentagi.com/it/docs/glossary/#flow), [tool calls](https://pentagi.com/it/docs/glossary/#tool-call), token e costi nel tempo; gli stack seguenti aggiungono tracce complete e metriche di sistema.

![La dashboard integrata](https://pentagi.com/images/product/dashboard.webp)

## [Langfuse](https://pentagi.com/it/docs/configuration/observability/#langfuse)

Langfuse registra prompt, completamenti, token e costi per ogni [agent](https://pentagi.com/it/docs/glossary/#agent).

```bash
LANGFUSE_BASE_URL=http://langfuse-web:3000
LANGFUSE_PROJECT_ID=same_as_LANGFUSE_INIT_PROJECT_ID
LANGFUSE_PUBLIC_KEY=same_as_LANGFUSE_INIT_PROJECT_PUBLIC_KEY
LANGFUSE_SECRET_KEY=same_as_LANGFUSE_INIT_PROJECT_SECRET_KEY
```

Imposta le credenziali di Langfuse in `.env` (`LANGFUSE_POSTGRES_*`, `LANGFUSE_CLICKHOUSE_*`, `LANGFUSE_REDIS_AUTH`, `LANGFUSE_SALT`, `LANGFUSE_ENCRYPTION_KEY`, `LANGFUSE_NEXTAUTH_SECRET`, `LANGFUSE_INIT_USER_*` e le chiavi del progetto), quindi avvia lo stack:

```bash
curl -O https://raw.githubusercontent.com/vxcontrol/pentagi/main/docker-compose-langfuse.yml
docker compose -f docker-compose.yml -f docker-compose-langfuse.yml up -d
```

L'interfaccia di Langfuse è disponibile su `http://localhost:4000`.

## [Grafana e OpenTelemetry](https://pentagi.com/it/docs/configuration/observability/#grafana-and-opentelemetry)

```bash
OTEL_HOST=otelcol:8148
```

```bash
git clone --depth 1 https://github.com/vxcontrol/pentagi.git pentagi-src
cp -r pentagi-src/observability ./observability
rm -rf pentagi-src
curl -O https://raw.githubusercontent.com/vxcontrol/pentagi/main/docker-compose-observability.yml
docker compose -f docker-compose.yml -f docker-compose-observability.yml up -d
```

Grafana è disponibile su `http://localhost:3000`, con metriche in VictoriaMetrics, tracce in Jaeger e log in Loki.

> [!NOTE]
> Per inviare la telemetria di Langfuse nello stesso stack, imposta `LANGFUSE_OTEL_EXPORTER_OTLP_ENDPOINT=http://otelcol:4318`.

## [Tutto insieme](https://pentagi.com/it/docs/configuration/observability/#everything-together)

```bash
git clone --depth 1 https://github.com/vxcontrol/pentagi.git pentagi-src
cp -r pentagi-src/examples/graphiti ./graphiti
cp -r pentagi-src/examples/neo4j ./neo4j
rm -rf pentagi-src
curl -O https://raw.githubusercontent.com/vxcontrol/pentagi/main/docker-compose-graphiti.yml
docker compose \
  -f docker-compose.yml \
  -f docker-compose-langfuse.yml \
  -f docker-compose-graphiti.yml \
  -f docker-compose-observability.yml \
  up -d
```