Skip to content

Instantly share code, notes, and snippets.

@horacioibrahim
Last active November 19, 2024 09:26
Show Gist options
  • Save horacioibrahim/911681feb00ead2dad03b5cd6ccec994 to your computer and use it in GitHub Desktop.
Save horacioibrahim/911681feb00ead2dad03b5cd6ccec994 to your computer and use it in GitHub Desktop.
Consulta SQL no ELASTIC
POST /_sql?format=txt
{
"query": """
SELECT payload_parsed.externalId, COUNT(*) as ocurrences FROM "TABLE" // "TABLE*"
WHERE payload_parsed.type.keyword = 'MESSAGE_STATUS'
AND event_data.source.keyword = 'ZENVIA'
AND payload_parsed.channel.keyword = 'email'
AND payload_parsed.messageStatus.code.keyword = 'SENT'
AND inserted_date >= NOW() - INTERVAL 48 HOUR
GROUP BY payload_parsed.externalId HAVING COUNT(*) > 2
"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment