Merge "Parametrize Cassandra JVM dashboard row"
diff --git a/metadata.yml b/metadata.yml
index 9ae0df6..ba3b2d8 100644
--- a/metadata.yml
+++ b/metadata.yml
@@ -3,4 +3,6 @@
 source: "https://github.com/openstack/salt-formula-opencontrail"
 dependencies:
 - name: linux
-  source: "https://github.com/tcpcloud/salt-formula-linux"
+  source: "https://github.com/salt-formulas/salt-formula-linux"
+- name: prometheus
+  source: "https://github.com/salt-formulas/salt-formula-prometheus"
diff --git a/opencontrail/files/3.0/contrail-api.conf b/opencontrail/files/3.0/contrail-api.conf
index dbe1b77..2191201 100644
--- a/opencontrail/files/3.0/contrail-api.conf
+++ b/opencontrail/files/3.0/contrail-api.conf
@@ -39,6 +39,9 @@
 {% if config.override_rpf_default_by is defined %}
 override_rpf_default_by={{ config.override_rpf_default_by | lower }}
 {% endif %}
+{%- if config.get('list_optimization_enabled', False) %}
+list_optimization_enabled=True
+{%- endif %}
 
 [SECURITY]
 use_certs=False
diff --git a/opencontrail/files/4.0/contrail-api.conf b/opencontrail/files/4.0/contrail-api.conf
index c14610f..efe12cc 100644
--- a/opencontrail/files/4.0/contrail-api.conf
+++ b/opencontrail/files/4.0/contrail-api.conf
@@ -35,6 +35,9 @@
 {% if config.override_rpf_default_by is defined %}
 override_rpf_default_by={{ config.override_rpf_default_by | lower }}
 {% endif %}
+{%- if config.get('list_optimization_enabled', False) %}
+list_optimization_enabled=True
+{%- endif %}
 
 # (StrOpt) default encoding to use for string resources.
 # this is optional variable. Define it if you want to override
@@ -56,4 +59,4 @@
 #introspect_ssl_enable=false
 #sandesh_keyfile=/etc/contrail/ssl/private/server-privkey.pem
 #sandesh_certfile=/etc/contrail/ssl/certs/server.pem
-#sandesh_ca_cert=/etc/contrail/ssl/certs/ca-cert.pem
\ No newline at end of file
+#sandesh_ca_cert=/etc/contrail/ssl/certs/ca-cert.pem
diff --git a/opencontrail/map.jinja b/opencontrail/map.jinja
index 9b91cca..e98c2f4 100644
--- a/opencontrail/map.jinja
+++ b/opencontrail/map.jinja
@@ -239,3 +239,25 @@
 {% set client    = salt['grains.filter_by'](base_defaults['client'], merge=salt['pillar.get']('opencontrail:client', {}), base='client') %}
 {% set tor       = salt['grains.filter_by'](base_defaults['tor'], merge=salt['pillar.get']('opencontrail:tor', {}), base='tor') %}
 
+{% set monitoring = salt['grains.filter_by']({
+    'default': {
+        'xmpp_sessions_too_high_threshold': 500,
+        'xmpp_sessions_variation_threshold': 100,
+        'vrouter_xmpp_sessions_too_high_threshold': 10,
+        'vrouter_xmpp_sessions_variation_threshold': 5,
+        'vrouter_dns_xmpp_sessions_too_high_threshold': 10,
+        'vrouter_dns_xmpp_sessions_variation_threshold': 5,
+        'vrouter_lls_too_high_threshold': 10,
+        'vrouter_lls_variation_threshold': 5,
+        'vrouter_flows_active_too_high_threshold': 1200,
+        'vrouter_flows_created_too_high_threshold': 1000,
+        'vrouter_flows_discard_too_high_threshold': 1200,
+        'vrouter_flows_flow_action_drop_too_high_threshold': 100,
+        'vrouter_flows_frag_err_too_high_threshold': 100,
+        'vrouter_flows_invalid_nh_too_high_threshold': 104,
+        'vrouter_flows_composite_invalid_interface_too_high_threshold': 105,
+        'vrouter_flows_invalid_label_too_high_threshold': 100,
+        'vrouter_flows_flow_queue_limit_exceeded_too_high_threshold': 100,
+        'vrouter_flows_flow_table_full_too_high_threshold': 100,
+    },
+}, grain='os_family', merge=salt['pillar.get']('opencontrail:monitoring')) %}
diff --git a/opencontrail/meta/collectd.yml b/opencontrail/meta/collectd.yml
index 8c4ca5f..482a70f 100644
--- a/opencontrail/meta/collectd.yml
+++ b/opencontrail/meta/collectd.yml
@@ -115,15 +115,15 @@
       {%- set bind_addr=config.bind.address|replace('0.0.0.0', '127.0.0.1') %}
       contrail-api:
         expected_code: 200
-        url: "http://{{ bind_addr }}:{{ config.bind.api_port }}/"
+        url: "http://{{ bind_addr }}:{{ config.bind.api_port|default(9100) }}/"
       contrail-discovery:
         expected_code: 200
-        url: "http://{{ bind_addr }}:{{ config.bind.discovery_port }}/"
+        url: "http://{{ bind_addr }}:{{ config.bind.discovery_port|default(9110) }}/"
     {%- endif %}
     {%- if collector.get('enabled', False) %}
       contrail-collector:
         expected_code: 200
-        url: "http://{{ collector.bind.address|replace('0.0.0.0', '127.0.0.1') }}:{{ collector.bind.port }}/"
+        url: "http://{{ collector.bind.address|replace('0.0.0.0', '127.0.0.1') }}:{{ collector.bind.port|default(9081) }}/"
     {%- endif %}
     {%- if compute.get('enabled', False) %}
       contrail-node-manager:
diff --git a/opencontrail/meta/prometheus.yml b/opencontrail/meta/prometheus.yml
index 0904554..72b2dbf 100644
--- a/opencontrail/meta/prometheus.yml
+++ b/opencontrail/meta/prometheus.yml
@@ -1,5 +1,5 @@
 {%- if pillar.opencontrail is defined %}
-  {%- from "opencontrail/map.jinja" import control, collector, compute, config, database, web with context %}
+  {%- from "opencontrail/map.jinja" import control, collector, compute, config, database, web, monitoring with context %}
 
   {%- if collector.get('enabled', False) %}
     {%- set collector_apis = ( 'contrail.collector', ) %}
@@ -179,24 +179,28 @@
         description: 'There are no XMPP sessions on node {{ $labels.host }}'
     ContrailXMPPSessionsTooMany:
       if: >-
-        min(contrail_xmpp_session_count) >= 500
+{%- endraw %}
+    {%- set xmpp_toohigh_threshold = monitoring.xmpp_sessions_too_high_threshold %}
+        min(contrail_xmpp_session_count) >= {{ xmpp_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-control
       annotations:
         summary: 'Too many XMPP sessions'
-        description: 'There are too many XMPP sessions on node {{ $labels.host }}'
+        description: 'There are too many XMPP sessions on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ xmpp_toohigh_threshold }})'
     ContrailXMPPSessionsTooManyVariations:
       if: >-
-        abs(delta(contrail_xmpp_session_count[2m])) >= 100
+    {%- set xmpp_variation_threshold = monitoring.xmpp_sessions_variation_threshold %}
+        abs(delta(contrail_xmpp_session_count[2m])) >= {{ xmpp_variation_threshold }}
+{%- raw %}
       labels:
         severity: warning
         service: contrail-control
       annotations:
         summary: 'Number of XMPP sessions changed between checks is too high'
-        description: 'There are too many XMPP sessions changes on node {{ $labels.host }}'
-{%- endraw %}
+        description: 'There are too many XMPP sessions changes on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ xmpp_variation_threshold }})'
     {%- endif %}
 
     {%- if collector_processes is defined %}
@@ -244,23 +248,29 @@
         description: 'There are no vRouter XMPP sessions on node {{ $labels.host }}'
     ContrailVrouterXMPPSessionsTooMany:
       if: >-
-        min(contrail_vrouter_xmpp) >= 10
+{%- endraw %}
+    {%- set vrouter_xmpp_toohigh_threshold = monitoring.vrouter_xmpp_sessions_too_high_threshold %}
+        min(contrail_vrouter_xmpp) >= {{ vrouter_xmpp_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter XMPP sessions'
-        description: 'There are too many vRouter XMPP sessions on node {{ $labels.host }}'
+        description: 'There are too many vRouter XMPP sessions on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_xmpp_toohigh_threshold }})'
     ContrailVrouterXMPPSessionsTooManyVariations:
       if: >-
-        abs(delta(contrail_vrouter_xmpp[2m])) >= 5
+    {%- set vrouter_xmpp_variation_threshold = monitoring.vrouter_xmpp_sessions_variation_threshold %}
+        abs(delta(contrail_vrouter_xmpp[2m])) >= {{ vrouter_xmpp_variation_threshold }}
+{%- raw %}
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Number of vRouter XMPP sessions changed between checks is too high'
-        description: 'There are too many vRouter XMPP sessions changes on node {{ $labels.host }}'
+        description: 'There are too many vRouter XMPP sessions changes on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_xmpp_variation_threshold }})'
+{%- raw %}
     ContrailVrouterDNSXMPPSessionsNone:
       if: >-
         max(contrail_vrouter_dns_xmpp) == 0
@@ -273,143 +283,171 @@
         description: 'There are no vRouter DNS-XMPP sessions on node {{ $labels.host }}'
     ContrailVrouterDNSXMPPSessionsTooMany:
       if: >-
-        min(contrail_vrouter_dns_xmpp) >= 10
+{%- endraw %}
+    {%- set vrouter_dns_xmpp_toohigh_threshold = monitoring.vrouter_dns_xmpp_sessions_too_high_threshold %}
+        min(contrail_vrouter_dns_xmpp) >= {{ vrouter_dns_xmpp_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter DNS-XMPP sessions'
-        description: 'There are too many vRouter DNS-XMPP sessions on node {{ $labels.host }}'
+        description: 'There are too many vRouter DNS-XMPP sessions on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_dns_xmpp_toohigh_threshold }})'
     ContrailVrouterDNSXMPPSessionsTooManyVariations:
       if: >-
-        abs(delta(contrail_vrouter_dns_xmpp[2m])) >= 5
+    {%- set vrouter_dns_xmpp_variation_threshold = monitoring.vrouter_dns_xmpp_sessions_variation_threshold %}
+        abs(delta(contrail_vrouter_dns_xmpp[2m])) >= {{ vrouter_dns_xmpp_variation_threshold }}
+{%- raw %}
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Number of vRouter DNS-XMPP sessions changed between checks is too high'
-        description: 'There are too many vRouter DNS-XMPP sessions changes on node {{ $labels.host }}'
+        description: 'There are too many vRouter DNS-XMPP sessions changes on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_dns_xmpp_variation_threshold }})'
     ContrailVrouterLLSSessionsTooMany:
       if: >-
-        min(contrail_vrouter_lls) >= 10
+    {%- set vrouter_lls_toohigh_threshold = monitoring.vrouter_lls_too_high_threshold %}
+        min(contrail_vrouter_lls) >= {{ vrouter_lls_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter LLS sessions'
-        description: 'There are too many vRouter LLS sessions on node {{ $labels.host }}'
+        description: 'There are too many vRouter LLS sessions on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_lls_toohigh_threshold }})'
     ContrailVrouterLLSSessionsTooManyVariations:
       if: >-
-        abs(delta(contrail_vrouter_lls[2m])) >= 5
+    {%- set vrouter_lls_variation_threshold = monitoring.vrouter_lls_variation_threshold %}
+        abs(delta(contrail_vrouter_lls[2m])) >= {{ vrouter_lls_variation_threshold }}
+{%- raw %}
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Number of vRouter LLS sessions changed between checks is too high'
-        description: 'There are too many vRouter LLS sessions changes on node {{ $labels.host }}'
+        description: 'There are too many vRouter LLS sessions changes on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_lls_variation_threshold }})'
     ContrailFlowsActiveTooMany:
       if: >-
-        min(contrail_vrouter_flows_active) >= 1200
+    {%- set vrouter_flows_active_toohigh_threshold = monitoring.vrouter_flows_active_too_high_threshold %}
+        min(contrail_vrouter_flows_active) >= {{ vrouter_flows_active_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter active flows'
-        description: 'There are too many active vRouter flows on node {{ $labels.host }}'
+        description: 'There are too many active vRouter flows on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_active_toohigh_threshold }})'
     ContrailFlowsCreatedTooMany:
       if: >-
-        min(contrail_vrouter_flows_created) >= 1000
+    {%- set vrouter_flows_created_toohigh_threshold = monitoring.vrouter_flows_created_too_high_threshold %}
+        min(contrail_vrouter_flows_created) >= {{ vrouter_flows_created_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter created flows'
-        description: 'There are too many created vRouter flows on node {{ $labels.host }}'
+        description: 'There are too many created vRouter flows on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_created_toohigh_threshold }})'
     ContrailFlowsDiscardTooMany:
       if: >-
-        min(contrail_vrouter_flows_discard) >= 1200
+    {%- set vrouter_flows_discard_toohigh_threshold = monitoring.vrouter_flows_discard_too_high_threshold %}
+        min(contrail_vrouter_flows_discard) >= {{ vrouter_flows_discard_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter discarded flows'
-        description: 'There are too many discarded vRouter flows on node {{ $labels.host }}'
+        description: 'There are too many discarded vRouter flows on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_discard_toohigh_threshold }})'
     ContrailFlowsDropTooMany:
       if: >-
-        min(contrail_vrouter_flows_flow_action_drop) >= 100
+    {%- set vrouter_flows_flow_action_drop_toohigh_threshold = monitoring.vrouter_flows_flow_action_drop_too_high_threshold %}
+        min(contrail_vrouter_flows_flow_action_drop) >= {{ vrouter_flows_flow_action_drop_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter dropped flows'
-        description: 'There are too many dropped vRouter flows on node {{ $labels.host }}'
+        description: 'There are too many dropped vRouter flows on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_flow_action_drop_toohigh_threshold }})'
     ContrailFlowsFragErrTooMany:
       if: >-
-        min(contrail_vrouter_flows_frag_err) >= 100
+    {%- set vrouter_flows_frag_err_toohigh_threshold = monitoring.vrouter_flows_frag_err_too_high_threshold %}
+        min(contrail_vrouter_flows_frag_err) >= {{ vrouter_flows_frag_err_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter flows with fragment errors'
-        description: 'There are too many vRouter flows with fragment errors on node {{ $labels.host }}'
+        description: 'There are too many vRouter flows with fragment errors on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_frag_err_toohigh_threshold }})'
     ContrailFlowsInvalidNHTooMany:
       if: >-
-        min(contrail_vrouter_flows_invalid_nh) >= 100
+    {%- set vrouter_flows_invalid_nh_toohigh_threshold = monitoring.vrouter_flows_invalid_nh_too_high_threshold %}
+        min(contrail_vrouter_flows_invalid_nh) >= {{ vrouter_flows_invalid_nh_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter flows with invalid next hop'
-        description: 'There are too many vRouter flows with invalid next hop on node {{ $labels.host }}'
+        description: 'There are too many vRouter flows with invalid next hop on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_invalid_nh_toohigh_threshold }})'
     ContrailFlowsInvalidITFTooMany:
       if: >-
-        min(contrail_vrouter_flows_composite_invalid_interface) >= 100
+    {%- set vrouter_flows_composite_invalid_interface_toohigh_threshold = monitoring.vrouter_flows_composite_invalid_interface_too_high_threshold %}
+        min(contrail_vrouter_flows_composite_invalid_interface) >= {{ vrouter_flows_composite_invalid_interface_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter flows with composite invalid interface'
-        description: 'There are too many vRouter flows with composite invalid interface on node {{ $labels.host }}'
+        description: 'There are too many vRouter flows with composite invalid interface on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_composite_invalid_interface_toohigh_threshold }})'
     ContrailFlowsInvalidLabelTooMany:
       if: >-
-        min(contrail_vrouter_flows_invalid_label) >= 100
+    {%- set vrouter_flows_invalid_label_toohigh_threshold = monitoring.vrouter_flows_invalid_label_too_high_threshold %}
+        min(contrail_vrouter_flows_invalid_label) >= {{ vrouter_flows_invalid_label_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter flows with invalid label'
-        description: 'There are too many vRouter flows with invalid label on node {{ $labels.host }}'
+        description: 'There are too many vRouter flows with invalid label on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_invalid_label_toohigh_threshold }})'
     ContrailFlowsQueueLimitExeededTooMany:
       if: >-
-        min(contrail_vrouter_flows_flow_queue_limit_exceeded) >= 100
+    {%- set vrouter_flows_flow_queue_limit_exceeded_toohigh_threshold = monitoring.vrouter_flows_flow_queue_limit_exceeded_too_high_threshold %}
+        min(contrail_vrouter_flows_flow_queue_limit_exceeded) >= {{ vrouter_flows_flow_queue_limit_exceeded_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter flows with queue limit exceeded'
-        description: 'There are too many vRouter flows with queue limit exceeded on node {{ $labels.host }}'
+        description: 'There are too many vRouter flows with queue limit exceeded on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_flow_queue_limit_exceeded_toohigh_threshold }})'
     ContrailFlowsTableFullTooMany:
       if: >-
-        min(contrail_vrouter_flows_flow_table_full) >= 100
+    {%- set vrouter_flows_flow_table_full_toohigh_threshold = monitoring.vrouter_flows_flow_table_full_too_high_threshold %}
+        min(contrail_vrouter_flows_flow_table_full) >= {{ vrouter_flows_flow_table_full_toohigh_threshold }}
+{%- raw %}
       for: 2m
       labels:
         severity: warning
         service: contrail-compute
       annotations:
         summary: 'Too many vRouter flows with table full'
-        description: 'There are too many vRouter flows with table full on node {{ $labels.host }}'
-{%- endraw %}
+        description: 'There are too many vRouter flows with table full on node {{ $labels.host }} (current value={{ $value }}, threshold={%- endraw %}{{ vrouter_flows_flow_table_full_toohigh_threshold }})'
       {%- for contrail_api in compute_apis %}
         {%- set words = contrail_api.split('.') %}
     {% for word in words %}{%- if word != 'api' %}{{ word | capitalize }}{% endif %}{% endfor %}APIDown:
diff --git a/opencontrail/meta/telegraf.yml b/opencontrail/meta/telegraf.yml
index 32989f1..e43dc93 100644
--- a/opencontrail/meta/telegraf.yml
+++ b/opencontrail/meta/telegraf.yml
@@ -90,13 +90,13 @@
     {%- if config.get('enabled', False) %}
       {%- set bind_addr=config.bind.address|replace('0.0.0.0', '127.0.0.1') %}
       contrail-api:
-        address: "http://{{ bind_addr }}:{{ config.bind.api_port }}/"
+        address: "http://{{ bind_addr }}:{{ config.bind.api_port|default(9100) }}/"
       contrail-discovery:
-        address: "http://{{ bind_addr }}:{{ config.bind.discovery_port }}/"
+        address: "http://{{ bind_addr }}:{{ config.bind.discovery_port|default(9110) }}/"
     {%- endif %}
     {%- if collector.get('enabled', False) %}
       contrail-collector:
-        address: "http://{{ collector.bind.address|replace('0.0.0.0', '127.0.0.1') }}:{{ collector.bind.port }}/"
+        address: "http://{{ collector.bind.address|replace('0.0.0.0', '127.0.0.1') }}:{{ collector.bind.port|default(9081) }}/"
     {%- endif %}
     {%- if compute.get('enabled', False) %}
       contrail-node-manager:
diff --git a/tests/pillar/control.sls b/tests/pillar/control.sls
index 1ae5ac9..0ae7584 100644
--- a/tests/pillar/control.sls
+++ b/tests/pillar/control.sls
@@ -62,6 +62,7 @@
       id: 2
     - host: 127.0.0.1
       id: 3
+    list_optimization_enabled: true
   control:
     version: 3.0
     enabled: true
diff --git a/tests/pillar/control4_0.sls b/tests/pillar/control4_0.sls
index 4177979..907dee7 100644
--- a/tests/pillar/control4_0.sls
+++ b/tests/pillar/control4_0.sls
@@ -64,6 +64,7 @@
       id: 2
     - host: 127.0.0.1
       id: 3
+    list_optimization_enabled: true
   control:
     version: 4.0
     enabled: true