tutorial

How to Monitor Hugging Face Text Generation Inference (TGI) with Vigilmon

TGI is a production-grade LLM inference server — but model loading, GPU exhaustion, and request queue saturation can bring it down silently. Here's how to monitor TGI with Vigilmon.

Hugging Face Text Generation Inference (TGI) is a high-performance inference server for LLMs — supporting Llama, Mistral, Falcon, BLOOM, and 50+ other models with tensor parallelism, continuous batching, quantization (GPTQ, AWQ, bitsandbytes), and an OpenAI-compatible API. When TGI goes down, every downstream application that depends on it — chatbots, code assistants, document processors — stops working. Vigilmon keeps a constant watch on your TGI endpoints, health checks, and GPU node availability so you catch outages before users do.

What You'll Set Up

  • HTTP uptime monitors for TGI's health endpoint and generate API
  • TCP port monitors for TGI in multi-node tensor-parallel deployments
  • Cron heartbeat monitors for batch inference jobs
  • SSL certificate alerts for TGI HTTPS endpoints
  • Alerting thresholds tuned for LLM inference latency

Prerequisites

  • TGI running via Docker, text-generation-launcher, or Kubernetes
  • TGI accessible over HTTP or HTTPS (typically port 80/443 or 8080)
  • A free Vigilmon account

Step 1: Monitor TGI's Built-In Health Endpoint

TGI exposes a /health endpoint that returns 200 OK when the model is loaded and the server is ready to accept requests. This is your primary liveness signal:

  1. Log in to vigilmon.online and click Add Monitor.
  2. Set Type to HTTP / HTTPS.
  3. Enter: https://tgi.yourdomain.com/health (or http://localhost:8080/health for local deployments).
  4. Set Check interval to 1 minute.
  5. Set Expected HTTP status to 200.
  6. Click Save.

TGI's /health endpoint returns a non-200 status during model loading — this is expected at startup. Set Consecutive failures before alert to 3 so Vigilmon doesn't page you during a cold start.


Step 2: Monitor the Generate Endpoint Directly

The /health endpoint confirms the server process is alive, but it does not confirm that the model can actually generate tokens. Add a second monitor for the generate endpoint using a minimal test payload:

  1. In Vigilmon, click Add MonitorHTTP / HTTPS.
  2. Set Method to POST.
  3. Enter: https://tgi.yourdomain.com/generate.
  4. Set Request body:
{
  "inputs": "Hello",
  "parameters": {
    "max_new_tokens": 5,
    "temperature": 0.1
  }
}
  1. Set Request headers: Content-Type: application/json.
  2. Set Expected HTTP status to 200.
  3. Set Expected response body contains: generated_text.
  4. Set Check interval to 5 minutes.
  5. Click Save.

This test catches model-level failures (OOM errors, corrupt weights) that /health does not surface.


Step 3: OpenAI-Compatible API Monitor

TGI supports an OpenAI-compatible /v1/chat/completions endpoint. If downstream apps use the OpenAI client library pointed at TGI, monitor the OpenAI-compatible surface:

# Manual test of the OpenAI-compatible endpoint
curl https://tgi.yourdomain.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "tgi",
    "messages": [{"role": "user", "content": "ping"}],
    "max_tokens": 5
  }'

Add a Vigilmon HTTP monitor for this URL with the same JSON body. A failure here means clients using the OpenAI SDK against TGI will start erroring even if the native /generate endpoint still works.


Step 4: TCP Port Monitors for Multi-Node Deployments

Tensor-parallel TGI deployments spread a single model across multiple GPU nodes. Each shard node must be reachable or the whole inference cluster degrades. Add TCP monitors for each node:

  1. In Vigilmon, click Add MonitorTCP.
  2. Enter the host and port for each shard: tgi-node-1.internal:8080, tgi-node-2.internal:8080, etc.
  3. Set Check interval to 1 minute.
  4. Click Save.

A single dead shard node causes TGI to stall on requests that require that shard — catching it at the TCP layer is faster than waiting for inference timeouts to bubble up to your application logs.


Step 5: Heartbeat Monitoring for Batch Inference Jobs

Offline batch inference jobs (processing document sets, generating embeddings, running evaluations) have no persistent HTTP endpoint to probe. Use Vigilmon's cron heartbeat:

  1. In Vigilmon, click Add MonitorCron Heartbeat.
  2. Set the expected ping interval to match your batch schedule.
  3. Copy the heartbeat URL: https://vigilmon.online/heartbeat/abc123.
  4. Add the ping to your batch script:
import requests
from text_generation import Client

client = Client("http://tgi.yourdomain.com")

def run_batch(documents: list[str]) -> list[str]:
    results = []
    for doc in documents:
        response = client.generate(doc, max_new_tokens=256)
        results.append(response.generated_text)
    return results

if __name__ == "__main__":
    docs = load_documents("/data/batch/")
    outputs = run_batch(docs)
    save_results(outputs, "/data/results/")
    
    # Signal successful completion
    requests.get("https://vigilmon.online/heartbeat/abc123", timeout=5)

If the batch job runs out of GPU memory mid-way, times out, or encounters a corrupt model shard, the heartbeat is never sent.


Step 6: SSL Certificate Alerts

TGI deployments exposed to the internet (or even internal services behind a reverse proxy) need valid TLS:

  1. Open the HTTP monitor created in Step 1.
  2. Enable Monitor SSL certificate.
  3. Set Alert when certificate expires in less than 21 days.
  4. Click Save.

LLM inference endpoints often sit behind nginx or Caddy. The TLS certificate is on the proxy layer, not TGI itself — if the proxy certificate lapses, all downstream LLM-powered features break without any TGI process dying.


Step 7: Configure Alert Channels and Thresholds

LLM inference has different latency characteristics than typical web APIs — cold starts take 30–120 seconds for large models, and TTFT (time to first token) can be several seconds even under normal load. Tune accordingly:

  1. Go to Alert Channels in Vigilmon and add Slack, email, or a webhook.
  2. For the /health monitor, set Consecutive failures before alert to 3 to absorb model loading delays.
  3. For the /generate monitor, set Consecutive failures before alert to 2.
  4. Set Request timeout to 30 seconds on the generate endpoint monitor.

Suppress alerts during model hot-swaps or quantization jobs:

# Before loading a new model checkpoint
curl -X POST https://vigilmon.online/api/maintenance \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{"monitor_id": "abc123", "duration_minutes": 15}'

docker restart tgi-server

Deployment Reference

Docker

docker run --gpus all --shm-size 1g \
  -p 8080:80 \
  -v $PWD/models:/data \
  ghcr.io/huggingface/text-generation-inference:latest \
  --model-id meta-llama/Meta-Llama-3-8B-Instruct

Monitor: http://localhost:8080/health

Kubernetes

livenessProbe:
  httpGet:
    path: /health
    port: 80
  initialDelaySeconds: 120   # allow time for model load
  periodSeconds: 30
readinessProbe:
  httpGet:
    path: /health
    port: 80
  initialDelaySeconds: 120
  periodSeconds: 10

Vigilmon supplements Kubernetes probes with external monitoring — K8s probes restart pods; Vigilmon alerts you when the restart loop itself is failing.


Summary

| Monitor | Target | What It Catches | |---|---|---| | /health endpoint | https://tgi.yourdomain.com/health | Server crash, model not loaded | | /generate endpoint | POST /generate with test payload | Model inference failure, OOM | | OpenAI-compatible API | POST /v1/chat/completions | Client-facing endpoint degradation | | TCP shard nodes | Each node host:port | Dead GPU shard in tensor-parallel cluster | | Cron heartbeat | Heartbeat URL | Batch job OOM or crash | | SSL certificate | Each TGI HTTPS domain | TLS expiry on proxy layer |

TGI makes production LLM serving tractable — but GPU memory, model weight loading, and shard coordination introduce failure modes that standard web monitoring misses. With Vigilmon covering your health endpoints, generate surfaces, batch heartbeats, and certificates, you get the observability layer that LLM infrastructure demands.

Monitor your app with Vigilmon

Free plan — 5 monitors, no credit card required. Up and running in 60 seconds.

Start free →