ElasticSearch wrapper

class DIRAC.Resources.LogBackends.ElasticSearchBackend.ElasticSearchBackend

Bases: DIRAC.Resources.LogBackends.AbstractBackend.AbstractBackend

ElasticsearchBackend is used to create an abstraction of the handler and the formatter concepts from logging. Here, we have a CMRESHandler which is part of an external library named ‘cmreslogging’ based on ‘logging’. CMRESHandler is a specific handler created to send log records to an ElasticSearch DB. It does not need a Formatter object.


CMRESHandler needs, at least, a hostname, a username, a password, a port and a specific index from the ElasticSearch DB to send log records.

static createFormat(options)

Create a format from the options given in parameters.

Params options:dictionary of options of the Logging which wants a new format
Params level:integer representing the level of the Logging object which wants a new format
Returns:tuple containing two strings: a format and a date format

Each backend can initialize its attributes and create its handler with them.

Params parameters:
 dictionary of parameters. ex: {‘FileName’: file.log}
Returns:the handler
setFormat(fmt, datefmt, options)

Each backend give a format to their formatters and attach them to their handlers.

Params fmt:string representing the log format
Params datefmt:string representing the date format
Params component:
 string represented as “system/component”
Params options:dictionary of logging options. ex: {‘Color’: True}

No possibility to set the level of the ElasticSearch handler. It is not set by default so it can send all Log Records of all levels to ElasticSearch.