Allow parentheses '()' in dimensions

Update tempest tests to allow parentheses in dimensions.
Update documentation.

Change-Id: Idceed9a6cf2deff2c60bc865dc6a8fb2d0640412
Story: 2001385
Task: 5960
This commit is contained in:
Witold Bedyk 2017-12-05 15:24:51 +01:00
parent ec5a0f2607
commit 594b94c7d6
3 changed files with 11 additions and 5 deletions

View File

@ -386,7 +386,12 @@ A metric is uniquely identified by a name and set of dimensions.
Defines the name of a metric. A name is of type string(255). The name may include any characters except the following: `> < = { } ( ) , ' " \ ; &`. Note that JSON does allow control characters (such as `\n`), however these should not be used in metric names.
### Dimensions
A dictionary of (key, value) pairs. The key and value are of type string(255). Dimension keys may not begin with '_' (underscore). The dimension key and value strings may include any characters except the following: `> < = { } ( ) , ' " \ ; &`. Note that JSON does allow control characters (such as `\n`), however these should not be used in dimension keys or values. Dimension keys and values must not be empty.
A dictionary of (key, value) pairs. The key and value are of type string(255).
Dimension keys may not begin with '_' (underscore). The dimension key and value
strings may include any characters except the following:
`> < = { } , ' " \ ; &`. Note that JSON does allow control characters (such as
`\n`), however these should not be used in dimension keys or values. Dimension
keys and values must not be empty.
### Text Representation
In this document, metrics will be represented in the form `name{name=value,name=value}` where name is the metric name and the name=value pairs in the curly braces are the dimensions. For example, `cpu.idle_perc{service=monitoring,hostname=mini-mon}` represents a metric with the name "cpu.idle_perc" and the dimensions "service=monitoring" and "hostname=mini-mon".

View File

@ -21,7 +21,8 @@ ALARM_DEFINITION_CREATION_WAIT = 1
MAX_METRIC_NAME_LENGTH = 255
MAX_DIMENSION_KEY_LENGTH = 255
MAX_DIMENSION_VALUE_LENGTH = 255
INVALID_CHARS = "<>={}(),\"\;&"
INVALID_DIMENSION_CHARS = "<>={},\"\;&"
INVALID_NAME_CHARS = INVALID_DIMENSION_CHARS + "()"
MAX_ALARM_DEFINITION_NAME_LENGTH = 255
MAX_ALARM_DEFINITION_DESCRIPTION_LENGTH = 255

View File

@ -318,7 +318,7 @@ class TestMetrics(base.BaseMonascaTest):
@decorators.attr(type='gate')
@decorators.attr(type=['negative'])
def test_create_metric_with_invalid_chars_in_name(self):
for invalid_char in constants.INVALID_CHARS:
for invalid_char in constants.INVALID_NAME_CHARS:
metric = helpers.create_metric(invalid_char)
self.assertRaises(exceptions.UnprocessableEntity,
self.monasca_client.create_metrics,
@ -327,12 +327,12 @@ class TestMetrics(base.BaseMonascaTest):
@decorators.attr(type='gate')
@decorators.attr(type=['negative'])
def test_create_metric_with_invalid_chars_in_dimensions(self):
for invalid_char in constants.INVALID_CHARS:
for invalid_char in constants.INVALID_DIMENSION_CHARS:
metric = helpers.create_metric('name-1', {'key-1': invalid_char})
self.assertRaises(exceptions.UnprocessableEntity,
self.monasca_client.create_metrics,
metric)
for invalid_char in constants.INVALID_CHARS:
for invalid_char in constants.INVALID_DIMENSION_CHARS:
metric = helpers.create_metric('name-1', {invalid_char: 'value-1'})
self.assertRaises(exceptions.UnprocessableEntity,
self.monasca_client.create_metrics,