From 6027943d65e59f179e0c1b0d018c482f71964816 Mon Sep 17 00:00:00 2001 From: omercier <32134301+omercier@users.noreply.github.com> Date: Fri, 21 Mar 2025 08:56:35 +0100 Subject: [PATCH] enh(counters/iplabe-ekara): allow to sort instances on attribute instead of instance key (#5501) Refs: CTOR-1388 --- .../iplabel/ekara/restapi/mode/scenarios.pm | 67 ++++++++++++++++--- src/centreon/plugins/templates/counter.pm | 39 ++++++++++- .../aws/cloudtrail/checktrailstatus.robot | 2 +- tests/cloud/aws/cloudtrail/countevents.robot | 2 +- .../restapi/monitoring-iplabel-ekara.json | 43 +++++++++++- .../iplabel/ekara/restapi/scenarios.robot | 6 +- tests/resources/resources.resource | 1 + 7 files changed, 144 insertions(+), 16 deletions(-) diff --git a/src/apps/monitoring/iplabel/ekara/restapi/mode/scenarios.pm b/src/apps/monitoring/iplabel/ekara/restapi/mode/scenarios.pm index 1641aa12d..afc4d33ea 100644 --- a/src/apps/monitoring/iplabel/ekara/restapi/mode/scenarios.pm +++ b/src/apps/monitoring/iplabel/ekara/restapi/mode/scenarios.pm @@ -53,7 +53,16 @@ sub set_counters { { name => 'scenarios', type => 3, cb_prefix_output => 'prefix_scenario_output', cb_long_output => 'prefix_scenario_output', indent_long_output => ' ', message_multiple => 'All scenarios are ok', group => [ { name => 'global', type => 0, skipped_code => { -10 => 1 } }, - { name => 'steps', display_long => 1, cb_prefix_output => 'prefix_steps_output', message_multiple => 'All steps are ok', type => 1, skipped_code => { -10 => 1 } } + { + name => 'steps', + type => 1, + cb_prefix_output => 'prefix_steps_output', + display_long => 1, + message_multiple => 'All steps are ok', + skipped_code => { -10 => 1 }, + sort_method => 'num', + sort_attribute => 'index' + } ] } ]; @@ -98,7 +107,7 @@ sub set_counters { ]; $self->{maps_counters}->{steps} = [ { label => 'time-step', nlabel => 'scenario.step.time.milliseconds', set => { - key_values => [ { name => 'time_step' }, { name => 'display' }, { name => 'last_exec' } ], + key_values => [ { name => 'time_step' }, { name => 'display' }, { name => 'last_exec' }, { name => 'index' } ], output_template => 'time step: %s ms', perfdatas => [ { template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 } @@ -106,7 +115,7 @@ sub set_counters { } }, { label => 'time-total', nlabel => 'scenario.steps.time.total.milliseconds', set => { - key_values => [ { name => 'time_total' }, { name => 'display' }, { name => 'last_exec' } ], + key_values => [ { name => 'time_total' }, { name => 'display' }, { name => 'last_exec' }, { name => 'index' } ], output_template => 'time total: %s ms', perfdatas => [ { template => '%s', unit => 'ms', min => 0, label_extra_instance => 1 } @@ -209,6 +218,7 @@ sub manage_selection { $self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{ $step_metrics->{metric} } = $step_metrics->{value}; $self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{last_exec} = POSIX::strftime('%d-%m-%Y %H:%M:%S %Z', localtime($exec_time)); $self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{display} = $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} }; + $self->{scenarios}->{ $scenario->{scenarioName} }->{steps}->{ $self->{scenarios}->{ $scenario->{scenarioName} }->{steps_index}->{ $step_metrics->{stepId} } }->{index} = $step_metrics->{stepId}; } } @@ -254,14 +264,53 @@ Syntax: C<--warning-scenario-status='%{status} =~ "xxx"'> Critical threshold for scenario status (default: '%{status} =~ "Failure"'). Syntax: --critical-scenario-status='%{status} =~ "xxx"' -=item B<--warning-*> B<--critical-*> +=item B<--warning-availability> -Thresholds. -Common: 'availability' (%), -For WEB scenarios: 'time-total-allsteps' (ms), 'time-step' (ms), -For HTTPR scenarios: 'time-total' (ms), -FOR BPL scenarios: 'time-interaction' (ms), 'time-total' (ms). +Thresholds in %. +=item B<--critical-availability> + +Thresholds in %. + +=item B<--warning-time-total-allsteps> + +Thresholds in ms for WEB scenarios. + +=item B<--critical-time-total-allsteps> + +Thresholds in ms for WEB scenarios. + +=item B<--warning-time-step> + +Thresholds in ms for WEB scenarios. + +=item B<--critical-time-step> + +Thresholds in ms for WEB scenarios. + +=item B<--warning-time-total> + +Thresholds in ms for HTTPR scenarios. + +=item B<--critical-time-total> + +Thresholds in ms for HTTPR scenarios. + +=item B<--warning-time-interaction> + +Thresholds in ms for BPL scenarios. + +=item B<--critical-time-interaction> + +Thresholds in ms for BPL scenarios. + +=item B<--warning-time-total> + +Thresholds in ms for BPL scenarios. + +=item B<--critical-time-total> + +Thresholds in ms for BPL scenarios. =back diff --git a/src/centreon/plugins/templates/counter.pm b/src/centreon/plugins/templates/counter.pm index 8aa4c14af..58fc23461 100644 --- a/src/centreon/plugins/templates/counter.pm +++ b/src/centreon/plugins/templates/counter.pm @@ -365,10 +365,27 @@ sub run_instances { my $message_separator = defined($options{config}->{message_separator}) ? $options{config}->{message_separator}: ', '; + # The default sort method is cmp (string comparison) my $sort_method = 'cmp'; + # If configured otherwise, we take it from the counter (only other method is 'num' for '<=>') $sort_method = $options{config}->{sort_method} if (defined($options{config}->{sort_method})); - foreach my $id (sort { $sort_subs->{$sort_method}->() } keys %{$self->{$options{config}->{name}}}) { + + # In the absence of sort_attribute the sort method is set now + my $sort_sub = $sort_subs->{$sort_method}; + + # If sort_attribute is set, then we'll redefine how things are sorted depending on the specified sort_method + if (defined($options{config}->{sort_attribute})) { + my $sort_attribute = $options{config}->{sort_attribute}; + if ($sort_method eq 'cmp') { + $sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} cmp $self->{$options{config}->{name}}->{$b}->{$sort_attribute}}; + } else { + $sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} <=> $self->{$options{config}->{name}}->{$b}->{$sort_attribute}}; + } + } + + # Now the loop begins with the desired sorting method + foreach my $id (sort { $sort_sub->() } keys %{$self->{$options{config}->{name}}}) { my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); my @exits = (); foreach (@{$self->{maps_counters}->{$options{config}->{name}}}) { @@ -547,10 +564,28 @@ sub run_multiple_instances { my $message_separator = defined($options{config}->{message_separator}) ? $options{config}->{message_separator} : ', '; + + # The default sort method is cmp (string comparison) my $sort_method = 'cmp'; + # If configured otherwise, we take it from the counter (only other method is 'num' for '<=>') $sort_method = $options{config}->{sort_method} if (defined($options{config}->{sort_method})); - foreach my $id (sort { $sort_subs->{$sort_method}->() } keys %{$self->{$options{config}->{name}}}) { + + # In the absence of sort_attribute the sort method is set now + my $sort_sub = $sort_subs->{$sort_method}; + + # If sort_attribute is set, then we'll redefine how things are sorted depending on the specified sort_method + if (defined($options{config}->{sort_attribute})) { + my $sort_attribute = $options{config}->{sort_attribute}; + if ($sort_method eq 'cmp') { + $sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} cmp $self->{$options{config}->{name}}->{$b}->{$sort_attribute}}; + } else { + $sort_sub = sub { $self->{$options{config}->{name}}->{$a}->{$sort_attribute} <=> $self->{$options{config}->{name}}->{$b}->{$sort_attribute}}; + } + } + + # Now the loop begins with the desired sorting method + foreach my $id (sort { $sort_sub->() } keys %{$self->{$options{config}->{name}}}) { my ($short_msg, $short_msg_append, $long_msg, $long_msg_append) = ('', '', '', ''); my @exits = (); foreach (@{$self->{maps_counters}->{$options{config}->{name}}}) { diff --git a/tests/cloud/aws/cloudtrail/checktrailstatus.robot b/tests/cloud/aws/cloudtrail/checktrailstatus.robot index 4c785abf2..5f54aef37 100644 --- a/tests/cloud/aws/cloudtrail/checktrailstatus.robot +++ b/tests/cloud/aws/cloudtrail/checktrailstatus.robot @@ -15,7 +15,7 @@ ${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtr *** Test Cases *** -AWS CloudTrail check trail status +AWS CloudTrail check trail status ${tc} [Documentation] Check AWS CloudTrail trail status [Tags] cloud aws cloudtrail diff --git a/tests/cloud/aws/cloudtrail/countevents.robot b/tests/cloud/aws/cloudtrail/countevents.robot index e47a2ddc1..a14ef3e9b 100644 --- a/tests/cloud/aws/cloudtrail/countevents.robot +++ b/tests/cloud/aws/cloudtrail/countevents.robot @@ -15,7 +15,7 @@ ${CMD} ${CENTREON_PLUGINS} --plugin=cloud::aws::cloudtr *** Test Cases *** -AWS CloudTrail count events +AWS CloudTrail count events ${tc} [Documentation] Check AWS CloudTrail count events [Tags] cloud aws cloudtrail diff --git a/tests/monitoring/iplabel/ekara/restapi/monitoring-iplabel-ekara.json b/tests/monitoring/iplabel/ekara/restapi/monitoring-iplabel-ekara.json index ee3c257c9..d515ab639 100644 --- a/tests/monitoring/iplabel/ekara/restapi/monitoring-iplabel-ekara.json +++ b/tests/monitoring/iplabel/ekara/restapi/monitoring-iplabel-ekara.json @@ -221,9 +221,50 @@ "value": "Bearer VeryLongTokenToAuthenticate", "invert": false, "operator": "equals" + }, + { + "target": "header", + "modifier": "Test", + "value": "2", + "invert": true, + "operator": "equals" } ], - "rulesOperator": "OR", + "rulesOperator": "AND", + "disableTemplating": false, + "fallbackTo404": false, + "default": false, + "crudKey": "id", + "callbacks": [] + }, + { + "uuid": "b33f660f-e7b5-45f7-92c9-72b2dacc71e4", + "body": "{\n \"kpis\": [\n {\n \"name\": \"Availability\",\n \"order\": 0,\n \"type\": \"User\",\n \"unit\": \"percent\",\n \"label\": \"availability\",\n \"value\": 64.48\n },\n {\n \"name\": \"Total time for all steps\",\n \"order\": 100,\n \"type\": \"User\",\n \"unit\": \"ms\",\n \"label\": \"time_total_allsteps\",\n \"value\": 4031\n }\n ],\n \"results\": [\n {\n \"planningTime\": \"2025-03-10T14:45:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 9741,\n \"count\": 2,\n \"value\": 4871\n },\n {\n \"planningTime\": \"2025-03-10T14:45:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 48,\n \"count\": 1,\n \"value\": 48\n },\n {\n \"planningTime\": \"2025-03-10T14:45:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 23,\n \"count\": 1,\n \"value\": 23\n },\n {\n \"planningTime\": \"2025-03-10T15:00:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 7096,\n \"count\": 2,\n \"value\": 3548\n },\n {\n \"planningTime\": \"2025-03-10T15:00:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 69,\n \"count\": 1,\n \"value\": 69\n },\n {\n \"planningTime\": \"2025-03-10T15:00:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 29,\n \"count\": 1,\n \"value\": 29\n },\n {\n \"planningTime\": \"2025-03-10T15:15:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 6420,\n \"count\": 2,\n \"value\": 3210\n },\n {\n \"planningTime\": \"2025-03-10T15:15:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 51,\n \"count\": 1,\n \"value\": 51\n },\n {\n \"planningTime\": \"2025-03-10T15:15:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 750,\n \"count\": 1,\n \"value\": 750\n },\n {\n \"planningTime\": \"2025-03-10T15:30:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 5986,\n \"count\": 2,\n \"value\": 2993\n },\n {\n \"planningTime\": \"2025-03-10T15:30:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 2499,\n \"count\": 2,\n \"value\": 1250\n },\n {\n \"planningTime\": \"2025-03-10T15:30:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 91,\n \"count\": 2,\n \"value\": 46\n },\n {\n \"planningTime\": \"2025-03-10T15:45:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 6275,\n \"count\": 2,\n \"value\": 3138\n },\n {\n \"planningTime\": \"2025-03-10T15:45:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 263,\n \"count\": 2,\n \"value\": 132\n },\n {\n \"planningTime\": \"2025-03-10T15:45:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 197,\n \"count\": 2,\n \"value\": 99\n },\n {\n \"planningTime\": \"2025-03-10T16:00:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 7029,\n \"count\": 2,\n \"value\": 3515\n },\n {\n \"planningTime\": \"2025-03-10T16:00:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 221,\n \"count\": 1,\n \"value\": 221\n },\n {\n \"planningTime\": \"2025-03-10T16:00:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 38,\n \"count\": 1,\n \"value\": 38\n },\n {\n \"planningTime\": \"2025-03-10T16:15:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 7397,\n \"count\": 2,\n \"value\": 3699\n },\n {\n \"planningTime\": \"2025-03-10T16:15:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 1611,\n \"count\": 1,\n \"value\": 1611\n },\n {\n \"planningTime\": \"2025-03-10T16:15:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 1583,\n \"count\": 1,\n \"value\": 1583\n },\n {\n \"planningTime\": \"2025-03-10T16:30:00Z\",\n \"stepId\": \"0\",\n \"metric\": \"time_step\",\n \"duration\": 7724,\n \"count\": 2,\n \"value\": 3862\n },\n {\n \"planningTime\": \"2025-03-10T16:30:00Z\",\n \"stepId\": \"1\",\n \"metric\": \"time_step\",\n \"duration\": 215,\n \"count\": 1,\n \"value\": 215\n },\n {\n \"planningTime\": \"2025-03-10T16:30:00Z\",\n \"stepId\": \"2\",\n \"metric\": \"time_step\",\n \"duration\": 68,\n \"count\": 1,\n \"value\": 68\n }\n ],\n \"siteIds\": [\n {\n \"id\": \"76300f93-1714-4235-aa20-105d0815b4e0\",\n \"name\": \"Paris (Iliad)\"\n },\n {\n \"id\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"name\": \"Paris (SFR)\"\n }\n ],\n \"metrics\": [\n {\n \"mtr_id\": \"eco_index\",\n \"mtr_name\": \"Eco Efficiency\",\n \"mtr_order\": 300,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \" \",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": false,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"nb_dom_elements\",\n \"mtr_name\": \"Number of DOM Elements\",\n \"mtr_order\": -1,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \" \",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": false,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"rum_speedindex\",\n \"mtr_name\": \"RUM Speed Index\",\n \"mtr_order\": 40,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": 10,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"start_render\",\n \"mtr_name\": \"Start render time\",\n \"mtr_order\": 10,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_appcache\",\n \"mtr_name\": \"Application cache\",\n \"mtr_order\": 220,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_connect\",\n \"mtr_name\": \"Connection time\",\n \"mtr_order\": 240,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_interaction\",\n \"mtr_name\": \"Time to interact\",\n \"mtr_order\": 20,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": 20,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_multi_step\",\n \"mtr_name\": \"Cumulative Time Step\",\n \"mtr_order\": 100,\n \"mtr_type\": \"Cumulative\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": false,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_namelookup\",\n \"mtr_name\": \"Lookup time\",\n \"mtr_order\": 230,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_pageload\",\n \"mtr_name\": \"Page load time\",\n \"mtr_order\": 280,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_received\",\n \"mtr_name\": \"Response time\",\n \"mtr_order\": 270,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_redirect\",\n \"mtr_name\": \"Redirection time\",\n \"mtr_order\": 210,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_request\",\n \"mtr_name\": \"First byte time\",\n \"mtr_order\": 260,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_security_connect\",\n \"mtr_name\": \"TLS time\",\n \"mtr_order\": 250,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_step\",\n \"mtr_name\": \"Time Step\",\n \"mtr_order\": 100,\n \"mtr_type\": \"Technical\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_total_allsteps\",\n \"mtr_name\": \"Total time for all steps\",\n \"mtr_order\": 100,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": 30,\n \"filterEnabled\": false,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_wv_fcp\",\n \"mtr_name\": \"First Contentful Paint\",\n \"mtr_order\": -1,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_wv_fid\",\n \"mtr_name\": \"First Input Delay\",\n \"mtr_order\": -1,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_wv_inp\",\n \"mtr_name\": \"Interaction to Next Paint\",\n \"mtr_order\": -1,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"time_wv_lcp\",\n \"mtr_name\": \"Largest Contentful Paint\",\n \"mtr_order\": -1,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \"ms\",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": true,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n },\n {\n \"mtr_id\": \"wv_cls\",\n \"mtr_name\": \"Cumulative Layout Shift\",\n \"mtr_order\": -1,\n \"mtr_type\": \"User\",\n \"mtr_scn_type\": \"WEB\",\n \"mtr_unit\": \" \",\n \"mtr_preferred_metric\": -1,\n \"filterEnabled\": false,\n \"filterDisabledOnMultiStep\": false,\n \"filterDisabledOnAllStep\": false,\n \"filterDisabledOnPartialStep\": false\n }\n ],\n \"retries\": [],\n \"replays\": [],\n \"updates\": [],\n \"runningReplayId\": null,\n \"steps\": [\n {\n \"name\": \"Home\",\n \"index\": 1\n },\n {\n \"name\": \"Dashboard v2\",\n \"index\": 2\n },\n {\n \"name\": \"Dashboard v3\",\n \"index\": 3\n }\n ],\n \"infos\": {\n \"active_filter\": [\n {\n \"type\": \"measurementIds\",\n \"items\": [\n \"time_step\",\n \"time_multi_step\",\n \"time_total_allsteps\"\n ]\n }\n ],\n \"plugin_id\": \"WEB\",\n \"plugin_name\": \"Web\",\n \"info\": {\n \"hasStep\": true,\n \"showKPI\": true,\n \"hasWaterfall\": true,\n \"hasEcoEfficiency\": true,\n \"showThirdPartyContent\": true\n },\n \"scenarioName\": \"AKILA - (Web)\",\n \"default_plugin\": false\n },\n \"timelineDetails\": [\n {\n \"status\": 1,\n \"startTime\": \"2025-03-10T14:42:04Z\",\n \"endTime\": \"2025-03-10T14:45:08Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"76300f93-1714-4235-aa20-105d0815b4e0\",\n \"status\": 1,\n \"execTime\": \"2025-03-10T14:35:36Z\",\n \"siteName\": \"Paris (Iliad)\",\n \"executionId\": \"2d592f6b-5c6c-49e0-b0a6-7cb05d5ddc60.14\",\n \"planningTime\": \"2025-03-10T14:30:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 2,\n \"startTime\": \"2025-03-10T14:45:08Z\",\n \"endTime\": \"2025-03-10T14:48:45Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"76300f93-1714-4235-aa20-105d0815b4e0\",\n \"status\": 2,\n \"execTime\": \"2025-03-10T14:45:08Z\",\n \"siteName\": \"Paris (Iliad)\",\n \"executionId\": \"671bfa25-9a96-4ff5-a3e4-cd2846608c88.15\",\n \"planningTime\": \"2025-03-10T14:45:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 1,\n \"startTime\": \"2025-03-10T14:48:45Z\",\n \"endTime\": \"2025-03-10T15:02:06Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 1,\n \"execTime\": \"2025-03-10T14:48:45Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"5b5172ba-b850-40f2-a1b7-82d194231580.15\",\n \"planningTime\": \"2025-03-10T14:45:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 2,\n \"startTime\": \"2025-03-10T15:02:06Z\",\n \"endTime\": \"2025-03-10T15:07:18Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 2,\n \"execTime\": \"2025-03-10T15:02:06Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"dfff8856-51e7-4c31-9f41-263b7af85ac3.16\",\n \"planningTime\": \"2025-03-10T15:00:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 1,\n \"startTime\": \"2025-03-10T15:07:18Z\",\n \"endTime\": \"2025-03-10T15:17:33Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"76300f93-1714-4235-aa20-105d0815b4e0\",\n \"status\": 1,\n \"execTime\": \"2025-03-10T15:07:18Z\",\n \"siteName\": \"Paris (Iliad)\",\n \"executionId\": \"404ded6b-ef1f-4085-800b-0b9e64730c24.16\",\n \"planningTime\": \"2025-03-10T15:00:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 2,\n \"startTime\": \"2025-03-10T15:17:33Z\",\n \"endTime\": \"2025-03-10T15:34:58Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 2,\n \"execTime\": \"2025-03-10T15:17:33Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"811c4c8d-51ce-4092-aa4d-d0bf218f477f.17\",\n \"planningTime\": \"2025-03-10T15:15:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 1,\n \"startTime\": \"2025-03-10T15:34:58Z\",\n \"endTime\": \"2025-03-10T16:08:21Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 1,\n \"execTime\": \"2025-03-10T15:34:58Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"a060532c-dc28-4ece-a06f-a8e2bdc8ad8c.18\",\n \"planningTime\": \"2025-03-10T15:30:00Z\",\n \"thresholdExceeded\": \"PT5.492S\"\n }\n ]\n },\n {\n \"status\": 2,\n \"startTime\": \"2025-03-10T16:08:21Z\",\n \"endTime\": \"2025-03-10T16:15:56Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 2,\n \"execTime\": \"2025-03-10T16:08:21Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"da588130-ed28-4528-89b6-aaeaaae19aec.20\",\n \"planningTime\": \"2025-03-10T16:00:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 1,\n \"startTime\": \"2025-03-10T16:15:56Z\",\n \"endTime\": \"2025-03-10T16:21:40Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 1,\n \"execTime\": \"2025-03-10T16:15:56Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"c77b8248-45aa-4f51-bfbc-a1dd76baa08f.21\",\n \"planningTime\": \"2025-03-10T16:15:00Z\",\n \"thresholdExceeded\": \"PT7.468S\"\n }\n ]\n },\n {\n \"status\": 2,\n \"startTime\": \"2025-03-10T16:21:40Z\",\n \"endTime\": \"2025-03-10T16:32:15Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"76300f93-1714-4235-aa20-105d0815b4e0\",\n \"status\": 2,\n \"execTime\": \"2025-03-10T16:21:40Z\",\n \"siteName\": \"Paris (Iliad)\",\n \"executionId\": \"cf72d69c-017f-43eb-8678-87ffacf9235b.21\",\n \"planningTime\": \"2025-03-10T16:15:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n },\n {\n \"status\": 1,\n \"startTime\": \"2025-03-10T16:32:15Z\",\n \"endTime\": \"2025-03-10T16:47:04Z\",\n \"execs\": [\n {\n \"period\": \"PT15M\",\n \"siteId\": \"d1c377bf-745f-4d63-b25f-904b16582649\",\n \"status\": 1,\n \"execTime\": \"2025-03-10T16:32:15Z\",\n \"siteName\": \"Paris (SFR)\",\n \"executionId\": \"ecdd45c2-9919-49ce-8231-d9c0bf6880e6.22\",\n \"planningTime\": \"2025-03-10T16:30:00Z\",\n \"thresholdExceeded\": null\n }\n ]\n }\n ],\n \"aggregate\": \"rowdata\",\n \"emptyResults\": [\n \"2025-03-10T16:45:00Z\"\n ],\n \"retentionDateExceeded\": false\n}\n", + "latency": 0, + "statusCode": 200, + "label": "With more steps, will display if \"Test: 2\" header provided", + "headers": [], + "bodyType": "INLINE", + "filePath": "", + "databucketID": "", + "sendFileAsBody": false, + "rules": [ + { + "target": "header", + "modifier": "authorization", + "value": "Bearer VeryLongTokenToAuthenticate", + "invert": false, + "operator": "equals" + }, + { + "target": "header", + "modifier": "Test", + "value": "2", + "invert": false, + "operator": "equals" + } + ], + "rulesOperator": "AND", "disableTemplating": false, "fallbackTo404": false, "default": false, diff --git a/tests/monitoring/iplabel/ekara/restapi/scenarios.robot b/tests/monitoring/iplabel/ekara/restapi/scenarios.robot index e8ec53919..6031d7712 100644 --- a/tests/monitoring/iplabel/ekara/restapi/scenarios.robot +++ b/tests/monitoring/iplabel/ekara/restapi/scenarios.robot @@ -30,9 +30,9 @@ scenario ${tc} Ctn Run Command And Check Result As Strings ${command} ${expected_result} - Examples: tc extra_options expected_result -- + Examples: tc extra_options expected_result -- ... 1 --filter-name='Centreon Demo Navigation|Centreon Demo ping NA' --output-ignore-perfdata CRITICAL: Scenario 'Centreon Demo Navigation': status: Failure (2) WARNING: Scenario 'Centreon Demo ping NA': status: Degraded (8) - ... 2 --filter-name='AKILA - Business App' OK: Scenario 'AKILA - Business App': status: Success (1), availability: 100%, time total all steps: 4280ms - All steps are ok | 'AKILA - Business App#scenario.availability.percentage'=100%;;;0;100 'AKILA - Business App#scenario.time.allsteps.total.milliseconds'=4280ms;;;0; 'AKILA - Business App~Dashboard 2#scenario.step.time.milliseconds'=898ms;;;0; 'AKILA - Business App~Dashboard 3#scenario.step.time.milliseconds'=848ms;;;0; 'AKILA - Business App~Run Chrome#scenario.step.time.milliseconds'=2534ms;;;0; + ... 2 --filter-name='AKILA - Business App' OK: Scenario 'AKILA - Business App': status: Success (1), availability: 100%, time total all steps: 4280ms - All steps are ok | 'AKILA - Business App#scenario.availability.percentage'=100%;;;0;100 'AKILA - Business App#scenario.time.allsteps.total.milliseconds'=4280ms;;;0; 'AKILA - Business App~Run Chrome#scenario.step.time.milliseconds'=2534ms;;;0; 'AKILA - Business App~Dashboard 2#scenario.step.time.milliseconds'=898ms;;;0; 'AKILA - Business App~Dashboard 3#scenario.step.time.milliseconds'=848ms;;;0; ... 3 --filter-name='wrong currentstatus.*' UNKNOWN: Scenario 'wrong currentstatus, no perfdata': status: Unknown (14) - No execution, please try again with a bigger timeframe ... 4 --filter-name='not a scenario name' UNKNOWN: No scenario found ... 5 --filter-id='127a149b.*' --warning-time-total='30' --output-ignore-perfdata WARNING: Scenario 'AKILA - (Browser Page Load)': Step: Default, last exec: 30-12-2024 10:30:00 UTC, time total: 1097 ms @@ -50,3 +50,5 @@ scenario ${tc} ... 14 --filter-name='unknown Status 4' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 4': status: No execution (4) ... 15 --filter-name='unknown Status 5' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 5': status: No execution (5) ... 16 --filter-name='unknown Status 6' --output-ignore-perfdata UNKNOWN: Scenario 'unknown Status 6': status: Stopped (6) + ... 17 --filter-name='AKILA - .Web.' --curl-opt='CURLOPT_HTTPHEADER => [test: 2]' --curl-opt='CURLOPT_HTTPHEADER => [ Authorization: Bearer VeryLongTokenToAuthenticate]' CRITICAL: Scenario 'AKILA - (Web)': status: Failure (2) | 'AKILA - (Web)#scenario.availability.percentage'=64.48%;;;0;100 'AKILA - (Web)#scenario.time.allsteps.total.milliseconds'=4031ms;;;0; 'AKILA - (Web)~Home#scenario.step.time.milliseconds'=3862ms;;;0; 'AKILA - (Web)~Dashboard v2#scenario.step.time.milliseconds'=215ms;;;0; 'AKILA - (Web)~Dashboard v3#scenario.step.time.milliseconds'=68ms;;;0; + diff --git a/tests/resources/resources.resource b/tests/resources/resources.resource index ca6820e7a..d3c585046 100644 --- a/tests/resources/resources.resource +++ b/tests/resources/resources.resource @@ -52,6 +52,7 @@ Ctn Cleanup Cache Ctn Generic Suite Setup Ctn Cleanup Cache + Set Environment Variable TZ UTC Ctn Run Command And Check Result As Regexp [Arguments] ${command} ${expected_result}