Setup guide

Connect any app in five minutes

Grafatsuki receives three kinds of signals over one HTTPS link. Plant an app to get its token — every app has a Setup page with this guide filled in, plus a prompt for your coding agent.

1. Plant an app, copy its link

After signing up, Plant an app. Its Setup page shows the endpoint and a token:

GRAFATSUKI_URL=https://grafatsuki.com/api/v1/ingest
GRAFATSUKI_TOKEN=gk_…   # per app, keep it secret

Send it as Authorization: Bearer gk_… (or X-Grafatsuki-Token).

2. Easiest: let your coding agent do it

Open your repository in Claude Code, Cursor, Codex or Copilot and paste the prompt from your app's Setup page. For Laravel it looks like this:

Add Grafatsuki observability (logs, metrics and request/job traces) to this Laravel app ("my app").
Grafatsuki is a hosted log & metrics dashboard; the app sends JSON to one HTTP endpoint. Do exactly this:

1. Download the three client files into these exact paths (create folders if needed):
   curl -fsSL https://grafatsuki.com/sdk/laravel-client.php -o app/Support/Grafatsuki.php
   curl -fsSL https://grafatsuki.com/sdk/laravel-log-handler.php -o app/Logging/GrafatsukiHandler.php
   curl -fsSL https://grafatsuki.com/sdk/laravel-middleware.php -o app/Http/Middleware/GrafatsukiTrace.php
   Read them; do not rewrite them.

2. Add to .env (and to .env.example with an EMPTY token — never commit the real token):
   GRAFATSUKI_URL=https://grafatsuki.com/api/v1/ingest
   GRAFATSUKI_TOKEN=gk_YOUR_APP_TOKEN

3. In config/services.php add:
   'grafatsuki' => [
       'url' => env('GRAFATSUKI_URL'),
       'token' => env('GRAFATSUKI_TOKEN'),
       'enabled' => env('GRAFATSUKI_ENABLED', true),
       'queries' => env('GRAFATSUKI_QUERIES', true),
       'timeout' => 2,
   ],

4. In config/logging.php add a channel and put it in the default stack (keep the existing channels):
   'grafatsuki' => [
       'driver' => 'monolog',
       'handler' => App\Logging\GrafatsukiHandler::class,
       'level' => env('GRAFATSUKI_LEVEL', 'info'),
   ],
   Then make the 'stack' channel include 'grafatsuki' (e.g. LOG_STACK=single,grafatsuki in .env,
   or add it to the stack's channels array — whichever this app already uses).

5. Register the middleware globally. Laravel 11+: in bootstrap/app.php inside withMiddleware():
   $middleware->append(\App\Http\Middleware\GrafatsukiTrace::class);
   (Laravel 10 and older: add it to $middleware in app/Http/Kernel.php.)

6. In App\Providers\AppServiceProvider::boot() call:
   \App\Support\Grafatsuki::boot();

7. Add business metrics where they matter. Look through the code for the important moments and add one line each, e.g.:
   \App\Support\Grafatsuki::increment('users.registered');
   \App\Support\Grafatsuki::increment('payments.succeeded', 1, ['plan' => $plan]);
   \App\Support\Grafatsuki::gauge('queue.pending', $count);
   Wrap slow external calls (payment gateways, AI APIs, emails) in a span:
   $result = \App\Support\Grafatsuki::span('openai chat', fn () => ..., 'http');
   Use short dotted lowercase names. Don't put personal data (emails, names) in tags.

8. Deploy markers: if this repository has a deploy script (deploy.sh, a Makefile target, a GitHub Actions
   workflow, an Envoy/Deployer task…), add this as its last step so every deploy draws a line on the charts:
   curl -fsS -m 10 -X POST https://grafatsuki.com/api/v1/deploys -H "Authorization: Bearer $GRAFATSUKI_TOKEN" -H "Content-Type: application/json" -d "{\"version\":\"$(git rev-parse --short HEAD)\",\"commit\":\"$(git rev-parse HEAD)\",\"environment\":\"production\"}" || true
   (GRAFATSUKI_TOKEN must be available to the script; the trailing `|| true` keeps a deploy from failing because of it.)
   If the app uses Laravel's scheduler, tell me which scheduled tasks exist — I will create a check-in for each in
   Grafatsuki and you can add ->pingOnSuccess(…) to them.

9. Verify, then tell me the result:
   php artisan config:clear
   php artisan tinker --execute="Log::info('Grafatsuki connected'); \App\Support\Grafatsuki::flush();"
   The line should appear in Grafatsuki within seconds. Also:
   curl -s https://grafatsuki.com/api/v1/ingest -H "Authorization: Bearer $GRAFATSUKI_TOKEN" -H "Content-Type: application/json" -d '{"message":"ping"}'
   should answer {"ok":true,...}.

Every response now carries an X-Trace-Id header; that id finds the request's logs, queries and timings in Grafatsuki.

3. The payload

POST https://grafatsuki.com/api/v1/ingest with JSON — any of the three arrays, up to 1000 items per request. Answers 202 with what was kept and why anything was dropped.

{
  "logs": [{
    "level": "error",                 // debug info notice warning error critical alert emergency (or Monolog numbers)
    "message": "Payment gateway timed out",
    "channel": "payments",            // optional
    "context": {"order": 2041},       // optional, any JSON
    "environment": "production",      // optional
    "trace_id": "9f2c81aa…",          // optional — links the log to its request
    "timestamp": "2026-11-30T12:04:15Z"  // optional, ISO-8601 or unix seconds/ms
  }],
  "metrics": [{
    "name": "orders.placed",          // letters, digits . _ - : /
    "type": "counter",                // counter (summed) · gauge (averaged) · timing (ms)
    "value": 1,
    "tags": {"plan": "pro"}           // optional, used for "split by"
  }],
  "spans": [{
    "trace_id": "9f2c81aa…",          // required — one per request / job
    "span_id": "a1b2c3",              // optional
    "parent_span_id": null,           // null = the transaction itself
    "name": "GET /orders/{id}",
    "kind": "request",                // request job command query http cache custom
    "status": "ok",                   // ok · error
    "duration_ms": 182.4,
    "started_at": "2026-11-30T12:04:14.812Z",
    "attributes": {"http.status": 200}
  }]
}

Shortcuts: a single log object, or a bare array of logs, also works. /api/v1/logs, /metrics and /spans take just one kind. GET /api/v1/ping checks a token.

Deploy markers

POST https://grafatsuki.com/api/v1/deploys with the app token. Every field is optional: version, commit, environment, url, description, timestamp. The last line of a deploy script:

curl -fsS -m 10 -X POST https://grafatsuki.com/api/v1/deploys -H "Authorization: Bearer $GRAFATSUKI_TOKEN" -H "Content-Type: application/json" -d "{\"version\":\"$(git rev-parse --short HEAD)\",\"commit\":\"$(git rev-parse HEAD)\",\"environment\":\"production\"}" || true

Cron check-ins

Create a check-in on an app's Uptime tab and you get a ping URL. The job calls it when it finishes; if no call arrives within the interval plus the grace, you are alerted. No token needed — the URL is the credential.

/ping/<id>          the job succeeded
/ping/<id>/start    the job started (the next ping then reports its duration)
/ping/<id>/fail     the job failed — alerts at once

# Laravel's scheduler does this for you:
Schedule::command('backup:run')->daily()
    ->pingBefore($url.'/start')->pingOnSuccess($url)->pingOnFailure($url.'/fail');

Alerts

On an app's Alerts tab: too many errors, failing requests, slow responses (p95), a metric crossing a value, the app going quiet, a new kind of error, or a resolved issue coming back. Alerts go to email, Slack, Discord, Telegram or a signed webhook — add those once under Notification channels.

Webhook bodies are JSON (event, app, title, body, value, url, at). With a secret set, X-Grafatsuki-Signature: t=<unix>,sha256=<hex> is an HMAC-SHA256 of t + "." + body.

4. Try it with curl

curl -X POST https://grafatsuki.com/api/v1/ingest \
  -H "Authorization: Bearer gk_YOUR_APP_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"logs":[{"level":"info","message":"Hello from curl"}],"metrics":[{"name":"signups","type":"counter","value":1}]}'

5. Drop-in clients

Laravel — clienthttps://grafatsuki.com/sdk/laravel-client.php
Laravel — log handlerhttps://grafatsuki.com/sdk/laravel-log-handler.php
Laravel — trace middlewarehttps://grafatsuki.com/sdk/laravel-middleware.php
Node.js 18+https://grafatsuki.com/sdk/node.mjs

Python, in twelve lines

import logging, requests, os, threading
URL, TOKEN = os.environ["GRAFATSUKI_URL"], os.environ["GRAFATSUKI_TOKEN"]
class GrafatsukiHandler(logging.Handler):
    def emit(self, record):
        body = {"logs": [{"level": record.levelname.lower(), "message": self.format(record),
                          "channel": record.name, "timestamp": record.created}]}
        threading.Thread(target=self._send, args=(body,), daemon=True).start()
    def _send(self, body):
        try: requests.post(URL, json=body, headers={"Authorization": f"Bearer {TOKEN}"}, timeout=3)
        except Exception: pass
logging.getLogger().addHandler(GrafatsukiHandler())

Go, Ruby and Java

One file each, standard library only, never throwing into your app; they buffer and send every 3 seconds. Each has a request middleware (trace id, root span, http.requests and http.duration) and log / metric / span helpers — usage is at the top of each file.

In the browser

One script tag sends front-end JavaScript errors and page timings. Each app's Setup page has it with its public browser key:

<script src="https://grafatsuki.com/sdk/browser.js" data-key="gkb_…" data-environment="production" defer></script>

Uncaught errors and unhandled promise rejections become error logs on the browser channel, with the page, the stack and the browser. Timings become metrics: web.ttfb, web.dom_ready, web.load, web.lcp (milliseconds) and web.cls, tagged with the page. data-sample="0.2" sends timings for a fifth of page views; errors are always sent. From your code: grafatsuki.log(), .warn(), .error(err), .metric(name, value, tags). The browser key can only do this — at most 50 items a page view, never spans — and can be limited to your origins.

OpenTelemetry

Any OpenTelemetry SDK or Collector can send logs, traces and metrics over OTLP/HTTP with the JSON encoding. Set three environment variables on your app:

OTEL_EXPORTER_OTLP_ENDPOINT=https://grafatsuki.com/api/v1/otlp
OTEL_EXPORTER_OTLP_PROTOCOL=http/json
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20gk_your_app_token

The SDK adds /v1/logs, /v1/traces and /v1/metrics. Severity becomes the level, the instrumentation scope becomes the channel, span kinds and db.system decide request / http / query / job, and a histogram point is stored as its mean. Protobuf is not accepted; gzip is.

Queries and dashboards

On Explore, ask anything with a short pipeline, then keep the answer as a dashboard panel:

logs | where level >= error and message ~ "timeout" | count by time
spans | where root = true | p95(duration) by name | top 10
metric http.duration | where route = "GET /checkout" | avg by time

Start with logs, spans or metric <name>; filter with where (= != > >= < <= ~, joined with and); aggregate with count sum avg min max p50 p90 p95 p99, optionally by time or by <field>; finish with top N or limit N. A dashboard can be shared read-only with a link.

Scripts can run the same queries over REST with a personal token from the Assistants & API page: GET https://grafatsuki.com/api/v1/query?q=…&range=24h with Authorization: Bearer gmcp_….

The AI gardener and your own assistant

On the AI gardener page, ask about your apps in plain words or press Explain on any issue. Every check shows its price in credits first and only runs when you accept; a check that fails is refunded. A daily or weekly digest can be emailed to you.

In Claude on the web or the app: Settings → Connectors → Add custom connector, paste https://grafatsuki.com/api/mcp, and approve when Grafatsuki asks you to sign in.

For Claude Code, Cursor or any MCP client that takes a config file, make a token on the Assistants page, then:

claude mcp add --transport http grafatsuki https://grafatsuki.com/api/mcp --header "Authorization: Bearer gmcp_…"

The assistant can list apps, search logs, read issues, traces, metrics, uptime and alerts. It can never change or delete anything.

How the garden reads your signals

LevelIn the garden
debug Seed
info Leaf
notice Sprout
warning Marigold
error Mushroom
critical Thorn
alert Storm
emergency Wildfire

An app is awake if it sent anything in the last 15 minutes, dozing within a day, asleep after that. Data is kept for each app's retention window (14 days by default), then composted.