Skip to content

Commit

Permalink
adding service monitors and fixing mistake on discoverable alertmanager
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Horvath <tyler.horvath@gmail.com>
  • Loading branch information
ts-mini committed Nov 9, 2020
1 parent 304a311 commit 36f0d5e
Show file tree
Hide file tree
Showing 14 changed files with 490 additions and 1 deletion.
44 changes: 44 additions & 0 deletions README.md
Expand Up @@ -109,6 +109,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| alertmanager.securityContext | object | `{}` | |
| alertmanager.service.annotations | object | `{}` | |
| alertmanager.service.labels | object | `{}` | |
| alertmanager.serviceMonitor.additionalLabels | object | `{}` | |
| alertmanager.serviceMonitor.annotations | object | `{}` | |
| alertmanager.serviceMonitor.enabled | bool | `false` | |
| alertmanager.serviceMonitor.interval | string | `""` | |
| alertmanager.statefulSet.enabled | bool | `false` | |
| alertmanager.statefulStrategy.type | string | `"RollingUpdate"` | |
| alertmanager.strategy.rollingUpdate.maxSurge | int | `0` | |
Expand Down Expand Up @@ -160,6 +164,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| compactor.securityContext | object | `{}` | |
| compactor.service.annotations | object | `{}` | |
| compactor.service.labels | object | `{}` | |
| compactor.serviceMonitor.additionalLabels | object | `{}` | |
| compactor.serviceMonitor.annotations | object | `{}` | |
| compactor.serviceMonitor.enabled | bool | `false` | |
| compactor.serviceMonitor.interval | string | `""` | |
| compactor.strategy.type | string | `"RollingUpdate"` | |
| compactor.terminationGracePeriodSeconds | int | `240` | |
| compactor.tolerations | list | `[]` | |
Expand Down Expand Up @@ -249,6 +257,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| configs.securityContext | object | `{}` | |
| configs.service.annotations | object | `{}` | |
| configs.service.labels | object | `{}` | |
| configs.serviceMonitor.additionalLabels | object | `{}` | |
| configs.serviceMonitor.annotations | object | `{}` | |
| configs.serviceMonitor.enabled | bool | `false` | |
| configs.serviceMonitor.interval | string | `""` | |
| configs.strategy.rollingUpdate.maxSurge | int | `0` | |
| configs.strategy.rollingUpdate.maxUnavailable | int | `1` | |
| configs.strategy.type | string | `"RollingUpdate"` | |
Expand Down Expand Up @@ -292,6 +304,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| distributor.securityContext | object | `{}` | |
| distributor.service.annotations | object | `{}` | |
| distributor.service.labels | object | `{}` | |
| distributor.serviceMonitor.additionalLabels | object | `{}` | |
| distributor.serviceMonitor.annotations | object | `{}` | |
| distributor.serviceMonitor.enabled | bool | `false` | |
| distributor.serviceMonitor.interval | string | `""` | |
| distributor.strategy.rollingUpdate.maxSurge | int | `0` | |
| distributor.strategy.rollingUpdate.maxUnavailable | int | `1` | |
| distributor.strategy.type | string | `"RollingUpdate"` | |
Expand Down Expand Up @@ -345,6 +361,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| ingester.securityContext | object | `{}` | |
| ingester.service.annotations | object | `{}` | |
| ingester.service.labels | object | `{}` | |
| ingester.serviceMonitor.additionalLabels | object | `{}` | |
| ingester.serviceMonitor.annotations | object | `{}` | |
| ingester.serviceMonitor.enabled | bool | `false` | |
| ingester.serviceMonitor.interval | string | `""` | |
| ingester.statefulSet.enabled | bool | `false` | |
| ingester.statefulStrategy.type | string | `"RollingUpdate"` | |
| ingester.strategy.rollingUpdate.maxSurge | int | `0` | |
Expand Down Expand Up @@ -461,6 +481,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| querier.securityContext | object | `{}` | |
| querier.service.annotations | object | `{}` | |
| querier.service.labels | object | `{}` | |
| querier.serviceMonitor.additionalLabels | object | `{}` | |
| querier.serviceMonitor.annotations | object | `{}` | |
| querier.serviceMonitor.enabled | bool | `false` | |
| querier.serviceMonitor.interval | string | `""` | |
| querier.strategy.rollingUpdate.maxSurge | int | `0` | |
| querier.strategy.rollingUpdate.maxUnavailable | int | `1` | |
| querier.strategy.type | string | `"RollingUpdate"` | |
Expand Down Expand Up @@ -499,6 +523,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| query_frontend.securityContext | object | `{}` | |
| query_frontend.service.annotations | object | `{}` | |
| query_frontend.service.labels | object | `{}` | |
| query_frontend.serviceMonitor.additionalLabels | object | `{}` | |
| query_frontend.serviceMonitor.annotations | object | `{}` | |
| query_frontend.serviceMonitor.enabled | bool | `false` | |
| query_frontend.serviceMonitor.interval | string | `""` | |
| query_frontend.strategy.rollingUpdate.maxSurge | int | `0` | |
| query_frontend.strategy.rollingUpdate.maxUnavailable | int | `1` | |
| query_frontend.strategy.type | string | `"RollingUpdate"` | |
Expand Down Expand Up @@ -535,6 +563,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| ruler.securityContext | object | `{}` | |
| ruler.service.annotations | object | `{}` | |
| ruler.service.labels | object | `{}` | |
| ruler.serviceMonitor.additionalLabels | object | `{}` | |
| ruler.serviceMonitor.annotations | object | `{}` | |
| ruler.serviceMonitor.enabled | bool | `false` | |
| ruler.serviceMonitor.interval | string | `""` | |
| ruler.strategy.rollingUpdate.maxSurge | int | `0` | |
| ruler.strategy.rollingUpdate.maxUnavailable | int | `1` | |
| ruler.strategy.type | string | `"RollingUpdate"` | |
Expand All @@ -543,6 +575,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| serviceAccount.annotations | object | `{}` | |
| serviceAccount.create | bool | `true` | |
| serviceAccount.name | string | `nil` | |
| serviceMonitor.additionalLabels | object | `{}` | |
| serviceMonitor.annotations | object | `{}` | |
| serviceMonitor.enabled | bool | `false` | |
| serviceMonitor.interval | string | `""` | |
| store_gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].key | string | `"target"` | |
| store_gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].operator | string | `"In"` | |
| store_gateway.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecution[0].podAffinityTerm.labelSelector.matchExpressions[0].values[0] | string | `"store-gateway"` | |
Expand Down Expand Up @@ -585,6 +621,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| store_gateway.securityContext | object | `{}` | |
| store_gateway.service.annotations | object | `{}` | |
| store_gateway.service.labels | object | `{}` | |
| store_gateway.serviceMonitor.additionalLabels | object | `{}` | |
| store_gateway.serviceMonitor.annotations | object | `{}` | |
| store_gateway.serviceMonitor.enabled | bool | `false` | |
| store_gateway.serviceMonitor.interval | string | `""` | |
| store_gateway.strategy.type | string | `"RollingUpdate"` | |
| store_gateway.terminationGracePeriodSeconds | int | `240` | |
| store_gateway.tolerations | list | `[]` | |
Expand Down Expand Up @@ -617,6 +657,10 @@ Source code can be found [here](https://cortexmetrics.io/)
| table_manager.securityContext | object | `{}` | |
| table_manager.service.annotations | object | `{}` | |
| table_manager.service.labels | object | `{}` | |
| table_manager.serviceMonitor.additionalLabels | object | `{}` | |
| table_manager.serviceMonitor.annotations | object | `{}` | |
| table_manager.serviceMonitor.enabled | bool | `false` | |
| table_manager.serviceMonitor.interval | string | `""` | |
| table_manager.strategy.rollingUpdate.maxSurge | int | `0` | |
| table_manager.strategy.rollingUpdate.maxUnavailable | int | `1` | |
| table_manager.strategy.type | string | `"RollingUpdate"` | |
Expand Down
34 changes: 34 additions & 0 deletions templates/alertmanager-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.alertmanager.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-alertmanager
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.alertmanager.serviceMonitor.additionalLabels }}
{{ toYaml .Values.alertmanager.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.alertmanager.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.alertmanager.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-alertmanager
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.alertmanager.serviceMonitor.interval }}
interval: {{ .Values.alertmanager.serviceMonitor.interval }}
{{- end }}
{{- if .Values.alertmanager.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.alertmanager.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
10 changes: 9 additions & 1 deletion templates/alertmanager-statefulset.yaml
Expand Up @@ -19,7 +19,7 @@ spec:
app: {{ template "cortex.name" . }}-alertmanager
release: {{ .Release.Name }}
updateStrategy:
{{- toYaml .Values.alertmanager.statefulStrategy | nindent 4 }}
{{- toYaml .Values.alertmanager.statefulStrategy | nindent 4 }}
serviceName: {{ template "cortex.fullname" . }}-alertmanager
{{- if .Values.alertmanager.persistentVolume.enabled }}
volumeClaimTemplates:
Expand Down Expand Up @@ -85,6 +85,8 @@ spec:
{{- toYaml .Values.alertmanager.tolerations | nindent 8 }}
terminationGracePeriodSeconds: {{ .Values.alertmanager.terminationGracePeriodSeconds }}
volumes:
- emptyDir: {}
name: tmp
- name: config
secret:
{{- if .Values.useExternalConfig }}
Expand Down Expand Up @@ -112,7 +114,11 @@ spec:
- "-alertmanager.configs.url=http://{{ template "cortex.fullname" . }}-configs.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.config.server.http_listen_port }}"
{{- if gt (.Values.alertmanager.replicas | int) 1 }}
{{- range $n := until (.Values.alertmanager.replicas |int ) }}
<<<<<<< HEAD
- -cluster.peer={{ template "cortex.fullname" $ }}-alertmanager-{{ $n }}.{{ template "cortex.fullname" $ }}-alertmanager-headless.{{ $.Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ $clusterPort }}
=======
- -cluster.peer={{ template "cortex.fullname" $ }}-alertmanager-{{ $n }}.{{ template "cortex.fullname" $ }}-alertmanager.{{ $.Release.Namespace }}.svc.cluster.local:{{ $clusterPort }}
>>>>>>> e3b2884 (I messed up)
{{- end }}
{{- end }}
{{- range $key, $value := .Values.alertmanager.extraArgs }}
Expand All @@ -124,6 +130,8 @@ spec:
{{- end }}
- name: config
mountPath: /etc/cortex
- mountPath: /tmp
name: tmp
- name: storage
mountPath: "/data"
{{- if .Values.alertmanager.persistentVolume.subPath }}
Expand Down
34 changes: 34 additions & 0 deletions templates/compactor-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.compactor.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-compactor
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.compactor.serviceMonitor.additionalLabels }}
{{ toYaml .Values.compactor.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.compactor.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.compactor.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-compactor
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.compactor.serviceMonitor.interval }}
interval: {{ .Values.compactor.serviceMonitor.interval }}
{{- end }}
{{- if .Values.compactor.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.compactor.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions templates/compactor-svc.yaml
@@ -0,0 +1,25 @@
apiVersion: v1
kind: Service
metadata:
name: {{ template "cortex.fullname" . }}-compactor
namespace: {{ .Release.Namespace }}
labels:
app: {{ template "cortex.name" . }}-compactor
chart: {{ template "cortex.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- with .Values.compactor.service.labels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- toYaml .Values.compactor.service.annotations | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.config.server.http_listen_port }}
protocol: TCP
name: http-metrics
targetPort: http-metrics
selector:
app: {{ template "cortex.name" . }}-compactor
release: {{ .Release.Name }}
34 changes: 34 additions & 0 deletions templates/configs-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.configs.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-configs
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.configs.serviceMonitor.additionalLabels }}
{{ toYaml .Values.configs.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.configs.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.configs.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-configs
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.configs.serviceMonitor.interval }}
interval: {{ .Values.configs.serviceMonitor.interval }}
{{- end }}
{{- if .Values.configs.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.configs.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/distributor-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.distributor.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-distributor
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.distributor.serviceMonitor.additionalLabels }}
{{ toYaml .Values.distributor.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.distributor.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.distributor.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-distributor
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.distributor.serviceMonitor.interval }}
interval: {{ .Values.distributor.serviceMonitor.interval }}
{{- end }}
{{- if .Values.distributor.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.distributor.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions templates/ingester-servicemonitor.yaml
@@ -0,0 +1,34 @@
{{- if .Values.ingester.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "cortex.fullname" . }}-ingester
labels:
app: {{ template "cortex.name" . }}
chart: {{ template "cortex.chart" . }}
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
{{- if .Values.ingester.serviceMonitor.additionalLabels }}
{{ toYaml .Values.ingester.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
{{- if .Values.ingester.serviceMonitor.annotations }}
annotations:
{{ toYaml .Values.ingester.serviceMonitor.annotations | indent 4 }}
{{- end }}
spec:
selector:
matchLabels:
app: {{ template "cortex.name" . }}-ingester
release: {{ .Release.Name | quote }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace | quote }}
endpoints:
- port: http-metrics
{{- if .Values.ingester.serviceMonitor.interval }}
interval: {{ .Values.ingester.serviceMonitor.interval }}
{{- end }}
{{- if .Values.ingester.serviceMonitor.scrapeTimeout }}
scrapeTimeout: {{ .Values.ingester.serviceMonitor.scrapeTimeout }}
{{- end }}
{{- end }}

0 comments on commit 36f0d5e

Please sign in to comment.