I have hundreds of HAProxy instances running outside of Kubernetes and I'm planning to monitor them using HAProxy Exporter and Prometheus, both of them are deployed in Pivotal Kubernetes.
I have few questions on how to achieve this.
1)Deployed Prometheus in Kuberenetes using prom.yaml
2)Deployed HAProxy Exporter per instances. Assume, I have 2 HAP instances and I'm attaching those 2 YAMLS here. Question: Do I need to install hundreds of exporters?
3)How do I make sure that my 2 HAProxy instances- one is for retail and another for IVR channel, writes to 2 different jobs in Prometheus. Need help with ConfigMap . I'm attaching my ConfigMap here.
Please help and review if I'm doing any mistakes here. Thank you in advance.
Sen.
ConfigMap.yaml
*******************
prometheus-hap-exporter-6bd8fc9974-gblr2 1/1 Running 0 2d
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-configuration
labels:
name: prometheus-configuration
namespace: metrics-dev
data:
prometheus.yml: |-
global:
scrape_interval: 10s
scrape_configs:
- job_name: 'ivr_hap'
honor_labels: true
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- metrics-dev
- job_name: 'rtl_hap'
honor_labels: true
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- metrics-dev
---
cat rtl_prom_hap_exporter.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: rtl-prometheus-hap-exporter
namespace: metrics-dev
labels:
spec:
replicas: 1
selector:
matchLabels:
template:
metadata:
labels:
spec:
serviceAccountName: prometheus-server
containers:
- name: rtl-prometheus-exporter
args:
- "--haproxy.scrape-uri=http://admin:xxxxxx.@<rtlhaphostname>:8181/haproxy?stats;csv"
ports:
- name: rtl-prom-metrics
containerPort: 9101
---
cat ivr_prom_hap_exporter.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: ivr-prometheus-hap-exporter
namespace: metrics-dev
labels:
spec:
replicas: 1
selector:
matchLabels:
template:
metadata:
labels:
spec:
serviceAccountName: prometheus-server
containers:
- name: ivr-prometheus-exporter
args:
- "--haproxy.scrape-uri=http://admin:xxxxxxx@<ivrhaphostname>:8181/haproxy?stats;csv"
ports:
- name: ivr-prom-metrics
containerPort: 9101
---
cat prom.yaml
kind: Role
metadata:
name: prometheus-server
namespace: metrics-dev
labels:
rules:
- apiGroups: [""]
resources:
- services
- endpoints
- pods
verbs: ["get", "list", "watch"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: prometheus-server
namespace: metrics-dev
labels:
---
kind: RoleBinding
metadata:
name: prometheus-server
namespace: metrics-dev
labels:
roleRef:
kind: Role
name: prometheus-server
subjects:
- kind: ServiceAccount
name: prometheus-server
namespace: metrics-dev
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: prometheus-server
namespace: metrics-dev
labels:
spec:
replicas: 1
selector:
matchLabels:
template:
metadata:
labels:
spec:
serviceAccountName: prometheus-server
containers:
- name: prometheus
image: prom/prometheus:v2.3.2
args:
- "--config.file=/etc/prometheus/prometheus.yml"
- "--storage.tsdb.path=/prometheus/"
ports:
- containerPort: 9090
volumeMounts:
- name: prometheus-config-volume
mountPath: /etc/prometheus/
- name: prometheus-storage-volume
mountPath: /prometheus/
volumes:
- name: prometheus-config-volume
configMap:
name: prometheus-configuration
- name: prometheus-storage-volume
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: prometheus-server
namespace: metrics-dev
labels:
spec:
selector:
type: NodePort
ports:
- port: 9090
name: prometheus
targetPort: 9090
protocol: TCP
---