Add support for metrics and pprof (#100)
Adds support for toggling support for `pprof` and metrics: ```yaml gitea: pprofEnabled: true metrics: enabled: true serviceMonitor: enabled: true ``` Co-authored-by: josef <josef.nilsen@outlook.com> Reviewed-on: gitea/helm-chart#100 Reviewed-by: luhahn <luhahn@noreply.gitea.io> Reviewed-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: JosefWN <josefwn@noreply.gitea.io> Co-committed-by: JosefWN <josefwn@noreply.gitea.io>
This commit was merged in pull request #100.
This commit is contained in:
28 README.md
28
README.md @@ -95,6 +95,16 @@ ROOT_URL = http://git.example.com | ||||
SSH_DOMAIN = git.example.com | ||||
SSH_LISTEN_PORT = 22 | ||||
SSH_PORT = 22 | ||||
ENABLE_PPROF = false | ||||
``` | ||||
| ||||
#### Metrics defaults | ||||
| ||||
The Prometheus `/metrics` endpoint is disabled by default. | ||||
| ||||
```ini | ||||
[metrics] | ||||
ENABLED = false | ||||
``` | ||||
| ||||
### External Database | ||||
@@ -278,6 +288,24 @@ kebab-case: | ||||
username-attribute: CN | ||||
``` | ||||
| ||||
### Metrics and profiling | ||||
| ||||
A Prometheus `/metrics` endpoint on the `HTTP_PORT` and `pprof` profiling endpoints on port 6060 can be enabled under `gitea`. Beware that the metrics endpoint is exposed via the ingress, manage access using ingress annotations for example. | ||||
| ||||
To deploy the `ServiceMonitor`, you first need to ensure that you have deployed `prometheus-operator` and its CRDs: https://github.com/prometheus-operator/prometheus-operator#customresourcedefinitions. | ||||
| ||||
```yaml | ||||
gitea: | ||||
metrics: | ||||
enabled: true | ||||
serviceMonitor: | ||||
enabled: true | ||||
| ||||
config: | ||||
server: | ||||
PPROF_ENABLED: true | ||||
``` | ||||
| ||||
### Pod Annotations | ||||
| ||||
Annotations can be added to the Gitea pod. | ||||
| ||||
@@ -15,6 +15,10 @@ stringData: | ||||
{{- $_ := set .Values.gitea.config "server" dict -}} | ||||
{{- end -}} | ||||
| ||||
{{- if not (hasKey .Values.gitea.config "metrics") -}} | ||||
{{- $_ := set .Values.gitea.config "metrics" dict -}} | ||||
{{- end -}} | ||||
| ||||
{{- if not (hasKey .Values.gitea.config "database") -}} | ||||
{{- $_ := set .Values.gitea.config "database" dict -}} | ||||
{{- end -}} | ||||
@@ -65,6 +69,14 @@ stringData: | ||||
{{- if not (hasKey .Values.gitea.config.server "APP_DATA_PATH") -}} | ||||
{{- $_ := set .Values.gitea.config.server "APP_DATA_PATH" "/data" -}} | ||||
{{- end -}} | ||||
{{- if not (hasKey .Values.gitea.config.server "PPROF_ENABLED") -}} | ||||
{{- $_ := set .Values.gitea.config.server "PPROF_ENABLED" false -}} | ||||
{{- end -}} | ||||
| ||||
{{- /* metrics default settings */ -}} | ||||
{{- if not (hasKey .Values.gitea.config.metrics "ENABLED") -}} | ||||
{{- $_ := set .Values.gitea.config.metrics "ENABLED" .Values.gitea.metrics.enabled -}} | ||||
{{- end -}} | ||||
| ||||
{{- /* database default settings */ -}} | ||||
{{- if .Values.gitea.database.builtIn.postgresql.enabled -}} | ||||
| ||||
14 templates/gitea/servicemonitor.yaml Normal file
14
templates/gitea/servicemonitor.yaml Normal file @@ -0,0 +1,14 @@ | ||||
{{- if .Values.gitea.metrics.serviceMonitor.enabled -}} | ||||
apiVersion: monitoring.coreos.com/v1 | ||||
kind: ServiceMonitor | ||||
metadata: | ||||
name: {{ include "gitea.fullname" . }} | ||||
labels: | ||||
{{- include "gitea.labels" . | nindent 4 }} | ||||
spec: | ||||
selector: | ||||
matchLabels: | ||||
{{- include "gitea.selectorLabels" . | nindent 6 }} | ||||
endpoints: | ||||
- port: http | ||||
{{- end -}} | ||||
@@ -66,6 +66,10 @@ spec: | ||||
containerPort: {{ .Values.gitea.config.server.SSH_LISTEN_PORT }} | ||||
- name: http | ||||
containerPort: {{ .Values.gitea.config.server.HTTP_PORT }} | ||||
{{- if .Values.gitea.config.server.PPROF_ENABLED }} | ||||
- name: profiler | ||||
containerPort: 6060 | ||||
{{- end }} | ||||
livenessProbe: | ||||
tcpSocket: | ||||
port: http | ||||
| ||||
@@ -105,6 +105,11 @@ gitea: | ||||
password: r8sA8CPHD9!bt6d | ||||
email: "gitea@local.domain" | ||||
| ||||
metrics: | ||||
enabled: false | ||||
serviceMonitor: | ||||
enabled: false | ||||
| ||||
ldap: | ||||
enabled: false | ||||
#name: | ||||
| ||||
Reference in New Issue
Block a user