Write your first DataPrime query in Coralogix

Build a DataPrime query to filter and count events, checking fields, time scope and interpretation limits.

Format
6 minEnglish
Updated 6 min

What you will create

Build a first DataPrime query to filter logs and count matching events. Learn to distinguish the source, time window and field being queried: three choices that can change the result without producing a syntax error.

Before you start

Use only a Coralogix workspace you are authorized to read, with test data already available. Do not upload production logs for this exercise. Check account limits and select a relevant short time window. Field names below are assumptions to adapt to the actual schema.

Step-by-step

  1. Define the question. For example: how many events contain the numeric HTTP status 500 within the selected period? This does not mean “how many distinct incidents”.
  2. Identify source and time. In DataPrime exploration, start with source logs. Check that the events you need exist in the selected period and dataset.
  3. Inspect an event. Identify the field's path and type. $d means event data, $m metadata and $l labels. A data field called severity is not automatically Coralogix's normalized severity.
  4. Filter before counting. Add a filter for the actual field and inspect a few matching events. Do not copy a path that does not exist in your data.
  5. Add the count. Once the filter is understood, append | count. Each step receives the previous step's output. Do not put a sampling limit before the count if you want the total number of matching events.
  6. Record scope. Keep the query, time window and assumptions with the result. A number without this context is difficult to explain or compare.

Example to adapt

Assume three fictional events in the same period with numeric http.status_code fields of 200, 500 and 500. Under this assumption, the following query should count two events:

source logs
| filter $d.http.status_code == 500
| count

This illustrative dataset was not ingested. If the field is a string, adapt the comparison to its type. For a different question about normalized severity, the documented syntax is:

source logs
| filter $m.severity == ERROR
| count

These queries are not equivalent: HTTP status and severity describe different properties.

Check your result

  • Inspected events really satisfy the filter.
  • The field type matches the compared value.
  • Source and time window are identical between compared runs.
  • Your report counts events without inventing a count of users or incidents.

Common problems

No results: check time, source, path, type and read permissions before concluding there were no errors. A different result elsewhere: compare filters and time windows. A surprisingly low count: look for a limit before counting or a severity field in the wrong namespace. An AI-suggested query: review it like any other query rather than assuming it is valid.

Next steps

See the Coralogix overview, then add one transformation at a time. This guide is based on documentation: no account connection, ingestion or query execution was performed.