Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save calexandrepcjr/f6b679456d2604c620f0d5180376aa9b to your computer and use it in GitHub Desktop.
Save calexandrepcjr/f6b679456d2604c620f0d5180376aa9b to your computer and use it in GitHub Desktop.
How to enable slowlogs for all indices and tweak slowlog logger level

Slowlog thresholds for all indices

Add slowlog thresholds for all indices

PUT /_all/_settings 
{
"index.search.slowlog.threshold.query.warn": "10s",
"index.search.slowlog.threshold.query.info": "5s",
"index.search.slowlog.threshold.query.debug": "2s",
"index.search.slowlog.threshold.query.trace": "500ms",

"index.search.slowlog.threshold.fetch.warn": "10s",
"index.search.slowlog.threshold.fetch.info": "5s",
"index.search.slowlog.threshold.fetch.debug": "2s",
"index.search.slowlog.threshold.fetch.trace": "500ms"
}

After investigation rollback to defaults

PUT /_all/_settings 
{
"index.search.slowlog.threshold.query.warn": null,
"index.search.slowlog.threshold.query.info": null,
"index.search.slowlog.threshold.query.debug": null,
"index.search.slowlog.threshold.query.trace": null,

"index.search.slowlog.threshold.fetch.warn": null,
"index.search.slowlog.threshold.fetch.info": null,
"index.search.slowlog.threshold.fetch.debug": null,
"index.search.slowlog.threshold.fetch.trace": null
}

Tweak slowlog logger level to suit your needs

#### Add slowlog logger in cluster settings (transient -> not conserved after reboot)

PUT _cluster/settings
{
  "transient" : {
    "logger.index.search.slowlog" : "DEBUG",
    "logger.index.indexing.slowlog" : "DEBUG"
  }
}

Rollback to defaults (from log4j logger.index_indexing_slowlog.level = trace)

PUT _cluster/settings
{
  "transient" : {
    "logger.index.search.slowlog" : null,
    "logger.index.indexing.slowlog" : null
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment