Search

AI Query Generator

Describe what you are looking for in plain language, and LogPulse writes the LPQL query for you. You see the query, so you can check it, change it and learn the syntax along the way.

Overview

The query generator is part of the workspace. It turns a question into one LPQL query and runs it in Search. For questions that need more than one query, such as a root cause, the AI Investigator takes over and runs as many searches as it needs.

Ask in the workspace

Type in Ask anything about your logs… and press Enter. Pick the Search mode next to the input when you want a query and its results, rather than an answer in the conversation.

LPQL or a question

The input recognises LPQL. Type index=web status>=500 | stats count by host and it runs as a search straight away, without AI. Type which hosts return the most 5xx errors? and the AI writes that query for you. You can also switch the input to the LPQL editor and back with Ask in natural language.

Refine a search

Below a search you can ask a follow-up, such as only the last hour or split it by host. The AI changes the current query instead of starting over. You can always edit the LPQL in the editor yourself and press Run.

What the AI knows

Before it writes a query, LogPulse gives the AI a picture of your own data, so it uses your real names instead of guessing:

ContextWhat it is
Indexes, sourcetypes, sources and hostsUp to 50 of each, seen in the last 7 days
FieldsField names from a sample of up to 500 recent events, including attributes and parsed fields
LPQLThe commands and functions LPQL supports
The current queryWhen you refine a search, the query you are looking at
The conversationEarlier questions and answers in the same conversation

The query then runs as you, so the results only hold the indexes and namespace your role may see.

Checks on the query

A generated query is checked before you get it. It must be valid LPQL and may not use internal fields. If a check fails, the AI gets the error and tries again, up to three times.

Examples

You askYou might get
errors from the order service in the last 30 minutessource=order-service level=error earliest=-30m
average response time per endpoint todayindex=web earliest=@d | stats avg(duration_ms) as avg_ms by endpoint | sort -avg_ms
errors per source this week, per hourlevel=error earliest=-7d | timechart span=1h count by source
failed logins per user, more than 10action=failure earliest=-24h | stats count by user | where count > 10

The exact query depends on your data: the AI uses the index, source and field names it finds in your organization.

Tips

TipWhy
Name the index or source if you know itA narrow search is faster and more precise
Say the time spanlast hour, yesterday or since 14:00 becomes earliest and latest
Say what you want to seecount, per host or over time gives stats or timechart instead of raw logs
Check the queryThe query is the truth, not the question. Read it before you build an alert on it
Tip: Turn a query you use often into a saved search, an alert or a dashboard panel. See LPQL syntax for everything a query can do.

Access and data

The query generator is on every plan, Free included. Questions in the workspace use AI credits, like the AI Investigator. AI runs on Claude via Amazon Bedrock in the EU region Stockholm; Amazon is a US provider. Owners can switch AI off for the whole organization.

API

CallWhat it does
POST /api/v1/ai/generate-queryWrite an LPQL query: prompt (3 to 500 characters), optional currentQuery and conversationHistory (up to 20 messages). Returns query and explanation

It needs logs:read and allows 10 calls per minute. The call writes the query but does not run it.

Example
curl -X POST https://api.logpulse.io/api/v1/ai/generate-query \
  -H "Authorization: Bearer $LOGPULSE_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "errors per host in the last hour"}'