Skip to content

Commit

Permalink
Merge pull request #29 from camilb/external-url
Browse files Browse the repository at this point in the history
External url
  • Loading branch information
camilb authored Oct 5, 2017
2 parents 6325cfa + d4b37b2 commit e7fa416
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 12 deletions.
4 changes: 2 additions & 2 deletions assets/prometheus/rules/node.rules
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ groups:
summary: Node is under disk pressure.
- alert: NodeCPUUsage
expr: (100 - (avg by (instance) (irate(node_cpu{job="node-exporter",mode="idle"}[5m])) * 100)) > 80
for: 5m
for: 30m
labels:
severity: warning
annotations:
summary: "{{$labels.instance}}: High CPU usage detected"
description: "{{$labels.instance}}: CPU usage is above 85% (current value is: {{ $value }})"
- alert: NodeMemoryUsage
expr: (((node_memory_MemTotal-node_memory_MemFree-node_memory_Cached)/(node_memory_MemTotal)*100)) > 85
for: 5m
for: 30m
labels:
severity: warning
annotations:
Expand Down
37 changes: 30 additions & 7 deletions deploy
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,16 @@
GRAFANA_DEFAULT_VERSION=4.5.2
PROMETHEUS_DEFAULT_VERSION=v2.0.0-beta.5
PROMETHEUS_OPERATOR_DEFAULT_VERSION=v0.13.0
ALERT_MANAGER_DEFAULT_VERSION=v0.9.1
ALERTMANAGER_DEFAULT_VERSION=v0.9.1
NODE_EXPORTER_DEFAULT_VERSION=v0.14.0
KUBE_STATE_METRICS_DEFAULT_VERSION=v1.0.1

#########################################################################################
#external Urls for Prometheus and Alertmanager
#########################################################################################
PROMETHEUS_DEFAULT_EXTERNAL_URL=http://127.0.0.1:9090
ALERTMANAGER_DEFAULT_EXTERNAL_URL=http://127.0.0.1:9093

#########################################################################################
#environment configuration
#########################################################################################
Expand Down Expand Up @@ -58,8 +64,8 @@ GRAFANA_VERSION=${GRAFANA_VERSION:-$GRAFANA_DEFAULT_VERSION}

#Alertmanager
echo
read -p "Enter Alert Manager version [$ALERT_MANAGER_DEFAULT_VERSION]: " ALERT_MANAGER_VERSION
ALERT_MANAGER_VERSION=${ALERT_MANAGER_VERSION:-$ALERT_MANAGER_DEFAULT_VERSION}
read -p "Enter Alert Manager version [$ALERTMANAGER_DEFAULT_VERSION]: " ALERTMANAGER_VERSION
ALERTMANAGER_VERSION=${ALERTMANAGER_VERSION:-$ALERTMANAGER_DEFAULT_VERSION}

#Node Exporter
echo
Expand All @@ -71,6 +77,16 @@ echo
read -p "Enter Kube State Metrics version [$KUBE_STATE_METRICS_DEFAULT_VERSION]: " KUBE_STATE_METRICS_VERSION
KUBE_STATE_METRICS_VERSION=${KUBE_STATE_METRICS_VERSION:-$KUBE_STATE_METRICS_DEFAULT_VERSION}

#Prometheus External URL
echo
read -p "Enter Prometheus external Url [$PROMETHEUS_DEFAULT_EXTERNAL_URL]: " PROMETHEUS_EXTERNAL_URL
PROMETHEUS_EXTERNAL_URL=${PROMETHEUS_EXTERNAL_URL:-$PROMETHEUS_DEFAULT_EXTERNAL_URL}

#Alertmanager External URL
echo
read -p "Enter Alertmanager external Url [$ALERTMANAGER_DEFAULT_EXTERNAL_URL]: " ALERTMANAGER_EXTERNAL_URL
ALERTMANAGER_EXTERNAL_URL=${ALERTMANAGER_EXTERNAL_URL:-$ALERTMANAGER_DEFAULT_EXTERNAL_URL}

#set prometheus operator version
sed -i -e 's/PROMETHEUS_OPERATOR_VERSION/'"$PROMETHEUS_OPERATOR_VERSION"'/g' manifests/prometheus-operator/prometheus-operator.yaml

Expand All @@ -81,14 +97,20 @@ sed -i -e 's/PROMETHEUS_VERSION/'"$PROMETHEUS_VERSION"'/g' manifests/prometheus/
sed -i -e 's/GRAFANA_VERSION/'"$GRAFANA_VERSION"'/g' manifests/grafana/grafana.de.yaml

#set alertmanager version
sed -i -e 's/ALERT_MANAGER_VERSION/'"$ALERT_MANAGER_VERSION"'/g' manifests/alertmanager/alertmanager.yaml
sed -i -e 's/ALERTMANAGER_VERSION/'"$ALERTMANAGER_VERSION"'/g' manifests/alertmanager/alertmanager.yaml

#set node-exporter version
sed -i -e 's/NODE_EXPORTER_VERSION/'"$NODE_EXPORTER_VERSION"'/g' manifests/node-exporter/node-exporter.ds.yaml

#set node-exporter version
sed -i -e 's/KUBE_STATE_METRICS_VERSION/'"$KUBE_STATE_METRICS_VERSION"'/g' manifests/kube-state-metrics/kube-state-metrics.de.yaml

#set prometheus external url
sed -i -e 's,PROMETHEUS_EXTERNAL_URL,'"$PROMETHEUS_EXTERNAL_URL"',g' manifests/prometheus/prometheus-k8s.yaml

#set alertmanager external url
sed -i -e 's,ALERTMANAGER_EXTERNAL_URL,'"$ALERTMANAGER_EXTERNAL_URL"',g' manifests/alertmanager/alertmanager.yaml

##########################################################################################################################################
#configure alert channels
##########################################################################################################################################
Expand Down Expand Up @@ -145,6 +167,10 @@ if [[ $use_slack =~ ^([yY][eE][sS]|[yY])$ ]]; then
sed -i -e 's/your_slack_channel/'"$slack_channel"'/g' assets/alertmanager/alertmanager.yaml
fi

echo
echo -e "${BLUE}Removing all the sed generated files"
find . -name "*.yaml-e" -exec rm -rf {} \;
tput sgr0
######################################################################################################
#deploy all the components
######################################################################################################
Expand Down Expand Up @@ -234,9 +260,6 @@ kubectl apply -f manifests/k8s/self-hosted
######################################################################################################
echo
echo -e "${BLUE}Removing local changes"
#remove "sed" generated files
find . -name "*.yaml-e" -exec rm -rf {} \;

git checkout -- .

echo
Expand Down
1 change: 1 addition & 0 deletions manifests/alertmanager/alertmanager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ metadata:
spec:
replicas: 3
version: ALERT_MANAGER_VERSION
externalUrl: ALERT_MANAGER_EXTERNAL_URL
4 changes: 2 additions & 2 deletions manifests/prometheus/prometheus-k8s-rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -508,15 +508,15 @@ data:
summary: Node is under disk pressure.
- alert: NodeCPUUsage
expr: (100 - (avg by (instance) (irate(node_cpu{job="node-exporter",mode="idle"}[5m])) * 100)) > 80
for: 5m
for: 30m
labels:
severity: warning
annotations:
summary: "{{$labels.instance}}: High CPU usage detected"
description: "{{$labels.instance}}: CPU usage is above 85% (current value is: {{ $value }})"
- alert: NodeMemoryUsage
expr: (((node_memory_MemTotal-node_memory_MemFree-node_memory_Cached)/(node_memory_MemTotal)*100)) > 85
for: 5m
for: 30m
labels:
severity: warning
annotations:
Expand Down
1 change: 1 addition & 0 deletions manifests/prometheus/prometheus-k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ metadata:
spec:
replicas: 2
version: PROMETHEUS_VERSION
externalUrl: PROMETHEUS_EXTERNAL_URL
serviceAccountName: prometheus-k8s
serviceMonitorSelector:
matchExpressions:
Expand Down
2 changes: 1 addition & 1 deletion release/download
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh

PROMKUBE_VERSION=${PROMKUBE_VERSION:-v2.0.0-beta.3}
PROMKUBE_VERSION=${PROMKUBE_VERSION:-2.0.0-beta.4}

NAME="prometheus-kubernetes"

Expand Down

0 comments on commit e7fa416

Please sign in to comment.