Alerts

Generate SQL from alert query parameters

Generates a SQL query string based on alert query parameters including stream, aggregations, and conditions. This endpoint is useful for testing alert queries and understanding the SQL that will be executed.

post/api/v2/{org_id}/alerts/generate_sql

Request

Path parameters

org_idstring required

Organization name

Request body

stream_namestring required

Stream name to query

stream_type'logs' | 'metrics' | 'traces' | 'profiles' | 'service_graph' | 'enrichment_tables' | 'file_list' | 'metadata' | 'index' required

Example request

{
  "stream_name": "default"
}

Response

Success

sqlstring required

The generated SQL query string

Example response

{
  "sql": "SELECT * FROM \"my_stream\" WHERE field > 100"
}

Changes

No recorded changes to this operation across all 1 revision of this API.