## Overview

The Coralogix DataPrime Query Assistance makes data querying easier. Describe what you're looking for in everyday language. The system will analyze your request and convert your description into a structured DataPrime query, saving you the trouble of writing complex queries.

### Natural language to structured queries

The DataPrime Query Assistance uses an advanced large-language model (LLM) to help you. You can enter your request in plain English, which is converted into a precise DataPrime query.

**Disclaimer**: LLM-based systems are still evolving, and the DataPrime Query Assistance can make mistakes. That’s why, we recommend validating any DataPrime query before running it.

### Flexible query modification

After you generate the query, you can review your prompt and adjust the generated DataPrime query to make the data exploration process more flexible.

### Smart input evaluation

The DataPrime Query Assistance minimizes the risk of DataPrime query errors. It detects and corrects spelling mistakes in the user prompt and prevents syntax or spelling errors in the DataPrime editor, ensuring more accurate and efficient data retrieval. In addition, the DataPrime Query Assistance validates user entries, which must be within DataPrime scope. Invalid input is automatically rejected.

## Limitations

- Currently, the DataPrime Query Assistance is available for querying logs only.
- The DataPrime Query Assistance supports single-turn interaction only. This means that a session consists of one user prompt and one Query Assistance answer.
- Maximum number of characters in a user prompt is 700.

## Query examples

This section provides examples of some common queries, including typical user prompts and corresponding DataPrime queries.

- **Simple field-based filter**

  - User prompt: *Show me all logs with application name default*
  - DataPrime query:

```dataprime
source logs
| filter $l.applicationname == 'default'
```

- **Multiple filters**

  - User prompt: *Show me all logs with severity error or higher where the subsystem name is archive*
  - DataPrime query:

```dataprime
source logs
| filter $m.severity >= ERROR 
| filter $l.subsystemname == 'archive'
```

- **Aggregation**

  - User prompt: *Count all errors by application name*
  - DataPrime query:

```dataprime
source logs 
| filter $m.severity == ERROR 
| groupby $l.applicationname aggregate count() as error_count
```

- **Aggregation and filtering**

  - User prompt: *Show me all logs where the cloud provider is aws and group it by subsystem*
  - DataPrime query:

```dataprime
source logs 
| filter $d.resource.attributes['cloud.provider'] == 'aws' 
| groupby $l.subsystemname
```

- **Advanced calculation**

  - User prompt: *Find the average grpc.timems where grpc code is not ok*
  - DataPrime query:

```dataprime
source logs 
| filter $d.grpc.code != 'ok' 
| groupby true aggregate avg($d.grpc.timems) as average_grpc_times
```

Note

Due to the DataPrime limitations, aggregate functions, such as *`sum`*, *`avg`*, *`count`*, etc., require a computation anchor to operate. As a result, the *`groupby true aggregate`* expression is used as a boolean value, serving as an anchor for the aggregate function.

## Prerequisites

1. Navigate to **Settings > Account Preferences** and verify that the Cora has been enabled. For details, see [Getting Started](https://coralogix.com/docs/user-guides/cora/getting-started/index.md).

## Enabling the DataPrime Query Assistance

1. Verify that the user has the `team-ai-settings:Manage` permission.
1. Navigate to **Settings > Account Preferences**.
1. In the **CORA - Coralogix Observation and Research Assistant** section, toggle the DataPrime Query Assistance switch to **ON**.

## Using the DataPrime Query Assistance

1. On the Logs Explore screen, select **DataPrime** as your query language.
1. Click on **Query Assistant** to enable it.
1. Enter your prompt in plain English. Click the **Generate DataPrime Query** button, or press **Enter**.
1. Review your prompt (the text in purple) and the resulting DataPrime query. If needed, you can modify the query in the DataPrime editor. Then, click the **Run** button to execute the query.

## Give us your feedback

The more you use our DataPrime Query Assistance, the better it becomes. While interacting with it, give its response a thumbs up or a thumbs down. If you think something needs correction or improvement, do let us know. Click the **Thumbs Up** or **Thumbs Down** button to make yourself heard.

- If you like the generated query, give us a positive response (**Thumbs Up**) to show us that we’re on the right track.
- If you choose to give a negative response (**Thumbs Down**), fill out the feedback form, specifying what you didn’t like, and send us your reply. You can make multiple selections and/or forward your suggestions as a free text.

## Frequently asked questions

This section includes a series of questions commonly asked by customers. The questions cover such topics as the DataPrime Query Assistance usage, compliance, data processing, privacy, etc.

Which data is sent to OpenAI and Kapa AI?

With every user prompt, the DataPrime Query Assistance sends customer fields with value examples in a prompt during query generation.

How is hallucination risk managed and mitigated within the DataPrime Query Assistance?

We use a DataPrime validator to verify the validity of each DataPrime query. Any invalid DataPrime query is rejected.

Has the DataPrime Query Assistance been audited or assessed for bias, toxicity, political polarity, insult, threat, profanity or possible errors?

We use an internal mechanism to validate and monitor these issues and do not allow them to pass. We only return valid DataPrime queries, and any other subject is rejected.

## Additional resources

DataPrime Query Assistance in Cora AI

## Support

**Need help?**

Our world-class customer success team is available 24/7 to walk you through your setup and answer any questions that may come up.

Feel free to reach out to us **via our in-app chat** or by sending us an email to [support@coralogix.com](mailto:support@coralogix.com).
