Avoid prometheus metrics explosion
Openstacksdk reports metrics for prometheus and adds an endpoint-label containing the full url of every request. In case the endpoints contain query strings this can easily cause metric explosion. To fix this we can parse the url and strip the query string. Change-Id: Ief3c3981a039b3ae38eeaeccd1fb70e974c94082
This commit is contained in:
parent
88f6a31d73
commit
3f2034832b
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
import urllib
|
||||
from urllib.parse import urlparse
|
||||
|
||||
try:
|
||||
import simplejson
|
||||
@ -226,10 +227,13 @@ class Proxy(adapter.Adapter):
|
||||
url = response.request.url
|
||||
if response is not None and not method:
|
||||
method = response.request.method
|
||||
parsed_url = urlparse(url)
|
||||
endpoint = "{}://{}{}".format(
|
||||
parsed_url.scheme, parsed_url.netloc, parsed_url.path)
|
||||
if response is not None:
|
||||
labels = dict(
|
||||
method=method,
|
||||
endpoint=url,
|
||||
endpoint=endpoint,
|
||||
service_type=self.service_type,
|
||||
status_code=response.status_code,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user