Skip to main content

Sources

A source is a named, typed collection of documents (think: a table with a schema, an API and charts). It is the single building block of Insights, and Customers entities show up as one too.

Every source, whatever its type, has the same anatomy.

Anatomy​

PartDescription
NameUnique per tenant and cannot be changed after creation. Letters, digits, umlauts, space, - and _. The SDK finds sources by name, so choose it deliberately
Source typeHow data gets in: store, push, rabbitmq, … See Source types
Fields and field typesThe schema. Each field has a type that decides how values are stored, filtered and charted
DocumentsThe records. Flat key/value objects
StateWhether the source is receiving data (see below)
Duplicate controlHow the id of a document is determined, so re-sent data updates instead of duplicating

Documents are flat​

A document is a flat object of field names and values. Only the field types list and geo-point may hold arrays or objects. Nested input from queues is flattened with _ (address.city becomes address_city). The names id and _id are reserved.

Field types​

The field type is the contract between the raw value you send and what you can do with it later.

TypeUse for
stringText, ids, categories
integer, floatNumbers you sum, average or compare
booleanFlags
date-isoISO 8601 dates and timestamps
date-formatDates in a custom text format
timestamp-seconds, timestamp-millis, timestamp-microsEpoch numbers
geo-pointLocations ("lat,lon", [lon, lat], { lat, lon }, GeoJSON, WKT)
listArrays of values

Fields can also be disabled, have a default value, and define how empty values are handled.

Raw and main data​

Every source keeps your data twice:

  • Raw: the values exactly as they arrived, all as text.
  • Main: the typed values that charts, filters and aggregations use.

This means you can change a field's type later. Scenid re-derives the main data from the raw data. Values that cannot be converted to a type do not block ingestion. They are counted and listed as warnings (grouped by field and error, with sample values) so you can fix the type or the data.

aggregate reads main data by default. Pass raw: true to read the raw data.

A third, internal record, the event log, tracks imports, errors and new fields. It powers the activity list and the throughput sparklines in the app.

State​

StateMeaning
ANALYZING / ANALYZEDData sample is being read / fields are ready for review
RUNNINGData is being ingested
SUCCESSFULIdle and up to date
REINDEXINGField settings changed, main data is being rebuilt
FAILED, STOPPED, STALENeeds attention

Streaming sources (push, RabbitMQ) go back to SUCCESSFUL after a period without data and to RUNNING again when data arrives.

Duplicate control​

Duplicate control decides the id of each document:

MethodDocument idEffect
HashFingerprint of the contentRe-sending identical data overwrites itself. Idempotent
FieldThe value of a field you choose (for example orderId)Re-sending a key updates that document (upsert)
AutomaticA random idEvery document is new, nothing is de-duplicated

Which methods a type offers, and its default, depends on the source type. Set it before the first data arrives: on a store source it locks once data has been ingested.

Enrichments​

Sources can be extended at write time with computed fields: join fields from another source (including customers), a scripted formula, or a geo lookup for IP addresses.

What every source gets​

  • aggregate via REST and the SDK.
  • Charts and dashboards in the Insights app.
  • CSV export (streamed).
  • Transform errors and throughput statistics.
  • Field-level configuration in the Insights app.
  • Use in a transform to build derived, aggregated sources.

Reading a source​

const { result } = await sdk.asAdmin().Insights().Source('Orders').aggregate({
size: 5,
fields: ['orderId', 'total']
})

See Query data.