DonJuanEco
DonJuanEco

Reputation: 143

How to log all queries made to elasticsearch container?

I'm trying to debug my app. When I hit the production elasticsearch host through my python app, the results are returned. When I change it to localhost, it works when I hit it manually through the browser, but not through the app.

I'd like to log all queries that are hitting my elasticsearch container, I've tried env variables such as "DEBUG=TRUE" or "DEBUG=*", and no requests are being logged (even when hitting it manually and results are returned).

Any idea how I'd do this?

Thanks

Upvotes: 2

Views: 3357

Answers (1)

ibexit
ibexit

Reputation: 3667

You can use the slow queries log with a really reduced treshold. See https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-slowlog.html for more details on this feature. For example:

index.search.slowlog.threshold.query.debug: 0s

Using cluster or index settings api you're able to change this settings while running the cluster.

curl -XPUT "http://localhost:9200/_all/_settings" -H "content-type: application/json" -d'
{
    "index.search.slowlog.threshold.query.debug": "0s"
}'

There are even more settings you can use to log and monitor index, fetch or search duration.

Upvotes: 5

Related Questions