Add Prometheus metrics support

This commit is contained in:
Alejandro Moreno
2019-09-25 10:18:08 +00:00
parent 3f759e0df7
commit a5c30bf379
4 changed files with 67 additions and 5 deletions

View File

@@ -69,3 +69,36 @@ data:
flush_interval 10s
</buffer>
</match>
{{- if .Values.metrics.enabled }}
metrics.conf: |
# Prometheus Exporter Plugin
# input plugin that exports metrics
<source>
@type prometheus
port {{ .Values.metrics.service.port }}
</source>
# input plugin that collects metrics from MonitorAgent
<source>
@type prometheus_monitor
<labels>
host ${hostname}
</labels>
</source>
# input plugin that collects metrics for output plugin
<source>
@type prometheus_output_monitor
<labels>
host ${hostname}
</labels>
</source>
# input plugin that collects metrics for in_tail plugin
<source>
@type prometheus_tail_monitor
<labels>
host ${hostname}
</labels>
</source>
{{- end }}

View File

@@ -49,6 +49,11 @@ spec:
- name: http
containerPort: 9880
protocol: TCP
{{- if .Values.metrics.enabled }}
- name: metrics
containerPort: {{ .Values.metrics.service.port }}
protocol: TCP
{{- end }}
livenessProbe:
httpGet:
path: /fluentd.healthcheck?json=%7B%22ping%22%3A+%22pong%22%7D

View File

@@ -5,11 +5,17 @@ metadata:
labels:
{{- include "fluentd.labels" . | nindent 4 }}
app.kubernetes.io/component: forwarder
{{- if or (and .Values.metrics.enabled .Values.metrics.service.annotations) .Values.service.annotations }}
annotations:
{{- if and .Values.metrics.enabled .Values.metrics.service.annotations }}
{{- tpl (toYaml .Values.metrics.service.annotations) $ | nindent 4 }}
{{- end }}
{{- if and .Values.service.annotations }}
{{- tpl (toYaml .Values.service.annotations) $ | nindent 4 }}
{{- end }}
{{- end }}
spec:
type: {{ .Values.service.type }}
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if eq .Values.service.type "LoadBalancer" }} {{- if .Values.service.loadBalancerIP }}
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
{{- end }} {{- end }}
@@ -17,8 +23,15 @@ spec:
ports:
- name: http
targetPort: http
protocol: TCP
port: {{ .Values.service.port }}
{{- if .Values.service.nodePort }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- if .Values.metrics.enabled }}
- name: metrics
port: {{ .Values.metrics.service.port }}
targetPort: metrics
{{- end }}
selector:
app.kubernetes.io/name: {{ include "fluentd.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}

View File

@@ -211,11 +211,22 @@ serviceAccount:
# name:
## Role Based Access
## Ref: https://kubernetes.io/docs/admin/authorization/rbac/
## ref: https://kubernetes.io/docs/admin/authorization/rbac/
##
rbac:
create: true
## Prometheus metrics
## ref: https://github.com/fluent/fluent-plugin-prometheus/blob/master/README.md
##
metrics:
enabled: false
service:
port: 24231
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "24231"
prometheus.io/path: "/metrics"
service:
type: ClusterIP