logs2k6
Install

Turn real traffic into a k6 load test you can commit

The real endpoint mix at the real peak-hour rate, so you test the load your users actually create instead of a guessed model. logs2k6 reads a usage table from the logs or traffic stats you already have and writes a plain k6 script and a report.

npx logs2k6@0.1.0 from-usage usage.csv --peak --scale 0.1 -o load.js

Version 0.1.0 · Node.js 20+ · k6 to run the result · MIT · GitHub · npm · llms.txt

Early · v0.1 Checked in CI with k6 inspect and run by hand against a local test server. Not yet run against a real staging system.

  • Active scenario
  • Write, generated but disabled
  • Left out of the script
Endpoint mix at the busiest hour, scale 0.1
EndpointSharek6 rateStatus
GET /api/v1/products35%49/1mactive
GET /api/v1/products/{id}23%33/1mactive
GET /api/v1/users/me12%18/1mactive
GET /api/v1/cart10%15/1mactive
POST /api/v1/cart/items3.2%5/1mdisabled (write)

Active scenarios reproduce 94% of the traffic (8 of 11 endpoints).

The report from the synthetic example in the repo (a fake Shop API), generated with --peak --scale 0.1, abridged. Basis: the busiest hour, Nov 24, 14:00 UTC.

In short

  • What it does: reads requests per endpoint per hour, finds the busiest hour and writes a k6 script with one scenario per endpoint at its share of that peak.
  • What it needs: Node.js 20+ (22 or 24 recommended), a usage table, and k6 to run the result.
  • What it reads: only aggregated counts: method, templated path, calls and hour. Never raw logs.
  • Safe by default: no host from your logs in the script, writes off, works offline, no dependencies.
  • Honest: it reproduces the request mix and rate, not user sessions. Early: v0.1.

It tests the busiest hour

With an hourly table, logs2k6 takes the hour with the most calls across all endpoints. The production rate is that hour's calls divided by 3,600. Your test rate is that times --scale, the size of your test environment relative to production.

  • --peak (the default): the busiest hour.
  • --avg: the average over the whole window.
  • Daily table only: the busiest day as a 24-hour average. Real peaks are higher, and the report says so.

Calls per hour · all endpoints, Nov 23 to Nov 24 (UTC)

Calls per hour over 48 hours: about 9,000 an hour at night, rising each afternoon. The busiest hour is Nov 24, 14:00 UTC, with 84,327 calls.
Busiest hour: 84,327 calls, 23.42 req/s in production. At --scale 0.1 the test runs 8 active scenarios at 2.22 req/s.

What you get

Two files you can read, review and commit. Numbers are from the synthetic example: a fake Shop API, two days, hourly, 16 endpoints.

load.report.md the mix: share, rate at peak, rate in the test, what was left out and why
Mix at the busiest hour, Nov 24, 14:00 UTC, --scale 0.1
EndpointShareRPS at basisRPS in testk6 rateStatus
GET /api/v1/products35%8.230.8249/1mactive
GET /api/v1/products/{id}23%5.500.5533/1mactive
GET /api/v1/users/me12%2.920.3018/1mactive
GET /api/v1/cart10%2.430.2515/1mactive
GET /api/v1/categories5.8%1.360.138/1mactive
GET /api/v1/products/{id}/reviews3.8%0.900.0835/1mactive
POST /api/v1/cart/items3.2%0.750.0835/1mdisabled (write)
GET /api/v1/orders1.8%0.430.0503/1mactive
GET /api/v1/orders/{id}1.4%0.340.0332/1mactive
DELETE /api/v1/cart/items/{itemId}0.63%0.150.01553/1hdisabled (write)
POST /api/v1/orders0.63%0.150.01553/1hdisabled (write)
Not in the script
EndpointShareReason
POST /api/v1/payments0.48%share below 0.5%
GET /api/v1/search0.43%share below 0.5%
HEAD /health0.18%share below 0.5%
PATCH /api/v1/users/me0.06%share below 0.5%
GET /api/v1/legacy/catalog0.02%share below 0.5%
load.js excerpt of a plain k6 script: one constant-arrival-rate scenario per endpoint
// Required. The production host from the logs is never written into this script.
const BASE_URL = (__ENV.BASE_URL || '').replace(/\/+$/, '');
const DURATION = __ENV.DURATION || "5m";

// Writes (POST/PUT/PATCH/DELETE...) are disabled by default.
const INCLUDE_WRITES = false;

// Endpoint mix from real traffic (data only).
const ENDPOINTS = {
  "get_api_v1_products": { method: "GET", path: "/api/v1/products" },
  "get_api_v1_products_id": { method: "GET", path: "/api/v1/products/{id}" },
  // … 9 more
};

export const options = {
  scenarios: {
    "get_api_v1_products": { executor: 'constant-arrival-rate', exec: 'hit',
      rate: 49, timeUnit: "1m", duration: DURATION, preAllocatedVUs: 1, maxVUs: 5 },
    // … one scenario per endpoint
  },
  thresholds: {
    http_req_failed: ['rate<0.01'],
    http_req_duration: ['p(95)<500'], // TODO: set your own latency target (ms)
  },
};
  • Path parameters get the placeholder "1" with a TODO. Set real IDs with PARAM_<NAME> ({itemId} becomes PARAM_ITEMID=42) or PARAMS_FILE=params.json.
  • Thresholds: fewer than 1% failed requests (404s from placeholder IDs count), and a p(95) placeholder you set with --p95. Check: no 5xx.
  • Test length: 5 minutes per scenario by default; DURATION=10m overrides it at run time.

Full files: examples/load.js and examples/load.report.md.

Example numbers are synthetic (examples/ in the repo).

How it runs

Three steps. logs2k6 itself makes no network calls.

  1. Get an hourly usage table from your logs, for example with api-dead-ends: npx api-dead-ends convert accesslog access.log --hourly -o usage.csv
  2. npx logs2k6@0.1.0 from-usage usage.csv --peak --scale 0.1 -o load.js writes load.js and load.report.md next to it.
  3. Read the report, then run against staging, never production: PARAM_ID=42 BASE_URL=https://staging.example.test k6 run load.js
Each endpoint from usage.csv gets its place in the script
EndpointShareIn the script
GET /api/v1/products35%Active, 49/1m
GET /api/v1/users/me12%Active, 18/1m
POST /api/v1/cart/items3.2%Disabled (write)
GET /api/v1/orders/{id}1.4%Active, 2/1m
POST /api/v1/payments0.48%Share below 0.5%
Input: method, templated path, calls and hour. Nothing else.

Safe by default

Every path in the table comes from whoever sent the requests, so logs2k6 treats it as untrusted.

  • Never your production host. The table has no host column. The script needs BASE_URL at run time and refuses to start without it. Pointing it at staging is up to you.
  • Writes are off. POST, PUT, PATCH, DELETE and OPTIONS are generated but disabled unless you pass --include-writes. Use them only against a disposable environment.
  • Traffic is data, not code. Paths are validated, bad rows are skipped and listed in the report, and every string enters the script only as JSON data.

Your usage table

logs2k6 reads requests per endpoint, with paths already templated. Get it hourly if you can: without an hour column it can only compute averages, not the real peak. The table is the same one api-dead-ends produces.

nginx, Apache or JSON access logs files on disk, hourly
npx api-dead-ends convert accesslog access.log --hourly -o usage.csv
npx logs2k6@0.1.0 from-usage usage.csv --peak --scale 0.1 -o load.js
Kibana hourly, verified on real data

Only a browser login to Kibana? A browser opens, you log in, and the query runs through your session (needs Playwright).

npx api-dead-ends fetch kibana --url "<Discover URL>" \
  --service shop --days 7 --hourly -o usage.csv
npx logs2k6@0.1.0 from-usage usage.csv --peak --scale 0.1 -o load.js
VictoriaLogs, Prometheus hourly; VictoriaLogs tested against a fake server only

api-dead-ends gives hourly rows from fetch victorialogs … --hourly and convert prometheus … --hourly. Elasticsearch gives daily rows only. Sources: docs/INPUT.md.

Datadog, Loki, CloudWatch, App Insights and others daily or total counts

These api-dead-ends sources give daily or total counts only. logs2k6 then falls back to the busiest day's average or the average over the whole window, and the report says so.

Your own CSV or JSON a SQL GROUP BY, a spreadsheet export

Columns: method, path and calls are required; first_seen, last_seen, status, day and hour are optional. CSV needs a header row; JSON and JSONL work too, and - reads from stdin.

method,path,calls,first_seen,last_seen,status,day,hour
GET,/api/v1/products,8230,2026-11-24T14:00:00.000Z,2026-11-24T14:59:59.000Z,200:8230,2026-11-24,2026-11-24T14

Paths must be templated (/api/v1/orders/{id}), with no host, query string or fragment. Full contract, validation and the rate math: docs/INPUT.md.

Limits

What a v0.1 load model from counts can and cannot tell you.

  • Mix and rate, not sessions. One request per iteration: no user journeys, no think time, no auth, no query strings or headers. Only method and templated path.
  • The peak is an hourly average. Bursts inside that hour are higher. Add headroom with --scale if you need it.
  • Status is not used. Endpoints that fail in production are generated like the rest. api-dead-ends lists them; remove them from the table if you do not want them.
  • Whole numbers. k6 needs them, so each rate is rounded to requests per second, per minute or per hour. Endpoints below 1 request per hour are raised to 1/h.
  • Rare endpoints are thin. They get only a handful of requests in a 5-minute run. Use a longer --duration or DURATION if they matter.
  • Fixed VU limits. If the target is slow, k6 reports dropped_iterations and the real rate is below the plan. Check it before you trust the result.

FAQ

Does logs2k6 read my raw logs?

No. It reads only a usage table of aggregated counts: method, templated path and calls, plus status, day and hour if you have them. The generated script contains no host from your logs.

Does it send my data anywhere?

No. logs2k6 has no dependencies, works offline and makes no network calls. The generated script calls only the BASE_URL you choose.

Can I run the script against production?

Don't. The script requires BASE_URL at run time and does not check it against an allowlist, so pointing it at staging is up to you. Writes stay off unless you generate with --include-writes.

Why do I get 404s?

Path parameters like {id} default to "1", which usually does not exist. Set real IDs with PARAM_ID=42 or PARAMS_FILE=params.json. 404s count as failed requests in the threshold.

Does it simulate user journeys?

No. It reproduces the request mix and rate: one request per iteration, with no sessions, think time, auth, query strings or headers.

Do I need api-dead-ends?

No. Any CSV or JSON with method, path and calls works, for example a SQL GROUP BY or a spreadsheet export. api-dead-ends is one way to build the table from your logs, in the same format.

What does the scale option mean?

The size of your test environment relative to production. --scale 0.1 runs 10% of the production rate; the default, 1, is the full production rate.

Is it ready for real use?

It is early: v0.1. The script is checked in CI with k6 inspect and was run by hand with k6 v2.4.0 against a local test server: for the example at --scale 0.5 the report planned 11.07 req/s and k6 sent 11.35 req/s. It has not yet run against a real staging system. Please tell me how it goes.

Is it free?

Yes. It is open source under the MIT license, with no runtime dependencies.

Start with one command

Point it at your hourly usage table. It writes load.js and load.report.md; read the report before you run anything.

No data at hand? Clone the repo and run node bin/logs2k6.mjs sample -o usage.csv for a synthetic table (a fake Shop API).

npx logs2k6@0.1.0 from-usage usage.csv --peak --scale 0.1 -o load.js

Support this tool

One-time, by card, Apple Pay or Google Pay. Processed by Stripe.

Or globally: npm install -g logs2k6 · npm · GitHub · tell me how it went