ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oleew...@apache.org
Subject ambari git commit: AMBARI-15975. Add Logsearch Solr alerts (Miklos Gergely via oleewere)
Date Fri, 22 Apr 2016 19:24:10 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 693e758a2 -> 5fc461804


AMBARI-15975. Add Logsearch Solr alerts (Miklos Gergely via oleewere)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/5fc46180
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/5fc46180
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/5fc46180

Branch: refs/heads/trunk
Commit: 5fc46180435bcd1aebcfc650d12a2ff4c752c9ae
Parents: 693e758
Author: Miklos Gergely <mgergely@hortonworks.com>
Authored: Fri Apr 22 18:12:10 2016 +0200
Committer: oleewere <oleewere@gmail.com>
Committed: Fri Apr 22 21:23:21 2016 +0200

----------------------------------------------------------------------
 .../common-services/LOGSEARCH/0.5.0/alerts.json |  95 +++++++++++++++++
 .../package/alerts/alert_solr_cpu_usage.py      | 104 +++++++++++++++++++
 .../package/alerts/alert_solr_index_size.py     | 100 ++++++++++++++++++
 .../package/alerts/alert_solr_memory_usage.py   | 103 ++++++++++++++++++
 4 files changed, 402 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5fc46180/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/alerts.json
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/alerts.json
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/alerts.json
index df20be6..c6c324f 100644
--- a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/alerts.json
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/alerts.json
@@ -56,6 +56,101 @@
             }
           }
         }
+      },
+      {
+        "name": "logsearch_solr_index_size",
+        "label": "LogSearch Solr Index Size",
+        "description": "This host-level alert is triggered if the Solr index size is over
a limit.",
+        "interval": 1,
+        "scope": "ANY",
+        "source": {
+          "parameters" : [
+            {
+              "name" : "solr.index.size.warning",
+              "display_name" : "Solr index size warning threshold",
+              "units" : "GB",
+              "value" : 50,
+              "description" : "The maximum size of the Solr index before this alert is considered
to be WARNING",
+              "type" : "NUMERIC",
+              "threshold" : "WARNING"
+            },
+            {
+              "name" : "solr.index.size.critical",
+              "display_name" : "Solr index size critical threshold",
+              "units" : "GB",
+              "value" : 100,
+              "description" : "The maximum size of the Solr index before this alert is considered
to be CRITICAL",
+              "type" : "NUMERIC",
+              "threshold" : "CRITICAL"
+            }
+          ],
+          "path" : "LOGSEARCH/0.5.0/package/alerts/alert_solr_index_size.py",
+          "type" : "SCRIPT"
+        }
+      },
+      {
+        "name": "logsearch_solr_cpu",
+        "label": "LogSearch Solr CPU Utilization",
+        "description": "This host-level alert is triggered if CPU utilization of the LogSearch
Solr exceeds certain warning and critical thresholds. It checks the LogSearch Solr JMX Servlet
for the SystemCPULoad property. The threshold values are in percent.",
+        "interval": 5,
+        "scope": "ANY",
+        "enabled": true,
+        "source": {
+          "parameters" : [
+            {
+              "name" : "solr.cpu.usage.warning",
+              "display_name" : "Solr cpu usage warning threshold",
+              "units" : "%",
+              "value" : 200,
+              "description" : "The maximum cpu usage of Solr before this alert is considered
to be WARNING",
+              "type" : "NUMERIC",
+              "threshold" : "WARNING"
+            },
+            {
+              "name" : "solr.cpu.usage.critical",
+              "display_name" : "Solr cpu usage critical threshold",
+              "units" : "%",
+              "value" : 250,
+              "description" : "The maximum cpu usage of Solr index before this alert is considered
to be CRITICAL",
+              "type" : "NUMERIC",
+              "threshold" : "CRITICAL"
+            }
+          ],
+          "path" : "LOGSEARCH/0.5.0/package/alerts/alert_solr_cpu_usage.py",
+          "type" : "SCRIPT"
+        }
+      },
+      {
+        "name": "logsearch_solr_memory",
+        "label": "LogSearch Solr Memory Utilization",
+        "description": "This host-level alert is triggered if CPU utilization of the LogSearch
Solr exceeds certain warning and critical thresholds. It checks the LogSearch Solr JMX Servlet
for the SystemCPULoad property. The threshold values are in percent.",
+        "interval": 5,
+        "scope": "ANY",
+        "enabled": true,
+        "source": {
+          "parameters" : [
+            {
+              "name" : "solr.memory.usage.warning",
+              "display_name" : "Solr memory usage warning threshold",
+              "units" : "%",
+              "value" : 200,
+              "description" : "The maximum memory usage of Solr before this alert is considered
to be WARNING",
+              "type" : "NUMERIC",
+              "threshold" : "WARNING"
+            },
+            {
+              "name" : "solr.memory.usage.critical",
+              "display_name" : "Solr memory usage critical threshold",
+              "units" : "%",
+              "value" : 250,
+              "description" : "The maximum memory usage of Solr index before this alert is
considered to be CRITICAL",
+              "type" : "NUMERIC",
+              "threshold" : "CRITICAL"
+            }
+          ],
+          "path" : "LOGSEARCH/0.5.0/package/alerts/alert_solr_memory_usage.py",
+          "type" : "SCRIPT"
+        }
       }
     ]
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5fc46180/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_cpu_usage.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_cpu_usage.py
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_cpu_usage.py
new file mode 100644
index 0000000..3e070b1
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_cpu_usage.py
@@ -0,0 +1,104 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import traceback
+import urllib2
+import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json
module and has the same functions set.
+
+RESULT_CODE_OK = 'OK'
+RESULT_CODE_WARNING = 'WARNING'
+RESULT_CODE_CRITICAL = 'CRITICAL'
+RESULT_CODE_UNKNOWN = 'UNKNOWN'
+
+SOLR_PORT = '{{logsearch-solr-env/logsearch_solr_port}}'
+
+MESSAGE = '{1} CPU, load {0:.1%}'
+
+SOLR_CPU_USAGE_WARNING_KEY = 'solr.cpu.usage.warning'
+SOLR_CPU_USAGE_WARNING_DEFAULT = 200
+
+SOLR_CPU_USAGE_CRITICAL_KEY = 'solr.cpu.usage.critical'
+SOLR_CPU_USAGE_CRITICAL_DEFAULT = 250
+
+CRITICAL_CONNECTION_MESSAGE = 'Could not execute query {0}\n{1}'
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+  """
+  return (SOLR_PORT,)
+
+
+def execute(configurations={}, parameters={}, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  configurations (dictionary): a mapping of configuration key to value
+  parameters (dictionary): a mapping of script parameter key to value
+  host_name (string): the name of this host where the alert is running
+  """
+
+  if configurations is None:
+    return (RESULT_CODE_UNKNOWN, ['There were no configurations supplied to the script.'])
+
+  if SOLR_PORT in configurations:
+    solr_port = configurations[SOLR_PORT]
+  else:
+    return (RESULT_CODE_UNKNOWN, ['No Solr port specified'])
+
+  # parse script arguments
+  solr_cpu_usage_warning = SOLR_CPU_USAGE_WARNING_DEFAULT
+  if SOLR_CPU_USAGE_WARNING_KEY in parameters:
+    solr_cpu_usage_warning = float(parameters[SOLR_CPU_USAGE_WARNING_KEY])
+
+  solr_cpu_usage_critical = SOLR_CPU_USAGE_CRITICAL_DEFAULT
+  if SOLR_CPU_USAGE_CRITICAL_KEY in parameters:
+    solr_cpu_usage_critical = float(parameters[SOLR_CPU_USAGE_CRITICAL_KEY])
+
+
+  try:
+    query = "http://localhost:" + str(solr_port) + "/solr/admin/cores?action=STATUS&indexInfo=false&wt=json"
+    shard_response = urllib2.urlopen(query)
+    shard_raw_data = shard_response.read()
+    shard_json_data = json.loads(shard_raw_data)
+
+    shard_name = shard_json_data["status"].keys()[0]
+    query = "http://localhost:" + str(solr_port) + "/solr/" + shard_name + "/admin/system?wt=json"
+    shard_details_response = urllib2.urlopen(query)
+    shard_details_raw_data = shard_details_response.read()
+    shard_details_json_data = json.loads(shard_details_raw_data)
+    cpu_load = shard_details_json_data["system"]["processCpuLoad"]
+    available_processors = shard_details_json_data["system"]["availableProcessors"]
+  except:
+    label = CRITICAL_CONNECTION_MESSAGE.format(query, traceback.format_exc())
+    return (RESULT_CODE_CRITICAL, [label])
+
+  cpu_percent = cpu_load * 100.0
+  label = MESSAGE.format(cpu_load, available_processors)
+  if cpu_percent <= solr_cpu_usage_warning:
+    result_code = RESULT_CODE_OK
+  elif cpu_percent <= solr_cpu_usage_critical:
+    result_code = RESULT_CODE_WARNING
+  else:
+    result_code = RESULT_CODE_CRITICAL
+
+  return (result_code, [label])

http://git-wip-us.apache.org/repos/asf/ambari/blob/5fc46180/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_index_size.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_index_size.py
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_index_size.py
new file mode 100644
index 0000000..63e4edf
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_index_size.py
@@ -0,0 +1,100 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import traceback
+import urllib2
+import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json
module and has the same functions set.
+
+RESULT_CODE_OK = 'OK'
+RESULT_CODE_WARNING = 'WARNING'
+RESULT_CODE_CRITICAL = 'CRITICAL'
+RESULT_CODE_UNKNOWN = 'UNKNOWN'
+
+SOLR_PORT = '{{logsearch-solr-env/logsearch_solr_port}}'
+
+MESSAGE = 'Solr index size is {0:.1f}GB'
+
+SOLR_INDEX_SIZE_WARNING_KEY = 'solr.index.size.warning'
+SOLR_INDEX_SIZE_WARNING_DEFAULT = 50
+
+SOLR_INDEX_SIZE_CRITICAL_KEY = 'solr.index.size.critical'
+SOLR_INDEX_SIZE_CRITICAL_DEFAULT = 100
+
+CRITICAL_CONNECTION_MESSAGE = 'Could not execute query {0}\n{1}'
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+  """
+  return (SOLR_PORT,)
+
+
+def execute(configurations={}, parameters={}, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  configurations (dictionary): a mapping of configuration key to value
+  parameters (dictionary): a mapping of script parameter key to value
+  host_name (string): the name of this host where the alert is running
+  """
+
+  if configurations is None:
+    return (RESULT_CODE_UNKNOWN, ['There were no configurations supplied to the script.'])
+
+  if SOLR_PORT in configurations:
+    solr_port = configurations[SOLR_PORT]
+  else:
+    return (RESULT_CODE_UNKNOWN, ['No Solr port specified'])
+
+  # parse script arguments
+  solr_index_size_warning = SOLR_INDEX_SIZE_WARNING_DEFAULT
+  if SOLR_INDEX_SIZE_WARNING_KEY in parameters:
+    solr_index_size_warning = float(parameters[SOLR_INDEX_SIZE_WARNING_KEY])
+
+  solr_index_size_critical = SOLR_INDEX_SIZE_CRITICAL_DEFAULT
+  if SOLR_INDEX_SIZE_CRITICAL_KEY in parameters:
+    solr_index_size_critical = float(parameters[SOLR_INDEX_SIZE_CRITICAL_KEY])
+
+
+  try:
+    query = "http://localhost:" + str(solr_port) + "/solr/admin/cores?action=STATUS&wt=json"
+    response = urllib2.urlopen(query)
+    raw_data = response.read()
+    json_data = json.loads(raw_data)
+
+    size_in_bytes = 0
+    for shard_data in json_data["status"].itervalues():
+      size_in_bytes += shard_data["index"]["sizeInBytes"]
+  except:
+    label = CRITICAL_CONNECTION_MESSAGE.format(query, traceback.format_exc())
+    return (RESULT_CODE_CRITICAL, [label])
+
+  size_in_gb = float(size_in_bytes) / float(1024 * 1024 * 1024)
+  label = MESSAGE.format(size_in_gb)
+  if size_in_gb <= solr_index_size_warning:
+    result_code = RESULT_CODE_OK
+  elif size_in_gb <= solr_index_size_critical:
+    result_code = RESULT_CODE_WARNING
+  else:
+    result_code = RESULT_CODE_CRITICAL
+
+  return (result_code, [label])

http://git-wip-us.apache.org/repos/asf/ambari/blob/5fc46180/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_memory_usage.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_memory_usage.py
b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_memory_usage.py
new file mode 100644
index 0000000..b36af34
--- /dev/null
+++ b/ambari-server/src/main/resources/common-services/LOGSEARCH/0.5.0/package/alerts/alert_solr_memory_usage.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python
+
+"""
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+"""
+
+import traceback
+import urllib2
+import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json
module and has the same functions set.
+
+RESULT_CODE_OK = 'OK'
+RESULT_CODE_WARNING = 'WARNING'
+RESULT_CODE_CRITICAL = 'CRITICAL'
+RESULT_CODE_UNKNOWN = 'UNKNOWN'
+
+SOLR_PORT = '{{logsearch-solr-env/logsearch_solr_port}}'
+
+MESSAGE = 'Memory usage is {0:.1%}'
+
+SOLR_MEMORY_USAGE_WARNING_KEY = 'solr.memory.usage.warning'
+SOLR_MEMORY_USAGE_WARNING_DEFAULT = 200
+
+SOLR_MEMORY_USAGE_CRITICAL_KEY = 'solr.memory.usage.critical'
+SOLR_MEMORY_USAGE_CRITICAL_DEFAULT = 250
+
+CRITICAL_CONNECTION_MESSAGE = 'Could not execute query {0}\n{1}'
+
+def get_tokens():
+  """
+  Returns a tuple of tokens in the format {{site/property}} that will be used
+  to build the dictionary passed into execute
+  """
+  return (SOLR_PORT,)
+
+
+def execute(configurations={}, parameters={}, host_name=None):
+  """
+  Returns a tuple containing the result code and a pre-formatted result label
+
+  Keyword arguments:
+  configurations (dictionary): a mapping of configuration key to value
+  parameters (dictionary): a mapping of script parameter key to value
+  host_name (string): the name of this host where the alert is running
+  """
+
+  if configurations is None:
+    return (RESULT_CODE_UNKNOWN, ['There were no configurations supplied to the script.'])
+
+  if SOLR_PORT in configurations:
+    solr_port = configurations[SOLR_PORT]
+  else:
+    return (RESULT_CODE_UNKNOWN, ['No Solr port specified'])
+
+  # parse script arguments
+  solr_memory_usage_warning = SOLR_MEMORY_USAGE_WARNING_DEFAULT
+  if SOLR_MEMORY_USAGE_WARNING_KEY in parameters:
+    solr_memory_usage_warning = float(parameters[SOLR_MEMORY_USAGE_WARNING_KEY])
+
+  solr_memory_usage_critical = SOLR_MEMORY_USAGE_CRITICAL_DEFAULT
+  if SOLR_MEMORY_USAGE_CRITICAL_KEY in parameters:
+    solr_memory_usage_critical = float(parameters[SOLR_MEMORY_USAGE_CRITICAL_KEY])
+
+
+  try:
+    query = "http://localhost:" + str(solr_port) + "/solr/admin/cores?action=STATUS&indexInfo=false&wt=json"
+    shard_response = urllib2.urlopen(query)
+    shard_raw_data = shard_response.read()
+    shard_json_data = json.loads(shard_raw_data)
+
+    shard_name = shard_json_data["status"].keys()[0]
+    query = "http://localhost:" + str(solr_port) + "/solr/" + shard_name + "/admin/system?wt=json"
+    shard_details_response = urllib2.urlopen(query)
+    shard_details_raw_data = shard_details_response.read()
+    shard_details_json_data = json.loads(shard_details_raw_data)
+    memory_percent = shard_details_json_data["jvm"]["memory"]["raw"]["used%"]
+  except:
+    label = CRITICAL_CONNECTION_MESSAGE.format(query, traceback.format_exc())
+    return (RESULT_CODE_CRITICAL, [label])
+
+  memory_load = memory_percent / 100.0
+  label = MESSAGE.format(memory_load)
+  if memory_percent <= solr_memory_usage_warning:
+    result_code = RESULT_CODE_OK
+  elif memory_percent <= solr_memory_usage_critical:
+    result_code = RESULT_CODE_WARNING
+  else:
+    result_code = RESULT_CODE_CRITICAL
+
+  return (result_code, [label])


Mime
View raw message