'1', 'params' => '123', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '2', 'params' => 'abc', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '3', 'params' => 'def', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '4', 'params' => '1a2b3c', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '5', 'params' => "regular expression pattern \noutput template", 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '6', 'params' => '', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '7', 'params' => '', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '8', 'params' => '', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '9', 'params' => '', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '11', 'params' => '/document/item/value/text()', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '12', 'params' => '$.document.item.value parameter.', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '13', 'params' => "-5\n3", 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '14', 'params' => 'regular expression pattern for matching', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '15', 'params' => 'regular expression pattern for not matching', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '16', 'params' => '/json/path', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '17', 'params' => '/xml/path', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '18', 'params' => "regular expression pattern for error matching \ntest output", 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '20', 'params' => '7', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '21', 'params' => 'test script', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '23', 'params' => 'metric', 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '24', 'params' => ".\n/\n1", 'error_handler' => 0, 'error_handler_params' => '' ], [ 'type' => '25', 'params' => "1\n2", 'error_handler' => 0, 'error_handler_params' => '' ] ]; /** * Attach MessageBehavior to the test. * * @return array */ public function getBehaviors() { return ['class' => CMessageBehavior::class]; } /* * Preprocessing validation data for Item and Item prototype. */ public function getItemPreprocessingValidationData() { return array_merge($this->getCommonPreprocessingValidationData(), [ // Text. Trim. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Right trim', 'Key' => 'empty-right-trim[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Right trim'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Left trim', 'Key' => 'empty-left-trim[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Left trim'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Trim', 'Key' => 'empty-trim[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Trim'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // Arithmetic. Custom multiplier. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Empty multiplier', 'Key' => 'empty-multiplier[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Custom multiplier'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'String multiplier', 'Key' => 'string-multiplier[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Custom multiplier', 'parameter_1' => 'abc'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Multiplier comma', 'Key' => 'comma-multiplier[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Custom multiplier', 'parameter_1' => '0,0'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Multiplier symbols', 'Key' => 'symbols-multiplier[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Custom multiplier', 'parameter_1' => '1a!@#$%^&*()-='] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], // Change. Simple change, Change per second [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Two delta', 'Key' => 'two-delta[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Simple change'], ['type' => 'Simple change'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist within '. 'the combinations of (type)=((9, 10)).' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Two delta per second', 'Key' => 'two-delta-per-second[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Change per second'], ['type' => 'Change per second'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist within '. 'the combinations of (type)=((9, 10)).' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Two different delta', 'Key' => 'two-different-delta[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Simple change'], ['type' => 'Change per second'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist within '. 'the combinations of (type)=((9, 10)).' ] ], // Validation. In range. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'In range empty', 'Key' => 'in-range-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params": cannot be empty.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'In range letters string', 'Key' => 'in-range-letters-string[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range', 'parameter_1' => 'abc', 'parameter_2' => 'def'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'In range symbols', 'Key' => 'in-range-symbols[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range', 'parameter_1' => '1a!@#$%^&*()-=', 'parameter_2' => '2b!@#$%^&*()-='] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'In range comma', 'Key' => 'in-range-comma[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range', 'parameter_1' => '1,5', 'parameter_2' => '-3,5'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a floating point value is expected.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'In range wrong interval', 'Key' => 'in-range-wrong-interval[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range', 'parameter_1' => '8', 'parameter_2' => '-8'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/2": cannot be less than or equal '. 'to the value of parameter "/1/preprocessing/1/params/1".' ] ], // Validation. Matches regular expression. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Matches regular expression empty', 'Key' => 'matches-regular-expression-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Matches regular expression'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // Validation. Check for error in XML. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item error XML empty', 'Key' => 'item-error-xml-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for error in XML'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // Validation. Check for error using regular expression. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item error REGEXP both params empty', 'Key' => 'item-error-regexp-both-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for error using regular expression'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item error REGEXP first parameter empty', 'Key' => 'item-error-regexp-first-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for error using regular expression', 'parameter_2' => 'test'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item error REGEXP second parameter empty', 'Key' => 'item-error-regexp-second-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for error using regular expression', 'parameter_1' => 'test'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/2": cannot be empty.' ] ], // Throttling. Discard unchanged. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item two discard unchanged', 'Key' => 'item-two-discard-unchanged[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged'], ['type' => 'Discard unchanged'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist within '. 'the combinations of (type)=((19, 20)).' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item two different throttlings', 'Key' => 'item-two-different-throttlings[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged'], ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist within '. 'the combinations of (type)=((19, 20)).' ] ] ]); } /* * Preprocessing validation data for item, item prototype and LLD. */ public static function getCommonPreprocessingValidationData() { return [ // #0 Text. Regular expression. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Empty regular expression', 'Key' => 'Empty-both-parameters[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Regular expression'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #1 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Empty pattern of regular expression', 'Key' => 'empty-first-parameter[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Regular expression', 'parameter_2' => 'test output'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #2 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Empty output of regular expression', 'Key' => 'empty-second-parameter[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Regular expression', 'parameter_1' => 'expression'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/2": cannot be empty.' ] ], // #3 Structured data. XML XPath. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'XML XPath', 'Key' => 'empty-xpath[{#KEY}]' ], 'preprocessing' => [ ['type' => 'XML XPath'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #4 Structured data. JSONPath. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'JSONPath empty', 'Key' => 'empty-jsonpath[{#KEY}]' ], 'preprocessing' => [ ['type' => 'JSONPath'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #5 Custom scripts. JavaScript. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Empty JavaScript', 'Key' => 'item-empty-javascript[{#KEY}]' ], 'preprocessing' => [ ['type' => 'JavaScript'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #6 Validation. Does not match regular expression [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Does not match regular expression empty', 'Key' => 'does-not-match-regular-expression-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Does not match regular expression'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #7 Validation. Check for error in JSON. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Error JSON empty', 'Key' => 'error-json-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for error in JSON'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #8 Throttling. Discard unchanged with heartbeat [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Two equal discard unchanged with heartbeat', 'Key' => 'two-equal-discard-unchanged-with-heartbeat[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1'], ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist '. 'within the combinations of (type)=((19, 20)).' ] ], // #9 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Two different discard unchanged with heartbeat', 'Key' => 'two-different-discard-unchanged-with-heartbeat[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1'], ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '2'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist '. 'within the combinations of (type)=((19, 20)).' ] ], // #10 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat empty', 'Key' => 'discard-unchanged-with-heartbeat-empty[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": cannot be empty.' ] ], // #11 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat symbols', 'Key' => 'discard-unchanged-with-heartbeat-symbols[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '3g!@#$%^&*()-='] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a time unit is expected.' ] ], // #12 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discardunchanged with heartbeat letters string', 'Key' => 'discard-unchanged-with-heartbeat-letters-string[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => 'abc'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a time unit is expected.' ] ], // #13 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat comma', 'Key' => 'discard-unchanged-with-heartbeat-comma[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1,5'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a time unit is expected.' ] ], // #14 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat dot', 'Key' => 'discard-unchanged-with-heartbeat-dot[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '1.5'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": a time unit is expected.' ] ], // #15 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat negative', 'Key' => 'discard-unchanged-with-heartbeat-negative[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '-3'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": value must be one of 1-788400000.' ] ], // #16 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat zero', 'Key' => 'discard-unchanged-with-heartbeat-zero[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '0'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": value must be one of 1-788400000.' ] ], // #17 [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Discard unchanged with heartbeat maximum', 'Key' => 'unchanged-with-heartbeat-max[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '788400001'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": value must be one of 1-788400000.' ] ] ]; } /* * Preprocessing data for item and item prototype successful creation. */ public static function getItemPreprocessingCreateData() { return [ // Structured data. CSV to JSON. [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'CSV to JSON empty parameters', 'Key' => 'csv-to-json-empty-parameters[{#KEY}]' ], 'preprocessing' => [ ['type' => 'CSV to JSON'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'CSV to JSON with default parameters', 'Key' => 'csv-to-json-with-default-parameters[{#KEY}]' ], 'preprocessing' => [ ['type' => 'CSV to JSON', 'parameter_1' => ',', 'parameter_2' => '"', 'parameter_3' => true] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'CSV to JSON custom parameters', 'Key' => 'csv-to-json-custom-parameters[{#KEY}]' ], 'preprocessing' => [ ['type' => 'CSV to JSON', 'parameter_1' => ' ', 'parameter_2' => "'", 'parameter_3' => false] ] ] ], // In range. [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'In range negative float', 'Key' => 'in-range-negative-float[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range', 'parameter_1' => '-3.5', 'parameter_2' => '-1.5'] ] ] ], // Validation [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Not supported step', 'Key' => 'check-for-not-supported[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for not supported value'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'In range zero', 'Key' => 'in-range-zero[{#KEY}]' ], 'preprocessing' => [ ['type' => 'In range', 'parameter_1' => '0', 'parameter_2' => '1'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Add all preprocessing', 'Key' => 'item.all.preprocessing[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Check for not supported value'], ['type' => 'Replace', 'parameter_1' => 'text', 'parameter_2' => 'REPLACEMENT'], ['type' => 'Right trim', 'parameter_1' => 'abc'], ['type' => 'Left trim', 'parameter_1' => 'def'], ['type' => 'Trim', 'parameter_1' => '1a2b3c'], ['type' => 'CSV to JSON','parameter_1' => ' ', 'parameter_2' => '\\', 'parameter_3' => true], ['type' => 'XML to JSON'], ['type' => 'Custom multiplier', 'parameter_1' => '123'], ['type' => 'Regular expression', 'parameter_1' => 'expression', 'parameter_2' => 'test output'], ['type' => 'Boolean to decimal'], ['type' => 'Octal to decimal'], ['type' => 'Hexadecimal to decimal'], ['type' => 'JavaScript', 'parameter_1' => 'Test JavaScript'], ['type' => 'Simple change'], ['type' => 'In range', 'parameter_1' => '-5', 'parameter_2' => '9.5'], ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '5'], ['type' => 'Prometheus pattern', 'parameter_1' => 'cpu_usage_system', 'parameter_2' => 'label', 'parameter_3' => 'label_name'] ], 'screenshot' => true ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Add symbols preprocessing', 'Key' => 'item.symbols.preprocessing[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Replace', 'parameter_1' => '1a!@#$%^&*()-=', 'parameter_2' => '1a!@#$%^&*()-='], ['type' => 'Right trim', 'parameter_1' => '1a!@#$%^&*()-='], ['type' => 'Left trim', 'parameter_1' => '2b!@#$%^&*()-='], ['type' => 'Trim', 'parameter_1' => '3c!@#$%^&*()-='], ['type' => 'XML XPath', 'parameter_1' => '3c!@#$%^&*()-='], ['type' => 'JSONPath', 'parameter_1' => '3c!@#$%^&*()-='], ['type' => 'Custom multiplier', 'parameter_1' => '4.0E+14'], ['type' => 'Regular expression', 'parameter_1' => '5d!@#$%^&*()-=', 'parameter_2' => '6e!@#$%^&*()-='], ['type' => 'JavaScript', 'parameter_1' => '5d!@#$%^&*()-='], ['type' => 'Matches regular expression', 'parameter_1' => '7f!@#$%^&*()-='], ['type' => 'Does not match regular expression', 'parameter_1' => '8g!@#$%^&*()-='], ['type' => 'Check for error in JSON', 'parameter_1' => '9h!@#$%^&*()-='], ['type' => 'Check for error in XML', 'parameter_1' => '0i!@#$%^&*()-='], ['type' => 'Check for error using regular expression', 'parameter_1' => '1j!@#$%^&*()-=', 'parameter_2' => '2k!@#$%^&*()-='] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Add the same preprocessing', 'Key' => 'item.theSamePpreprocessing[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Replace', 'parameter_1' => 'текст', 'parameter_2' => 'замена'], ['type' => 'Replace', 'parameter_1' => 'текст', 'parameter_2' => 'замена'], ['type' => 'Change per second'], ['type' => 'Right trim', 'parameter_1' => 'abc'], ['type' => 'Right trim', 'parameter_1' => 'abc'], ['type' => 'Left trim', 'parameter_1' => 'def'], ['type' => 'Left trim', 'parameter_1' => 'def'], ['type' => 'Trim', 'parameter_1' => '1a2b3c'], ['type' => 'Trim', 'parameter_1' => '1a2b3c'], ['type' => 'CSV to JSON', 'parameter_1' => '.', 'parameter_2' => "'" ,'parameter_3' => false], ['type' => 'CSV to JSON', 'parameter_1' => '.', 'parameter_2' => "'" ,'parameter_3' => false], ['type' => 'XML to JSON'], ['type' => 'XML to JSON'], ['type' => 'XML XPath', 'parameter_1' => '1a2b3c'], ['type' => 'XML XPath', 'parameter_1' => '1a2b3c'], ['type' => 'JSONPath', 'parameter_1' => '1a2b3c'], ['type' => 'JSONPath', 'parameter_1' => '1a2b3c'], ['type' => 'Custom multiplier', 'parameter_1' => '123'], ['type' => 'Custom multiplier', 'parameter_1' => '123'], ['type' => 'Regular expression', 'parameter_1' => 'expression', 'parameter_2' => 'test output'], ['type' => 'Regular expression', 'parameter_1' => 'expression', 'parameter_2' => 'test output'], ['type' => 'Boolean to decimal'], ['type' => 'Boolean to decimal'], ['type' => 'Octal to decimal'], ['type' => 'Octal to decimal'], ['type' => 'Hexadecimal to decimal'], ['type' => 'Hexadecimal to decimal'], ['type' => 'In range', 'parameter_1' => '-5.5', 'parameter_2' => '10'], ['type' => 'In range', 'parameter_1' => '-5.5', 'parameter_2' => '10'], ['type' => 'JavaScript', 'parameter_1' => 'Test JavaScript'], ['type' => 'JavaScript', 'parameter_1' => 'Test JavaScript'], ['type' => 'Matches regular expression', 'parameter_1' => 'test_expression'], ['type' => 'Matches regular expression', 'parameter_1' => 'test_expression'], ['type' => 'Does not match regular expression', 'parameter_1' => 'not_expression'], ['type' => 'Does not match regular expression', 'parameter_1' => 'not_expression'], ['type' => 'Check for error in JSON', 'parameter_1' => '/path'], ['type' => 'Check for error in JSON', 'parameter_1' => '/path'], ['type' => 'Check for error in XML', 'parameter_1' => '/path/xml'], ['type' => 'Check for error in XML', 'parameter_1' => '/path/xml'], ['type' => 'Check for error using regular expression', 'parameter_1' => 'regexp', 'parameter_2' => '\1'], ['type' => 'Check for error using regular expression', 'parameter_1' => 'regexp', 'parameter_2' => '\1'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item with preprocessing rule with user macro', 'Key' => 'item-user-macro[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Replace', 'parameter_1' => '{$TEST1}', 'parameter_2' => '{$MACRO2}'], ['type' => 'Regular expression', 'parameter_1' => '{$DELIM}(.*)', 'parameter_2' => '\1'], ['type' => 'Trim', 'parameter_1' => '{$DELIM}'], ['type' => 'Right trim', 'parameter_1' => '{$MACRO}'], ['type' => 'Left trim', 'parameter_1' => '{$USER}'], ['type' => 'XML XPath', 'parameter_1' => 'number(/values/Item/value[../key=\'{$DELIM}\'])'], ['type' => 'JSONPath', 'parameter_1' => '$.data[\'{$KEY}\']'], ['type' => 'Custom multiplier', 'parameter_1' => '{$VALUE}'], ['type' => 'In range', 'parameter_1' => '{$FROM}', 'parameter_2' => '{$TO}'], ['type' => 'Matches regular expression', 'parameter_1' => '{$EXPRESSION}(.*)'], ['type' => 'Does not match regular expression', 'parameter_1' => '{$REGEXP}(.+)'], ['type' => 'JavaScript', 'parameter_1' => '{$JAVASCRIPT}'], ['type' => 'Check for error in JSON', 'parameter_1' => '{$USERMACRO}'], ['type' => 'Check for error in XML', 'parameter_1' => '/tmp/{$PATH}'], ['type' => 'Check for error using regular expression', 'parameter_1' => '^{$REGEXP}(.+)', 'parameter_2' => '\0'], ['type' => 'Discard unchanged with heartbeat', 'parameter_1' => '{$SECONDS}'], ['type' => 'Prometheus to JSON', 'parameter_1' => '{$PATTERN}'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item with spaces in preprocessing', 'Key' => 'item-spaces-preprocessing[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Replace', 'parameter_1' => ' test text ', 'parameter_2' => ' replacement 1 '], ['type' => 'Regular expression', 'parameter_1' => ' pattern ', 'parameter_2' => ' \1 '], ['type' => 'Right trim', 'parameter_1' => ' 22 '], ['type' => 'Left trim', 'parameter_1' => ' 33 '], ['type' => 'Trim', 'parameter_1' => ' 0 '], ['type' => 'XML XPath', 'parameter_1' => ' number(/values/Item) '], ['type' => 'JSONPath', 'parameter_1' => ' $.data.key '], ['type' => 'Matches regular expression', 'parameter_1' => ' expression '], ['type' => 'Does not match regular expression', 'parameter_1' => ' not_expression '], ['type' => 'JavaScript', 'parameter_1' => " Test line 1 \n Test line 2 \n Test line 3 \n \n "], ['type' => 'Check for error in JSON', 'parameter_1' => ' $.error '], ['type' => 'Check for error in XML', 'parameter_1' => ' /tmp/path/ '], ['type' => 'Check for error using regular expression', 'parameter_1' => ' expression ', 'parameter_2' => ' 0 '] ] ] ] ]; } /* * "Prometheus to JSON" data for item, item prototype and LLD. */ public static function getPrometheustoJSONData() { return [ // Prometheus to JSON validation. [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter starts with digits', 'Key' => 'json-prometeus-digits-first-parameter[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '1name_of_metric'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON wrong equals operator', 'Key' => 'json-prometeus-wrong-equals-operator[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}=1'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON unsupported operator >', 'Key' => 'json-prometeus-unsupported-operator-1[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}>1'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON unsupported operator <', 'Key' => 'json-prometeus-unsupported-operator-2[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}<1'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON unsupported operator !==', 'Key' => 'json-prometeus-unsupported-operator-3[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}!==1'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON unsupported operator >=', 'Key' => 'json-prometeus-unsupported-operator-4[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}>=1'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON unsupported operator =<', 'Key' => 'json-prometeus-unsupported-operator-5[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}=<1'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON duplicate metric condition', 'Key' => 'json-duplicate-metric-condition[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu_system{__name__="metric_name"}'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON wrong parameter - space', 'Key' => 'json-wrong-parameter-space[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu usage_system'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometeus to JSON wrong parameter - slash', 'Key' => 'json-wrong-parameter-slash[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu\\'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometheus to JSON wrong parameter - digits', 'Key' => 'json-wrong-parameter-digits[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '123'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometheus to JSON wrong first parameter - pipe', 'Key' => 'json-wrong-parameter-pipe[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'metric==1e|5'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item Prometheus to JSON wrong first parameter - slash', 'Key' => 'json-wrong-parameter-slash[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{label="value\"}'] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_BAD, 'fields' => [ 'Name' => 'Item duplicate Prometeus to JSON steps', 'Key' => 'duplicate-prometheus-to-json-steps[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu_usage_system_1'], ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu_usage_system_1'] ], 'error' => 'Invalid parameter "/1/preprocessing/2": only one object can exist within '. 'the combinations of (type)=((22, 23)).' ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON empty first parameter', 'Key' => 'json-prometeus-empty-first-parameter[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => ''] ], 'error' => 'Invalid parameter "/1/preprocessing/1/params/1": invalid Prometheus pattern.' ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter +inf', 'Key' => 'json-prometeus-plus-inf[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu_usage_system==+inf'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter inf', 'Key' => 'json-prometeus-inf[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__="metric_name"}==inf'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter -inf', 'Key' => 'json-prometeus-negative-inf[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__=~""}==-inf'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter nan', 'Key' => 'json-prometeus-nan[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__="metric_name"}==nan'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter exp', 'Key' => 'json-prometeus-exp[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => 'cpu_usage_system==3.5180e+11'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameter ==1', 'Key' => 'json-prometeus-neutral-digit[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__="metric_name"}==1'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameters ==+1', 'Key' => 'json-prometeus-positive-digit[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__="metric_name"}==+1'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON first parameters ==-1', 'Key' => 'json-prometeus-negative-digit[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__="metric_name"}==-1'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON label operator =', 'Key' => 'json-prometeus-label-operator-equal-strong[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{label_name="name"}'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON label operator =~', 'Key' => 'json-prometeus-label-operator-contains[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{label_name=~"name"}'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON slashes in pattern', 'Key' => 'json-prometeus-slashes-pattern[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{label="value\\\\"}'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON user macros in parameter', 'Key' => 'json-prometeus-macros-1[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{$METRIC_NAME}==1'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON user macros in parameter', 'Key' => 'json-prometeus-macros-2[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{__name__="{$METRIC_NAME}"}'] ] ] ], [ [ 'expected' => TEST_GOOD, 'fields' => [ 'Name' => 'Item Prometeus to JSON user macros in parameters', 'Key' => 'json-prometeus-macros-3[{#KEY}]' ], 'preprocessing' => [ ['type' => 'Prometheus to JSON', 'parameter_1' => '{{$LABEL_NAME}="