From ea9f474ab3d5b2f91f4fd460321cca80b0349b33 Mon Sep 17 00:00:00 2001
From: Omer Levi Hevroni <omerlh@users.noreply.github.com>
Date: Mon, 6 Apr 2020 12:15:09 +0300
Subject: [PATCH] Allow to configure EKS available IPs alert

---
 jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet b/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet
index d04a3eed..1c21a93a 100644
--- a/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet
+++ b/jsonnet/kube-prometheus/kube-prometheus-eks.libsonnet
@@ -3,6 +3,12 @@ local service = k.core.v1.service;
 local servicePort = k.core.v1.service.mixin.spec.portsType;
 
 {
+  _config+:: {
+    eks: {
+      minimumAvailableIPs: 10,
+      minimumAvailableIPsTime: '10m'
+    }
+  }
   prometheus+: {
     serviceMonitorCoreDNS+: {
         spec+: {
@@ -59,14 +65,14 @@ local servicePort = k.core.v1.service.mixin.spec.portsType;
         name: 'kube-prometheus-eks.rules',
         rules: [
           {
-            expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < 10',
+            expr: 'sum by(instance) (awscni_total_ip_addresses) - sum by(instance) (awscni_assigned_ip_addresses) < %s' % $._config.eks.minimumAvailableIPs,
             labels: {
               severity: 'critical',
             },
             annotations: {
               message: 'Instance {{ $labels.instance }} has less than 10 IPs available.'
             },
-            'for': '10m',
+            'for': $._config.eks.minimumAvailableIPsTime,
             alert: 'EksAvailableIPs'
           },
         ],
-- 
GitLab