New site key, first events, first schema
This guide walks through the three steps that take a new app or website from nothing to queryable event data in your StarRocks tables:
- Create a site key for the app on your codops service.
- Send a few test events with that key from the command line.
- Register a schema for the new event type, so the events load into a table.
The example throughout is a video player that starts reporting rebuffering:
each time playback stalls to refill its buffer, the player sends a
media_buffering event saying how long the stall lasted, at which bitrate and
from which CDN. That is the raw material for streaming quality analytics:
stalls per hour of viewing, by CDN, device or live versus on demand.
You can do all three steps yourself. The whole round trip takes about half an hour, most of it waiting for the pipeline between steps.
Who can do what
| Step | What you do | Who can do it |
|---|---|---|
| 1 · Create a site key | Name the app and choose its environment | Admins of your codops |
| 2 · Send test events | Push a few events with that key from the command line | Any member of your codops |
| 3 · Register a schema | Save the shape of the new event type so its events load into a table | Admins of your codops |
If you are not an admin, the Create site key and Create schema buttons are missing or disabled. Ask an admin of your codops, or the PEACH team.
Before you start
You need your codops service, https://<codops>.peach.ebu.io (see
The codops service), and peach-cli, installed and
signed in:
peach auth login opens a browser for your EBU GitLab sign-in. The CLI finds
your codops from your GitLab groups; if you belong to more than one, pick it
once with peach codops <codops>. See Command line (peach-cli)
for details.
How the pieces fit
your app --(site key)--> Peach collector --> raw topic <key>_events
peach events produce ----------------------------^ |
v
bridge: does the event type have a schema?
| yes | no
v v
StarRocks table <event_type> stays in the raw topic,
in peach_events_<codops> "Waiting for a schema"
The important part for this guide: an event type with no schema is not lost.
Its events stay in the site key's raw topic for as long as the key keeps raw
events. They are not loaded into StarRocks. The Failures page counts them as
schema_not_registered and keeps a first sample of them (up to about 50), but
the events themselves wait in the raw topic. The type shows up on the Schemas page under Waiting for a schema,
and once you save a schema the held events are backfilled into the new table.
Step 1: create a site key
A site key tells the platform which app sent an event and which codops it belongs to. Use one key per app and per stage (for example the Android app's beta channel, or a staging website), so you can tell their data apart later.
- Open your codops service and go to Data › Site keys.
-
Click Create site key and fill in the dialog:
Field What to enter Name For people: what sends events with this key, e.g. Web player, staging Environment Live, or Dev / test for staging, local builds and test devices Keep raw events How long raw events stay available for backfills and replays: 30 days, 1 year or 3 years Collect heartbeats Playback progress pings every few seconds. High volume; turn on only if you use playback analytics -
Click Create site key.
The key itself is generated for you. It appears in the list straight away; expand its row and use Copy to get it. The change is saved in the platform configuration with your name on it. Within a few minutes the collector accepts the key and its events load into StarRocks. Archiving its raw events to your member bucket (S3) starts once the PEACH team has rolled the key out to the archive; they are notified automatically, and nothing is lost in the meantime.
Environment is a label, not a separate pipeline
Every key of your codops loads into the same StarRocks database,
peach_events_<codops>, whatever its environment; nothing goes to a
separate -dev database. Dev / test is shown on the Site keys and
Schemas pages only; it is not a column in your tables. To keep test traffic
out of an analysis, filter on the site_key column, which every event
table has:
Moving a key to another codops, or deleting its data, always goes through the PEACH team.
Step 2: send test events with peach-cli
peach events produce sends events into the pipeline exactly as if the
collector had received them from your app. It is the quickest way to check a
new key and a new event type before the app itself is ready.
Since media_buffering has no schema yet, the command needs --unregistered:
# Check first: nothing is sent with --dry-run
peach events produce media_buffering --site-key <your-key> --unregistered --dry-run \
--data '{"id": "urn:media:1234", "context": {"page_uri": "example.org/live/tv1", "component": {"type": "player", "name": "web-player", "version": "4.2.0"}}, "props": {"playback_position_s": 0.0, "stream_type": "live", "buffer_duration_ms": 2300, "bitrate_kbps": 4500, "cdn": "cdn-a"}}'
A realistic test sends a mix: live and on demand, short and long stalls, two CDNs. Put one event per line in a file:
{"id": "urn:media:1234", "context": {"page_uri": "example.org/live/tv1", "component": {"type": "player", "name": "web-player", "version": "4.2.0"}}, "props": {"playback_position_s": 0.0, "stream_type": "live", "buffer_duration_ms": 2300, "bitrate_kbps": 4500, "cdn": "cdn-a"}}
{"id": "urn:media:1234", "context": {"page_uri": "example.org/live/tv1", "component": {"type": "player", "name": "web-player", "version": "4.2.0"}}, "props": {"playback_position_s": 0.0, "stream_type": "live", "buffer_duration_ms": 850, "bitrate_kbps": 2800, "cdn": "cdn-b"}}
{"id": "urn:media:5678", "context": {"page_uri": "example.org/live/tv1", "component": {"type": "player", "name": "web-player", "version": "4.2.0"}}, "props": {"playback_position_s": 312.4, "stream_type": "vod", "buffer_duration_ms": 4100, "bitrate_kbps": 1200, "cdn": "cdn-a"}}
{"id": "urn:media:5678", "context": {"page_uri": "example.org/live/tv1", "component": {"type": "player", "name": "web-player", "version": "4.2.0"}}, "props": {"playback_position_s": 1290.0, "stream_type": "vod", "buffer_duration_ms": 600, "bitrate_kbps": 6000, "cdn": "cdn-b"}}
and send it, with the device shared by every event:
peach events produce media_buffering --site-key <your-key> --unregistered -f buffering.jsonl \
--common '{"client": {"device": {"type": "desktop"}}}'
Each event is what your app would put in the events[] list of a collector
request (see General guidelines): id is the media,
context where the player is and props the playback state, as in the standard media events. The type is set
for you.
Useful options:
| Option | What it does |
|---|---|
--dry-run |
Check the events, send nothing |
--count N |
Send one --data event N times (up to 1000) |
-f FILE |
Read events from a file (- for stdin; then add --yes) |
--common '{...}' |
Envelope fields shared by every event, for example a client or device object (not the event's own context) |
--client-id ID |
Set client.id on events that have none |
--yes |
Skip the confirmation prompt |
Fields the collector always sets are filled in for you where you leave them
out: timestamps, peach_schema_version, client.type and client.id (a new
peach-produce-<uuid> per call, printed after sending). Every produced event is
marked with peach_framework_version = peach-events-produce, so you can filter
test events out of your analyses later.
For an unregistered type the CLI ends with:
That is expected. The type appears under Waiting for a schema within about ten minutes; any number of events is enough. Move on to step 3.
Step 3: register a schema
The schema decides which fields of the event become columns in your StarRocks table, and which are required.
- On your codops service, go to Data › Schemas.
- Find
media_bufferingunder Waiting for a schema. It shows how many events arrived in the last 7 days and which site keys sent them; types sent only from the CLI say Sent with peach events produce. - Click Create schema.
The form starts from suggested fields: fields found in a sample of recent raw events (every 20th event over 7 days), with how often each appears, a suggested type and an example value. Treat it as a starting point:
- Untick fields you do not want stored. Fields seen in only a handful of events (usually test data or typos) start unticked.
- Change types where the guess is wrong. When apps disagree (a number in
one, text in another) the suggestion is text. For
media_buffering,buffer_duration_msandbitrate_kbpsshould be long,playback_position_sdouble,stream_typeandcdnstring. - Add fields your apps do not send yet, so the column is ready when the new app version ships. Use a dot for a field inside a group, as the suggested fields do.
- Paste an Avro schema if you already have one.
- Mark a field Required only if every app always sends it. An event without a required field is rejected into the error queue (see Failures) instead of loaded.
No suggestions for a small test batch
Sampling every 20th event means a handful of events sent from the CLI may give few or no suggested fields. Add the fields yourself with + Add field, or paste the Avro schema.
Field names may contain letters, digits and _ only; other characters are
renamed (share-channel becomes share_channel), with a note on the form.
Fields that identify a person
If you store a field that identifies someone (an email, an account id),
tick Identifies a person. It is added to your erasure keys, so GDPR
deletion requests also remove the rows that hold it. client.id is always
stored and always an erasure key. Leave personal data out unless you really
need it.
When the form looks right:
- Leave Backfill the held events from raw storage ticked, so the events you sent in step 2 load into the new table too.
- Click Save schema and start loading.
What happens after Save
The Applying screen shows each step as it completes. You can leave the page; progress also shows on the Schemas page.
- The schema is saved as version 1 in the platform configuration, with your name and the time.
- It is registered in the Schema Registry. The bridge starts converting new events within about a minute.
- The StarRocks table
<event_type>is created with the ticked fields. The StarRocks setup runs every 15 minutes, so this step can take that long. - The held events are backfilled once the bridge converts events with the new schema.
Each step retries on its own. If one stays failed, tell the PEACH team; nothing already loaded is affected.
Check the result
Once the table exists, look at your test stalls. Fields inside the event become
columns named after their path, so props.buffer_duration_ms is
event_props_buffer_duration_ms:
peach events query "SELECT event_props_stream_type, event_props_cdn, COUNT(*) AS stalls, AVG(event_props_buffer_duration_ms) AS avg_ms FROM media_buffering WHERE _partition_ts >= NOW() - INTERVAL 1 HOUR GROUP BY 1, 2"
peach events schema media_buffering prints the registered schema, and
peach events tables lists your tables. Events for a type that has a schema
reach StarRocks within a few minutes of being sent, and the CLI prints the
query to check them.
From now on, peach events produce media_buffering no longer needs (and
refuses) --unregistered. Each event is checked against the schema before
anything is sent: a missing required field, or a value that cannot be converted
to the field's type, is an error and nothing is sent. Fields the schema does not
have are reported as warnings; those fields are skipped when loading but stay
in raw storage.
Changing the schema later
When your apps start sending fields the schema lacks (say the player adds
props.dropped_frames), the Schemas page shows a new count on that event
type once the field has been seen in about 1,000 events. Click it to add the
fields: new fields are always optional, so apps that do not send them keep
working. StarRocks adds the columns at its next setup run (every 15 minutes);
past rows stay empty in the new columns.
Changing a field's type, making an existing field required, or removing a field would break older events or apps. These go through the PEACH team. To rename a field, create a new event type instead.
Where to go next
- General guidelines: the event format your apps send.
- Web Data collection: sending events from a website with the Peach collector.
- Querying event data: reading your event tables.
- The codops service: the other pages under Data.