Open
Description
It is great to support multiple elasticsearch nodes as you do. It would be nice to be able to specify the hostname, scheme, and port in a single string:
Thanks for writing this. I'm not sure why Elastic themselves have not.
from cmreslogging.handlers import CMRESHandler
handler = CMRESHandler(hosts=[
'https://elastic-1.internal.example.com',
'https://elastic-2.internal.example.com],
auth_type=CMRESHandler.AuthType.NO_AUTH,
es_index_name="my_python_index",
es_additional_fields={'App': 'MyAppName', 'Environment': 'Dev'})
log = logging.getLogger("PythonTest")
log.setLevel(logging.INFO)
log.addHandler(handler)
Our elastic is also behind a load balancer, so that fault-tolerance doesn't require an array, it would be nice to specify the hosts as a simple string in the case that there is one of them:
from cmreslogging.handlers import CMRESHandler
handler = CMRESHandler(hosts='https://elastic.internal.example.com',
auth_type=CMRESHandler.AuthType.NO_AUTH,
es_index_name="my_python_index",
es_additional_fields={'App': 'MyAppName', 'Environment': 'Dev'})
log = logging.getLogger("PythonTest")
log.setLevel(logging.INFO)
log.addHandler(handler)
It would be nice to be able to specify the authentication as an object rather than a pair (now moving to dictionary based configuration:
LOGGING = {
...
'handlers': {
"elastic": {
'formatter': 'full',
'level': 'DEBUG',
'class': 'cmreslogging.handlers.CMRESHandler',
'hosts': 'https://elastic.internal.example.com',
'auth': CMRESHandler.auth.BasicAuth('username', 'password'),
'flush_frequency_in_sec': 1,
'es_index_name': 'mplusadmin-pylogs',
'es_additional_fields': {
'app': 'nlmcatutils',
},
},
...
},
}
This combination of simplification reduces the dictionary configuration complexity by 3 full keys:
use_ssl
= not needed because it is implied by schemeverify_ssl
= not needed because it is implied by scheme, still available to turn offauth_type
andauth_details
combined intoauth
Also, the specification of hosts
is a little simpler.
Metadata
Metadata
Assignees
Labels
No labels