Monitoring and Observability
1. Checking Index Statistics
Example: Stats
s = index.describe_index_stats()
print(s["total_vector_count"], s["dimension"], s.get("index_fullness"))
2. Monitoring Vector Count
| Metric | Source |
|---|---|
| Total vectors | total_vector_count |
| Growth trend | Record over time |
| Alerting | Threshold-based on fullness |
3. Tracking Namespace Statistics
Example: Per-Namespace
for ns, info in s["namespaces"].items():
push_metric("pinecone.ns.vector_count",
value=info["vector_count"], tags={"ns": ns})
4. Measuring Query Latency
Example: Histogram
from prometheus_client import Histogram
qlat = Histogram("pinecone_query_latency_seconds", "...")
with qlat.time():
res = index.query(vector=qv, top_k=10)
5. Monitoring Upsert Throughput
| Metric | Detail |
|---|---|
| Vectors/sec | Client timer / total batch size |
| Failed batches | Counter |
| Bytes/sec | For storage growth |
6. Tracking API Error Rates
Example: Error Counter
from prometheus_client import Counter
err = Counter("pinecone_errors_total", "...", ["op", "code"])
try:
index.upsert(vectors=batch)
except Exception as e:
err.labels(op="upsert", code=getattr(e, "status", "unknown")).inc()
raise
7. Monitoring Index Fullness
| Value | Action |
|---|---|
| < 0.7 | Healthy |
| 0.7 – 0.85 | Plan scale-up |
| > 0.85 | Scale immediately |
| 1.0 | Upserts rejected |
8. Implementing Request Logging
Example: Structured Log
import logging, time
log = logging.getLogger("pinecone")
def query_logged(qv, top_k):
t = time.perf_counter()
res = index.query(vector=qv, top_k=top_k)
log.info("query", extra={"top_k": top_k,
"matches": len(res["matches"]),
"ms": (time.perf_counter()-t)*1000})
return res
9. Setting Up Alerting
| Alert | Threshold |
|---|---|
| Error rate > 1% | 5-min window |
| p99 latency > 500ms | 5-min window |
| Fullness > 0.85 | Immediate |
| QPS dropoff > 50% | Anomaly detection |
10. Using Metrics Dashboards
| Dashboard | Source |
|---|---|
| Pinecone console | Built-in metrics |
| Datadog/Grafana | Custom from SDK |
| Prometheus + Grafana | Self-hosted |
11. Tracking Cost Metrics
| Metric | Why |
|---|---|
| Storage GB | Predict serverless storage bill |
| Read units | Query cost projection |
| Write units | Upsert cost projection |
| Pod-hours | Pod-based pricing |
12. Understanding Usage Limits
| Limit | Approx (plan-dependent) |
|---|---|
| RPM | Plan-tiered; soft |
| Concurrent connections | Plan-tiered |
| Index count | 20 (Standard) |