---
name: obistack-wizard
description: Instrument a project so it sends logs, metrics and traces to ObiStack, then prove the data arrived. Use when the user asks to set up ObiStack, add observability or logging to a repository, connect an app to ObiStack, or work out why an app's data is not showing up.
license: MIT
metadata:
  version: "1.0.0"
---

# Set up ObiStack in a project

You are doing what the ObiStack setup wizard does: find out what the project
is built with, add OpenTelemetry to it, send a test event and check that it
arrived. Work in that order and show the user every change before you make it.

You use three things, and nothing else:

- the `obi` command line, signed in as the user,
- the ObiStack MCP tools, if the user has connected them,
- the project's own package manager and files.

Never write a key or token into a file that is committed. Read keys from
environment variables, and add the variable names (with no values) to the
project's example environment file if it has one.

## 1. Check you can reach ObiStack

```bash
obi whoami
```

If that fails, ask the user to run `obi login` themselves. Do not ask them to
paste a token into the chat.

Then see whether the workspace already has data, and from where:

```bash
obi get onboarding
obi get sources
```

With the MCP tools connected, `list_sources` answers the same question.

## 2. Detect the stack

Read the project's manifests before you decide anything:

| You find | The project is |
|---|---|
| `package.json` with `next` | Next.js (Node.js) |
| `package.json` with `express`, `fastify`, `@nestjs/core` or `koa` | Node.js service |
| `pyproject.toml` or `requirements.txt` with `django`, `flask` or `fastapi` | Python service |
| `go.mod` | Go service |
| `pom.xml` or `build.gradle` | Java service |
| `*.csproj` | .NET service |
| A Collector config (`otel-collector*.yaml`, a Helm values file) | Already using OpenTelemetry |

A monorepo can hold several of these. List what you found and ask which
services to instrument before changing anything.

If the project already exports OpenTelemetry, do not add a second SDK. Point
its existing exporter at ObiStack instead (step 4).

## 3. Add OpenTelemetry

Use the official OpenTelemetry SDK and auto-instrumentation for the language,
installed with the project's own package manager and lockfile. Prefer
auto-instrumentation over hand-written spans. Set `service.name` to the
service's real name, and `deployment.environment` when the project has more
than one environment.

Show the user the diff, and wait for a yes before you write it.

## 4. Point the exporter at ObiStack

ObiStack accepts OTLP over HTTP. The exporter needs two environment
variables, read at run time:

```bash
OTEL_EXPORTER_OTLP_ENDPOINT="$OBISTACK_INGEST_URL/ingest/otel"
OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer $OBISTACK_INGEST_KEY"
```

`OBISTACK_INGEST_URL` is the ingest address the user's workspace shows under
Connect Your Data, and `OBISTACK_INGEST_KEY` is an ingest key created there.
An ingest key can only send data, never read it, so it is the right key for
an app. Ask the user to create one and put it in their secret store or local
environment file. You never see its value.

The exporter appends `/v1/logs`, `/v1/traces` and `/v1/metrics` itself. Both
`http/protobuf` and `http/json` work; gRPC does not.

## 5. Send a test event

Before you start the app, check that the key works on its own:

```bash
obi send "obistack setup test" --service setup-check --level info
```

`obi send` reads the ingest key from `OBI_INGEST_KEY`, so ask the user to
export it in their shell first. Then start the app and exercise one request.

## 6. Prove it arrived

Events are searchable a few seconds after they are accepted.

```bash
obi search 'service="setup-check"' --from now-15m
obi search 'service="checkout-api"' --from now-15m --limit 20
```

Use the service name you set in step 3 in place of `checkout-api`. To see
every service that sent something recently:

```obiql
* | stats count() by service
```

With the MCP tools, run the same queries with `run_query` and share the
Explorer link it returns.

## When something fails

| Symptom | What to check |
|---|---|
| `obi send` says the key is refused | The key was revoked, or it is a personal access token rather than an ingest key. |
| The test event arrives but the app's data does not | The app is not reading the environment variables, or the exporter uses gRPC. Print the effective OTLP settings at start-up. |
| Data arrives with no `service` | `service.name` is not set on the resource. |
| Some services arrive and others do not | Each process needs the variables. Check the container or process manager config for the missing ones. |
| A partial install failed half way | Revert the uncommitted changes with the user's agreement, then start again at step 3 for one service at a time. |

Report what you changed, which services now send data, and the queries the
user can run to see it.
