Skip to content

Commit

Permalink
feat(sentry): adding statsd backend + prometheus-operator support (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
ts-mini authored Jul 9, 2020
1 parent e74f7f9 commit 7daee19
Show file tree
Hide file tree
Showing 7 changed files with 260 additions and 8 deletions.
2 changes: 1 addition & 1 deletion sentry/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: sentry
description: A Helm chart for Kubernetes
type: application
version: 4.0.0
version: 4.1.0
appVersion: 10.0.0
dependencies:
- name: redis
Expand Down
38 changes: 35 additions & 3 deletions sentry/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
### Upgrading from deprecated 9.0 -> 10.0 Chart
As this chart runs in helm 3 and also tries its best to follow on from the original Sentry chart. There are some steps that needs to be taken in order to correctly upgrade.
As this chart runs in helm 3 and also tries its best to follow on from the original Sentry chart. There are some steps that needs to be taken in order to correctly upgrade.

From the previous upgrade, make sure to get the following from your previous installation:
- Redis Password (If Redis auth was enabled)
- Postgresql Password
- Postgresql Password
Both should be in the `secrets` of your original 9.0 release. Make a note of both of these values.

#### Upgrade Steps
Expand All @@ -22,4 +22,36 @@ If Redis auth enabled:
> helm upgrade -n <Sentry namespace> <Sentry Release> . --set redis.usePassword=true --set redis.password=<Redis Password>
If Redis auth is disabled:
> helm upgrade -n <Sentry namespace> <Sentry Release> .
> helm upgrade -n <Sentry namespace> <Sentry Release> .
## Configuration

The following table lists the configurable parameters of the Sentry chart and their default values.

Parameter | Description | Default
:--------------------------------- | :--------------------------------------------------------------------------------------------------------- | :---------------------------------------------------
`user.create` | if `true`, creates a default admin user defined from `email` and `password` | `true`
`user.email` | Admin user email | `admin@sentry.local`
`user.password` | Admin user password| `aaaa`
`metrics.enabled`| if `true`, enable Prometheus metrics | `false`
`metrics.image.repository` | Metrics exporter image repository | `prom/statsd-exporter`
`metrics.image.tag` | Metrics exporter image tag | `v0.10.5`
`metrics.image.PullPolicy` | Metrics exporter image pull policy | `IfNotPresent`
`metrics.nodeSelector`| Node labels for metrics pod assignment| `{}`
`metrics.tolerations` | Toleration labels for metrics pod assignment| `[]`
`metrics.affinity` | Affinity settings for metrics | `{}`
`metrics.resources`| Metrics resource requests/limit| `{}`
`metrics.service.annotations` | annotations for Prometheus metrics service | `{}`
`metrics.service.clusterIP` | cluster IP address to assign to service (set to `"-"` to pass an empty value) | `nil`
`metrics.service.omitClusterIP` | (Deprecated) To omit the `clusterIP` from the metrics service | `false`
`metrics.service.externalIPs` | Prometheus metrics service external IP addresses | `[]`
`metrics.service.additionalLabels` | labels for metrics service | `{}`
`metrics.service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""`
`metrics.service.loadBalancerSourceRanges` | list of IP CIDRs allowed access to load balancer (if supported) | `[]`
`metrics.service.servicePort` | Prometheus metrics service port | `9913`
`metrics.service.type` | type of Prometheus metrics service to create | `ClusterIP`
`metrics.serviceMonitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false`
`metrics.serviceMonitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | `{}`
`metrics.serviceMonitor.honorLabels` | honorLabels chooses the metric's labels on collisions with target labels. | `false`
`metrics.serviceMonitor.namespace` | namespace where servicemonitor resource should be created | `the same namespace as sentry`
`metrics.serviceMonitor.scrapeInterval` | interval between Prometheus scraping | `30s`
12 changes: 10 additions & 2 deletions sentry/templates/configmap-sentry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ data:
# See https://docs.getsentry.com/on-premise/server/queue/ for more
# information on configuring your queue broker and workers. Sentry relies
# on a Python framework called Celery to manage queues.
{{- if or (.Values.rabbitmq.enabled) (.Values.rabbitmq.host) }}
BROKER_URL = os.environ.get("BROKER_URL", "amqp://{{ .Values.rabbitmq.rabbitmqUsername }}:{{ .Values.rabbitmq.rabbitmqPassword }}@{{ template "sentry.rabbitmq.host" . }}:5672//")
{{- else if $redisPass }}
BROKER_URL = os.environ.get("BROKER_URL", "redis://:{{ $redisPass }}@{{ $redisHost }}:{{ $redisPort }}/0")
{{- else }}
BROKER_URL = os.environ.get("BROKER_URL", "redis://{{ $redisHost }}:{{ $redisPort }}/0")
{{- end }}
#########
# Cache #
#########
Expand Down Expand Up @@ -329,4 +329,12 @@ data:
# BITBUCKET_CONSUMER_KEY = 'YOUR_BITBUCKET_CONSUMER_KEY'
# BITBUCKET_CONSUMER_SECRET = 'YOUR_BITBUCKET_CONSUMER_SECRET'
{{- if .Values.metrics.enabled }}
SENTRY_METRICS_BACKEND = 'sentry.metrics.statsd.StatsdMetricsBackend'
SENTRY_METRICS_OPTIONS = {
'host': '{{ template "sentry.fullname" . }}-metrics',
'port': 9125,
}
{{- end }}

{{ .Values.config.sentryConfPy | indent 4 }}
85 changes: 85 additions & 0 deletions sentry/templates/deployment-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{{- if .Values.metrics.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ template "sentry.fullname" . }}-metrics
labels:
app: {{ template "sentry.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
spec:
selector:
matchLabels:
app: {{ template "sentry.fullname" . }}-metrics
release: "{{ .Release.Name }}"
role: metrics
replicas: 1
template:
metadata:
annotations:
checksum/configYml: {{ .Values.config.configYml | sha256sum }}
checksum/sentryConfPy: {{ .Values.config.sentryConfPy | sha256sum }}
checksum/config.yaml: {{ include (print $.Template.BasePath "/configmap-sentry.yaml") . | sha256sum }}
{{- if .Values.sentry.web.annotations }}
{{ toYaml .Values.sentry.web.annotations | indent 8 }}
{{- end }}
labels:
app: {{ template "sentry.fullname" . }}-metrics
release: "{{ .Release.Name }}"
role: metrics
spec:
{{- if .Values.metrics.affinity }}
affinity:
{{ toYaml .Values.metrics.affinity | indent 8 }}
{{- end }}
{{- if .Values.metrics.nodeSelector }}
nodeSelector:
{{ toYaml .Values.metrics.nodeSelector | indent 8 }}
{{- end }}
{{- if .Values.metrics.tolerations }}
tolerations:
{{ toYaml .Values.metrics.tolerations | indent 8 }}
{{- end }}
{{- if .Values.metrics.schedulerName }}
schedulerName: "{{ .Values.metrics.schedulerName }}"
{{- end }}
containers:
- name: {{ .Chart.Name }}-metrics
args:
- "--statsd.listen-udp=:9125"
- "--web.listen-address=:9102"
image: "{{ .Values.metrics.image.repository }}:{{ .Values.metrics.image.tag }}"
imagePullPolicy: {{ .Values.metrics.image.pullPolicy }}
ports:
- name: statsd
containerPort: 9125
- name: metrics
containerPort: 9102
{{- if .Values.metrics.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /metrics
port: 9102
scheme: HTTP
initialDelaySeconds: {{ .Values.metrics.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.livenessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.livenessProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.livenessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.livenessProbe.failureThreshold }}
{{- end }}
{{- if .Values.metrics.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /metrics
port: 9102
scheme: HTTP
initialDelaySeconds: {{ .Values.metrics.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.metrics.readinessProbe.periodSeconds }}
timeoutSeconds: {{ .Values.metrics.readinessProbe.timeoutSeconds }}
successThreshold: {{ .Values.metrics.readinessProbe.successThreshold }}
failureThreshold: {{ .Values.metrics.readinessProbe.failureThreshold }}
{{- end }}
resources:
{{ toYaml .Values.metrics.resources | indent 10 }}
{{- end }}
30 changes: 30 additions & 0 deletions sentry/templates/service-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if .Values.metrics.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ template "sentry.fullname" . }}-metrics
labels:
app: {{ template "sentry.fullname" . }}-metrics
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
role: metrics
{{- if .Values.metrics.service.additionalLabels }}
{{ toYaml .Values.metrics.service.additionalLabels | indent 4 }}
{{- end }}
spec:
type: {{ .Values.metrics.service.type }}
ports:
- port: 9102
targetPort: 9102
protocol: TCP
name: metrics
- port: 9125
targetPort: 9125
protocol: UDP
name: statsd
selector:
app: {{ template "sentry.fullname" . }}-metrics
release: {{ .Release.Name }}
role: metrics
{{- end }}
37 changes: 37 additions & 0 deletions sentry/templates/servicemonitor-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ template "sentry.fullname" . }}-metrics
{{- if .Values.metrics.serviceMonitor.namespace }}
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
{{- end }}
labels:
app: {{ template "sentry.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
{{ toYaml .Values.metrics.serviceMonitor.additionalLabels | indent 4 }}
{{- end }}
spec:
endpoints:
- port: metrics
interval: {{ .Values.metrics.serviceMonitor.scrapeInterval }}
{{- if .Values.metrics.serviceMonitor.honorLabels }}
honorLabels: true
{{- end }}
{{- if .Values.metrics.serviceMonitor.namespaceSelector }}
namespaceSelector:
{{ toYaml .Values.metrics.serviceMonitor.namespaceSelector | indent 4 -}}
{{ else }}
namespaceSelector:
matchNames:
- {{ .Release.Namespace }}
{{- end }}
selector:
matchLabels:
app: {{ template "sentry.fullname" . }}-metrics
release: "{{ .Release.Name }}"
role: metrics
{{- end }}
64 changes: 62 additions & 2 deletions sentry/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ externalPostgresql:
# sslMode: require

rabbitmq:
## If disabled, Redis will be used instead as the broker.
## If disabled, Redis will be used instead as the broker.
enabled: true
forceBoot: true
replicaCount: 3
Expand Down Expand Up @@ -384,4 +384,64 @@ rabbitmq:
"ha-sync-mode": "automatic",
"ha-sync-batch-size": 1
}
}
}
## Prometheus Exporter / Metrics
##
metrics:
enabled: false

## Configure extra options for liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
livenessProbe:
enabled: true
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 3
successThreshold: 1
readinessProbe:
enabled: true
initialDelaySeconds: 30
periodSeconds: 5
timeoutSeconds: 2
failureThreshold: 3
successThreshold: 1

## Metrics exporter resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
resources: {}
# limits:
# cpu: 100m
# memory: 100Mi
# requests:
# cpu: 100m
# memory: 100Mi

nodeSelector: {}
tolerations: []
affinity: {}
# schedulerName:
# Optional extra labels for pod, i.e. redis-client: "true"
# podLabels: []
service:
type: ClusterIP
labels: {}

image:
repository: prom/statsd-exporter
tag: v0.17.0
pullPolicy: IfNotPresent

# Enable this if you're using https://github.com/coreos/prometheus-operator
serviceMonitor:
enabled: false
additionalLabels: {}
namespace: ""
namespaceSelector: {}
# Default: scrape .Release.Namespace only
# To scrape all, use the following:
# namespaceSelector:
# any: true
scrapeInterval: 30s
# honorLabels: true

0 comments on commit 7daee19

Please sign in to comment.