Allow Keystone config in init_config for http check
Now the user will be able to configure one, default Keystone for all services in `http_check.yml` instead of providing them one by one for every instance. Setting Keystone config in every instance is marked as depreciated. Story: 2001843 Task: 12610 Change-Id: If52b52efab6cc14a7df583b1dc2596b04e6813bc
This commit is contained in:
parent
bd42ecb1c3
commit
e13de8083e
|
@ -1,6 +1,16 @@
|
||||||
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
|
||||||
|
|
||||||
init_config:
|
init_config:
|
||||||
|
# If your service uses keystone for authentication, you can optionally
|
||||||
|
# specify the information to collect a token to be used in the check.
|
||||||
|
# This information should follow the same guidelines presented in
|
||||||
|
# agent.yaml.template
|
||||||
|
# https://github.com/openstack/monasca-agent/blob/master/agent.yaml.template
|
||||||
|
# keystone_config:
|
||||||
|
# keystone_url: http://endpoint.com/v3/
|
||||||
|
# project_name: project
|
||||||
|
# username: user
|
||||||
|
# password: password
|
||||||
|
|
||||||
instances:
|
instances:
|
||||||
# - name: Some Service Name
|
# - name: Some Service Name
|
||||||
|
@ -12,19 +22,10 @@ instances:
|
||||||
# username: user
|
# username: user
|
||||||
# password: pass
|
# password: pass
|
||||||
|
|
||||||
# If your service uses keystone for authentication, you can optionally
|
# If use_keystone=True then Keystone information from `init_config`
|
||||||
# specify the information to collect a token to be used in the check.
|
# will be used, and if it's not there then Keystone configuration
|
||||||
# This information should follow the same guidelines presented in
|
|
||||||
# agent.yaml.template
|
|
||||||
# https://github.com/openstack/monasca-agent/blob/master/agent.yaml.template
|
|
||||||
# If use_keystone=True and keystone_config is not specified, the keystone information
|
|
||||||
# from the agent config will be used.
|
# from the agent config will be used.
|
||||||
# use_keystone: True
|
# use_keystone: True
|
||||||
# keystone_config:
|
|
||||||
# keystone_url: http://endpoint.com/v3/
|
|
||||||
# project_name: project
|
|
||||||
# username: user
|
|
||||||
# password: password
|
|
||||||
|
|
||||||
# The (optional) match_pattern parameter will instruct the check
|
# The (optional) match_pattern parameter will instruct the check
|
||||||
# to match the HTTP response body against a regular-expression-
|
# to match the HTTP response body against a regular-expression-
|
||||||
|
|
|
@ -1330,20 +1330,38 @@ This section describes the http endpoint check that can be performed by the Agen
|
||||||
|
|
||||||
The Agent supports additional functionality through the use of Python scripts. A YAML file (http_check.yaml) contains the list of URLs to check (among other optional parameters). A Python script (http_check.py) runs checks each host in turn, returning a 0 on success and a 1 on failure in the result sent through the Forwarder and on the Monitoring API.
|
The Agent supports additional functionality through the use of Python scripts. A YAML file (http_check.yaml) contains the list of URLs to check (among other optional parameters). A Python script (http_check.py) runs checks each host in turn, returning a 0 on success and a 1 on failure in the result sent through the Forwarder and on the Monitoring API.
|
||||||
|
|
||||||
Similar to other checks, the configuration is done in YAML, and consists of two keys: init_config and instances. The former is not used by http_check, while the later contains one or more URLs to check, plus optional parameters like a timeout, username/password, pattern to match against the HTTP response body, whether or not to include the HTTP response in the metric (as a 'detail' dimension), whether or not to also record the response time, and more.
|
Similar to other checks, the configuration is done in YAML, and consists of two
|
||||||
If the endpoint being checked requires authentication, there are two options. First, a username and password supplied in the instance options will be used by the check for authentication. Alternately, the check can retrieve a keystone token for authentication. Specific keystone information can be provided for each check, otherwise the information from the agent config will be used.
|
keys: `init_config` and `instances`. In the former, you can provide Keystone
|
||||||
|
configuration for checks to retrieve token for authentication that will be used
|
||||||
|
for all checks. While the later contains one or more URLs to check, plus
|
||||||
|
optional parameters like a timeout, username/password, pattern to match against
|
||||||
|
the HTTP response body, whether or not to include the HTTP response
|
||||||
|
in the metric (as a 'detail' dimension), whether or not to also record
|
||||||
|
the response time, and more.
|
||||||
|
If the endpoint being checked requires authentication, there are two options.
|
||||||
|
First, a username and password supplied in the instance options will be used
|
||||||
|
by the check for authentication. Alternately, the check can retrieve
|
||||||
|
a keystone token for authentication. Specific keystone information can
|
||||||
|
be provided for all checks in `init_config` section, or if it's not
|
||||||
|
provided there, the information from the agent config will be used.
|
||||||
|
DEPRECATED: providing Keystone configuration in each instance.
|
||||||
|
|
||||||
Sample config:
|
Sample config:
|
||||||
|
|
||||||
```
|
```
|
||||||
init_config:
|
init_config:
|
||||||
|
keystone_config:
|
||||||
|
keystone_url: http://endpoint.com/v3/
|
||||||
|
project_name: project
|
||||||
|
username: user
|
||||||
|
password: password
|
||||||
|
|
||||||
instances:
|
instances:
|
||||||
url: http://192.168.0.254/healthcheck
|
url: http://192.168.0.254/healthcheck
|
||||||
timeout: 1
|
timeout: 1
|
||||||
include_content: true
|
include_content: true
|
||||||
collect_response_time: true
|
collect_response_time: true
|
||||||
match_pattern: '.*OK.*OK.*OK.*OK.*OK'
|
match_pattern: '.*OK.*OK.*OK.*OK.*OK'
|
||||||
```
|
```
|
||||||
|
|
||||||
The http_status checks return the following metrics:
|
The http_status checks return the following metrics:
|
||||||
|
|
|
@ -33,6 +33,9 @@ class HTTPCheck(services_checks.ServicesCheck):
|
||||||
# init the keystone client if instance has use_keystone
|
# init the keystone client if instance has use_keystone
|
||||||
self._api_config = cfg.Config().get_config('Api')
|
self._api_config = cfg.Config().get_config('Api')
|
||||||
self._ksclients = {}
|
self._ksclients = {}
|
||||||
|
|
||||||
|
init_keystone_config = init_config.get('keystone_config', None)
|
||||||
|
|
||||||
for instance in instances:
|
for instance in instances:
|
||||||
addr, username, password, timeout, headers, response_time, \
|
addr, username, password, timeout, headers, response_time, \
|
||||||
disable_ssl_validation, use_keystone, keystone_config, \
|
disable_ssl_validation, use_keystone, keystone_config, \
|
||||||
|
@ -40,7 +43,11 @@ class HTTPCheck(services_checks.ServicesCheck):
|
||||||
if use_keystone:
|
if use_keystone:
|
||||||
# keystone is a singleton. It will be initialized once,
|
# keystone is a singleton. It will be initialized once,
|
||||||
# the first config instance used.
|
# the first config instance used.
|
||||||
if keystone_config:
|
if init_keystone_config:
|
||||||
|
ksclient = keystone.Keystone(init_keystone_config)
|
||||||
|
elif keystone_config:
|
||||||
|
# Using Keystone config in each instance is deprecated
|
||||||
|
# in Rocky.
|
||||||
ksclient = keystone.Keystone(keystone_config)
|
ksclient = keystone.Keystone(keystone_config)
|
||||||
else:
|
else:
|
||||||
ksclient = keystone.Keystone(self._api_config)
|
ksclient = keystone.Keystone(self._api_config)
|
||||||
|
|
Loading…
Reference in New Issue