Job aid: the master’s workbench
Section titled “Job aid: the master’s workbench”The five windows onto the engine that every ACM lab uses, set up in
M0-S2. Names are Larkspur Lab’s: cluster lk-lab, release lk,
namespace larkspur, datastores in namespace datastores, bus virtual host lk, platform databases
prefixed lk-. Keep this page open during every lab.
Once per terminal
Section titled “Once per terminal”export BASE=http://localhost # Larkspur Lab; use your Larkspur Dev address for Devread -rs TOKEN && export TOKEN # the Larkspur Workbench token; never in a fileexport values="-f lk-values.yaml -f lk-secrets.yaml -f pack-values.yaml"R="-s -u lab:lab-only-rabbit -H content-type:application/json" # the bus tap's management callsPort-forwards, each in its own terminal: RabbitMQ management
kubectl -n datastores port-forward svc/rabbitmq 15672:15672 · Mailpit
kubectl -n datastores port-forward svc/mailpit 8025:8025.
1. The API (both environments)
Section titled “1. The API (both environments)”| Job | Command |
|---|---|
| A call with your own trace id | curl -s -H "x-app-token: $TOKEN" -H "x-correlation-id: lk-<you>-<n>" "$BASE/api/…" |
| The modules | curl -s -H "x-app-token: $TOKEN" "$BASE/api/v1/data-module" | jq '.result[] | {id, normalizedName}' |
| An entity’s id | curl -s -G -H "x-app-token: $TOKEN" "$BASE/api/v1/entities" --data-urlencode 'filter={"where":{"normalizedName":"<entity>"}}' | jq -r '.result[0].id' |
| An entity’s records | curl -s -H "x-app-token: $TOKEN" "$BASE/api/v2/entities/<entity id>/entries" | jq (by id: on 1.10 a list by normalized name answers empty unless you have Edit at system level) |
| One record | curl -s -H "x-app-token: $TOKEN" "$BASE/api/v1/entities/<entity>/entries/<id>" | jq |
| Headers and status too | add -i (or -D - to print headers before a piped body) |
Read the answer before the body: success: true with result, or success: false with
error.code, error.message and error.traceId. A /v3 GET answers with the bare body. The
workbench credential is for GET only.
2. The logs (Lab)
Section titled “2. The logs (Lab)”| Job | Command |
|---|---|
| One id in every pod | kubectl -n larkspur logs -l app.kubernetes.io/instance=lk --all-containers --prefix --since=10m --max-log-requests=30 | grep <id> |
| One service only | kubectl -n larkspur logs deploy/<deployment> --since=10m | grep <id> |
| Readable lines | append | sed 's/^[^{]*//' | jq -c '{service, level, msg, correlationId}' |
| A crashed container | kubectl -n larkspur logs <pod> --previous |
Every line is one JSON object with service, level, msg, and inside a request or a message
handler, correlationId, userId and spaceId. Work that carries no id logs NO-TRACE-ID.
3. The bus tap (Lab)
Section titled “3. The bus tap (Lab)”| Job | Command |
|---|---|
| Tracer on | kubectl -n datastores exec deploy/rabbitmq -- rabbitmqctl trace_on -p lk |
| Create the tap (once) | curl $R -X PUT http://localhost:15672/api/queues/lk/acm-tap -d '{"durable":false,"arguments":{"x-max-length":500}}' |
| Bind it (once) | curl $R -X POST http://localhost:15672/api/bindings/lk/e/amq.rabbitmq.trace/q/acm-tap -d '{"routing_key":"publish.#"}' |
| Also catch deliveries (once; M2-S2) | curl $R -X POST http://localhost:15672/api/bindings/lk/e/amq.rabbitmq.trace/q/acm-tap -d '{"routing_key":"deliver.#"}' |
| Empty it before a test | curl $R -X DELETE http://localhost:15672/api/queues/lk/acm-tap/contents |
| Read what it caught | curl $R -X POST http://localhost:15672/api/queues/lk/acm-tap/get -d '{"count":20,"ackmode":"ack_requeue_false","encoding":"auto"}' | jq |
| Just exchange and key | append | jq '.[] | {x: .properties.headers.exchange_name, k: .properties.headers.routing_keys}' |
One line per trace (publish.<exchange> or deliver.<queue>) | append | jq -r '.[].routing_key' |
| Payloads | append | jq '.[].payload | fromjson' |
| Who published (pod address) | jq '.[0].properties.headers.connection', then kubectl -n larkspur get pods -o wide |
| Queues, consumers, depth | kubectl -n datastores exec deploy/rabbitmq -- rabbitmqctl list_queues -p lk name consumers messages |
| Tracer off | kubectl -n datastores exec deploy/rabbitmq -- rabbitmqctl trace_off -p lk |
Never take messages from a platform queue (…-service-queue): only from acm-tap. Switch the tracer
off when you finish a lab; it copies every message.
4. The record store (Lab, reads only)
Section titled “4. The record store (Lab, reads only)”| Job | Command |
|---|---|
| Open the data database | kubectl -n datastores exec -it mongo-0 -- mongosh --quiet lk-data |
| Which databases | show dbs (each platform database starts with lk-) |
| An entity’s records | db.<entity normalized name>.find({}, {id:1, state:1, value:1}).limit(5) |
| A definition | db.DataEntity.findOne({normalizedName: "<entity>"}) |
| How many | db.<entity>.countDocuments({state: 1}) |
| Applied migrations | db.Migration.find().sort({_id:-1}).limit(5) |
| See the pipeline a read ran (M3-S2) | db.setProfilingLevel(2), run the read, then db.system.profile.find({ns: "lk-data.<entity>"}).sort({ts:-1}).limit(1).forEach(p => printjson(p.command.pipeline)); always db.setProfilingLevel(0) after |
Only find, findOne, countDocuments, aggregate, explain and show, plus the profiler switch in the lab. Never insert, update, delete,
drop or createIndex: the platform changes its own data, so every engine sees the change.
5. The portal (both environments)
Section titled “5. The portal (both environments)”Signed in as rami.aziz. The designer: Administration › Applications › Modules. Run
histories: Administration › Monitoring. Each record’s own history is on the record.
| To | Do |
|---|---|
| Reset the suite’s data | node larkspur-pack/seed/seed.mjs --base-url $BASE --reset |
| Rebuild the whole lab | kind delete cluster --name lk-lab, then M0-S2 from step 1 |
- Write to MongoDB, flush Redis, or delete a queue or a migration record to make an error go away.
- Put a token or password in a file, a command line or a screenshot.
- Use the workbench credential, the tracer or these lab passwords anywhere but your lab.