Add url subpath for Logsender to reach OpenSearch
It might happen, that the url for the OpenSearch is not directly the hostname, eg.: localhost, but it also contains a subPath for example: localhost/opensearch. In that case, the Logsender was not able to connect to the OpenSearch. Change-Id: I58a89c2fc33bdd06466bb60cc90fe2bd0317c92b
This commit is contained in:
parent
d47815c04c
commit
6e3e1bf6f0
@ -2,6 +2,7 @@
|
|||||||
directory: /tmp/logscraper
|
directory: /tmp/logscraper
|
||||||
host: localhost
|
host: localhost
|
||||||
port: 9200
|
port: 9200
|
||||||
|
subpath:
|
||||||
username: logstash
|
username: logstash
|
||||||
password:
|
password:
|
||||||
index_prefix: logstash-
|
index_prefix: logstash-
|
||||||
|
@ -63,6 +63,11 @@ def get_arguments():
|
|||||||
"be stored.")
|
"be stored.")
|
||||||
parser.add_argument("--host", help="Opensearch host")
|
parser.add_argument("--host", help="Opensearch host")
|
||||||
parser.add_argument("--port", help="Opensearch port", type=int)
|
parser.add_argument("--port", help="Opensearch port", type=int)
|
||||||
|
parser.add_argument("--subpath", help="Add the subpath to the host. "
|
||||||
|
"That is useful, when the host url contains "
|
||||||
|
"a slash(/). For example: "
|
||||||
|
"'http://localhost/opensearch' then the subpath "
|
||||||
|
"is 'opensearch'.")
|
||||||
parser.add_argument("--username", help="Opensearch username")
|
parser.add_argument("--username", help="Opensearch username")
|
||||||
parser.add_argument("--password", help="Opensearch user password")
|
parser.add_argument("--password", help="Opensearch user password")
|
||||||
parser.add_argument("--index-prefix", help="Prefix for the index.",
|
parser.add_argument("--index-prefix", help="Prefix for the index.",
|
||||||
@ -660,6 +665,9 @@ def get_es_client(args):
|
|||||||
if args.ca_file:
|
if args.ca_file:
|
||||||
es_creds['ca_certs'] = args.ca_file
|
es_creds['ca_certs'] = args.ca_file
|
||||||
|
|
||||||
|
if args.subpath:
|
||||||
|
es_creds['url_prefix'] = args.subpath
|
||||||
|
|
||||||
es_client = OpenSearch([es_creds], timeout=60)
|
es_client = OpenSearch([es_creds], timeout=60)
|
||||||
logging.info("Connected to Opensearch: %s" % es_client.info())
|
logging.info("Connected to Opensearch: %s" % es_client.info())
|
||||||
return es_client
|
return es_client
|
||||||
|
@ -87,6 +87,11 @@ def get_arguments():
|
|||||||
args_parser.add_argument('--port',
|
args_parser.add_argument('--port',
|
||||||
help='Opensearch port. Need to ensure that '
|
help='Opensearch port. Need to ensure that '
|
||||||
'index pattern exists before restore')
|
'index pattern exists before restore')
|
||||||
|
args_parser.add_argument("--subpath", help="Add the subpath to the host. "
|
||||||
|
"That is useful, when the host url contains "
|
||||||
|
"a slash(/). For example: "
|
||||||
|
"'http://localhost/opensearch' then the subpath "
|
||||||
|
"is 'opensearch'.")
|
||||||
args_parser.add_argument('--ca-file',
|
args_parser.add_argument('--ca-file',
|
||||||
help='Custom CA certificate file')
|
help='Custom CA certificate file')
|
||||||
args_parser.add_argument("--debug", help="Print more information",
|
args_parser.add_argument("--debug", help="Print more information",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user