From 6d88688be6686a2afc7ea1f80bdef51a2ee6db9f Mon Sep 17 00:00:00 2001 From: CarlosEDP Date: Fri, 22 Mar 2019 16:03:59 -0300 Subject: [PATCH] Join Elasticsearch monitor and rules files --- elasticsearch_exporter.jsonnet | 45 +++++++++++++++++++++++++++++++++- elasticsearch_rules.jsonnet | 44 --------------------------------- 2 files changed, 44 insertions(+), 45 deletions(-) delete mode 100644 elasticsearch_rules.jsonnet diff --git a/elasticsearch_exporter.jsonnet b/elasticsearch_exporter.jsonnet index 5c61611..6313022 100644 --- a/elasticsearch_exporter.jsonnet +++ b/elasticsearch_exporter.jsonnet @@ -138,4 +138,47 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet'; }, }, }, -} + (import 'elasticsearch_rules.jsonnet') + // Add Prometheus monitoring rules for ElasticSearch + prometheusRules+:: { + groups+: [ + { + name: 'elasticsearch-k8s-rules', + rules: [ + { + expr: '100 * (elasticsearch_filesystem_data_size_bytes - elasticsearch_filesystem_data_free_bytes) / elasticsearch_filesystem_data_size_bytes', + record: 'elasticsearch_filesystem_data_used_percent', + }, + { + expr: '100 - elasticsearch_filesystem_data_used_percent', + record: 'elasticsearch_filesystem_data_free_percent', + }, + + { + expr: 'elasticsearch_cluster_health_number_of_nodes < 3', + alert: 'ElasticsearchTooFewNodesRunning', + 'for': '5m', + annotations: { + message: 'There are only {{$value}} < 3 ElasticSearch nodes running', + summary: 'ElasticSearch running on less than 3 nodes', + }, + labels: { + severity: 'critical', + }, + }, + { + expr: 'elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"} > 0.9', + alert: 'ElasticsearchHeapTooHigh', + 'for': '15m', + annotations: { + message: 'The heap usage is over 90% for 15m', + summary: 'ElasticSearch node {{$labels.node}} heap usage is high', + }, + labels: { + severity: 'critical', + }, + }, + ], + }, + ], + }, +} diff --git a/elasticsearch_rules.jsonnet b/elasticsearch_rules.jsonnet deleted file mode 100644 index 550a15b..0000000 --- a/elasticsearch_rules.jsonnet +++ /dev/null @@ -1,44 +0,0 @@ -{ - prometheusRules+:: { - groups+: [ - { - name: 'elasticsearch-k8s-rules', - rules: [ - { - expr: '100 * (elasticsearch_filesystem_data_size_bytes - elasticsearch_filesystem_data_free_bytes) / elasticsearch_filesystem_data_size_bytes', - record: 'elasticsearch_filesystem_data_used_percent', - }, - { - expr: '100 - elasticsearch_filesystem_data_used_percent', - record: 'elasticsearch_filesystem_data_free_percent', - }, - - { - expr: 'elasticsearch_cluster_health_number_of_nodes < 3', - alert: 'ElasticsearchTooFewNodesRunning', - 'for': '5m', - annotations: { - message: 'There are only {{$value}} < 3 ElasticSearch nodes running', - summary: 'ElasticSearch running on less than 3 nodes', - }, - labels: { - severity: 'critical', - }, - }, - { - expr: 'elasticsearch_jvm_memory_used_bytes{area="heap"} / elasticsearch_jvm_memory_max_bytes{area="heap"} > 0.9', - alert: 'ElasticsearchHeapTooHigh', - 'for': '15m', - annotations: { - message: 'The heap usage is over 90% for 15m', - summary: 'ElasticSearch node {{$labels.node}} heap usage is high', - }, - labels: { - severity: 'critical', - }, - }, - ], - }, - ], - }, -}