Added HAproxy exporter

Change-Id: I99124d11639505c76bafcfe9be622135382e3f09
This commit is contained in:
Mohammed Naser 2020-07-21 16:58:28 -04:00
parent 70655055f9
commit 7badbfad0b
7 changed files with 175 additions and 0 deletions

View File

@ -0,0 +1,11 @@
---
apiVersion: v1
name: haproxy-exporter
version: 0.3.1
description: HAProxy exporter for Prometheus
home: https://github.com/vexxhost/helm-charts
maintainers:
- name: Mohammed Naser
email: mnaser@vexxhost.com
url: https://github.com/mnaser
appVersion: v0.10.0

View File

@ -0,0 +1,45 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "haproxy-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "haproxy-exporter.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
Generate basic labels
*/}}
{{- define "haproxy-exporter.labels" }}
app.kubernetes.io/name: {{ include "haproxy-exporter.fullname" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: metrics
app.kubernetes.io/part-of: haproxy
{{- if .Values.commonLabels }}
{{ toYaml .Values.commonLabels }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "haproxy-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

View File

@ -0,0 +1,47 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
selector:
matchLabels:
{{ include "haproxy-exporter.labels" $ | indent 6 }}
template:
metadata:
labels:
{{ include "haproxy-exporter.labels" $ | indent 8 }}
spec:
containers:
- name: haproxy-exporter
image: prom/haproxy-exporter:v0.10.0
args:
- --haproxy.scrape-uri=unix:/var/run/haproxy.stat
resources:
limits:
cpu: 500m
memory: 180Mi
requests:
cpu: 250m
memory: 180Mi
volumeMounts:
- name: haproxy-socket
mountPath: /var/run/haproxy.stat
ports:
- name: metrics
containerPort: 9101
{{- with $.Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with $.Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
volumes:
- name: haproxy-socket
hostPath:
path: /var/run/haproxy.stat

View File

@ -0,0 +1,32 @@
---
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
groups:
- name: haproxy
rules:
- alert: HaproxyDown
expr: |
absent(haproxy_up == 1)
for: 1m
labels:
severity: critical
- alert: HaproxyBackendDown
for: 1m
expr: |
haproxy_backend_up != 1
labels:
severity: P2
- alert: HaproxyBackendDegraded
expr: |
avg(haproxy_server_up) by (instance, backend, server) != 1
for: 1m
labels:
severity: P3

View File

@ -0,0 +1,16 @@
---
apiVersion: v1
kind: Service
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
clusterIP: None
ports:
- name: metrics
port: 9101
targetPort: metrics
selector:
{{ include "haproxy-exporter.labels" $ | indent 4 }}

View File

@ -0,0 +1,23 @@
---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
namespace: {{ .Release.Namespace }}
name: {{ include "haproxy-exporter.fullname" . }}
labels:
{{ include "haproxy-exporter.labels" $ | indent 4 }}
spec:
endpoints:
- interval: 30s
port: metrics
relabelings:
- action: replace
regex: (.*)
replacement: ${1}:9101
sourceLabels:
- __meta_kubernetes_pod_node_name
targetLabel: instance
jobLabel: jobLabel
selector:
matchLabels:
{{ include "haproxy-exporter.labels" $ | indent 6 }}

View File

@ -0,0 +1 @@
---