Skip to content
This repository has been archived by the owner on Jan 11, 2021. It is now read-only.

IGNORE_PODS #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ Additionally, the following environment variables can be used:
- `TICK_RATE`: How often to update in milliseconds. (Default to 15000 or 15s)
- `FLOOD_EXPIRE`: Repeat notification after this many milliseconds has passed after status returned to normal. (Default to 60000 or 60s)
- `NOT_READY_MIN_TIME`: Time to wait after pod become not ready before notifying. (Default to 60000 or 60s)
- `IGNORE_PODS`: Comma separated list with the name prefix of the pods to ignore. Example: `kube-proxy-gke,prometheus-prometheus-node-exporter` (Default "")
- `METRICS_CPU`: Enable/disable metric alerting on cpu (Default true)
- `METRICS_MEMORY`: Enable/disable metric alerting on memory (Default true)
- `METRICS_PERCENT`: Set percentage threshold on metric alerts (Default 80)
Expand Down
1 change: 1 addition & 0 deletions config/custom-environment-variables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ metrics_requests:
__format: json
flood_expire: FLOOD_EXPIRE
not_ready_min_time: NOT_READY_MIN_TIME
ignore_pods: IGNORE_PODS

slack_url: SLACK_URL
slack_channel: SLACK_CHANNEL
Expand Down
2 changes: 2 additions & 0 deletions config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interval: 15000
flood_expire: 60000
not_ready_min_time: 60000

ignore_pods: ""

metrics_cpu: true
metrics_memory: true
metrics_alert: 80 # percent
Expand Down
16 changes: 16 additions & 0 deletions src/monitors/longnotready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {

class PodLongNotReady extends EventEmitter {
minimumTime: number;
ignorePods: string;
alerted: { [key: string]: KubernetesPod };

constructor() {
super();
this.minimumTime = parseInt(config.get('not_ready_min_time'), 10);
this.ignorePods = config.get('ignore_pods');
this.alerted = {};
}

Expand All @@ -31,9 +33,23 @@ class PodLongNotReady extends EventEmitter {

async check() {
let pods = await kube.getWatchedPods();
const ignorePods = this.ignorePods.split(',')

for (let pod of pods) {
let messageProps: Partial<NotifyMessage> = {};

// Ignore pod if exists in ingnore_pods array
let skipPod = false;
for (let ingnorePod of ignorePods) {
if (ingnorePod.length > 0 && pod.metadata.name.startsWith(ingnorePod.trim())) {
skipPod = true;
break;
}
}
if (skipPod) {
continue;
}

let annotations = pod.metadata.annotations;
if (annotations) {
// Ignore pod if the annotation is set and evaluates to true
Expand Down