Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheus-statsd-exporter] add first release #449

Merged
merged 11 commits into from
Dec 8, 2020
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
/charts/prometheus-redis-exporter/ @acondrat @zanhsieh
/charts/prometheus-snmp-exporter/ @miouge1
/charts/prometheus-stackdriver-exporter/ @apenney @rpahli
/charts/prometheus-statsd-exporter/ @scDisorder
/charts/prometheus-to-sd/ @acondrat
23 changes: 23 additions & 0 deletions charts/prometheus-statsd-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
19 changes: 19 additions & 0 deletions charts/prometheus-statsd-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: prometheus-statsd-exporter
description: A Helm chart for prometheus stats-exporter
version: 0.1.0
appVersion: 0.18.0
home: https://github.com/prometheus/statsd_exporter
sources:
- https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus-statsd-exporter
annotations:
"artifacthub.io/links": |
- name: Chart Source
url: https://github.com/prometheus-community/helm-charts/blob/main/charts/prometheus-statsd-exporter
keywords:
- statsd
- prometheus
- exporter
maintainers:
- email: d@rovergulf.net
name: scDisorder
59 changes: 59 additions & 0 deletions charts/prometheus-statsd-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# prometheus-statsd-exporter

Prometheus Exporter for [Statsd](https://github.com/statsd/statsd) metrics.

This chart bootstraps a [Statsd Exporter](https://github.com/prometheus/statsd_exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.16+ with Beta APIs enabled
scDisorder marked this conversation as resolved.
Show resolved Hide resolved
- Helm 3+

## Get Repo Info

```console
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm repo update
```

_See [helm repo](https://helm.sh/docs/helm/helm_repo/) for command documentation._

## Install Chart

```console
helm install [RELEASE_NAME] prometheus-community/prometheus-statsd-exporter
```

_See [configuration](#configuration) below._

_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._

## Uninstall Chart

```console
helm uninstall [RELEASE_NAME]
```

This removes all the Kubernetes components associated with the chart and deletes the release.

_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._

## Upgrading Chart

```console
helm upgrade [RELEASE_NAME] [CHART] --install
```

_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._

## Configuring

See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands:

```console
helm show values prometheus-community/prometheus-statsd-exporter
```

### Statsd Exporter Server

- Use early created ConfigMap with file `statsd.mappingConf` contained in data or specify mapping values in `statsd.mappingConfig`
22 changes: 22 additions & 0 deletions charts/prometheus-statsd-exporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "prometheus-statsd-exporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "prometheus-statsd-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "prometheus-statsd-exporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "prometheus-statsd-exporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}
73 changes: 73 additions & 0 deletions charts/prometheus-statsd-exporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "prometheus-statsd-exporter.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "prometheus-statsd-exporter.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "prometheus-statsd-exporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "prometheus-statsd-exporter.labels" -}}
helm.sh/chart: {{ include "prometheus-statsd-exporter.chart" . }}
{{ include "prometheus-statsd-exporter.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "prometheus-statsd-exporter.selectorLabels" -}}
app.kubernetes.io/name: {{ include "prometheus-statsd-exporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "prometheus-statsd-exporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "prometheus-statsd-exporter.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Check if there is any mappings available
*/}}
{{- define "prometheus-statsd-exporter.configMapName"}}
{{- if .Values.statsd.mappingConfigMapName }}
{{ default .Values.statsd.mappingConfigMapName }}
{{- else }}
{{ template "prometheus-statsd-exporter.fullname" . }}
{{- end }}
{{- end }}
13 changes: 13 additions & 0 deletions charts/prometheus-statsd-exporter/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- if or .Values.statsd.mappingConfig }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "prometheus-statsd-exporter.fullname" . }}
labels:
{{- include "prometheus-statsd-exporter.labels" . | nindent 4 }}
data:
{{- with .Values.statsd.mappingConfig }}
statsd.mappingConf: |-
{{ . | nindent 4 }}
{{- end }}
{{- end }}
106 changes: 106 additions & 0 deletions charts/prometheus-statsd-exporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "prometheus-statsd-exporter.fullname" . }}
labels:
{{- include "prometheus-statsd-exporter.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
revisionHistoryLimit: {{ .Values.deploymentRevisionHistoryLimit | default 10 }}
{{- end }}
selector:
matchLabels:
{{- include "prometheus-statsd-exporter.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "prometheus-statsd-exporter.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "prometheus-statsd-exporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- --web.listen-address=:{{ .Values.service.port }}
- --web.telemetry-path={{ .Values.service.path }}
{{- if .Values.statsd.udpPort }}
- --statsd.listen-udp=:{{ .Values.statsd.udpPort }}
{{- else }}
- --statsd.listen-udp=
{{- end }}
{{- if .Values.statsd.tcpPort }}
- --statsd.listen-tcp=:{{ .Values.statsd.tcpPort }}
{{- else }}
- --statsd.listen-tcp=
{{- end }}
- --statsd.cache-size={{ .Values.statsd.cacheSize }}
- --statsd.event-queue-size={{ .Values.statsd.eventQueueSize }}
- --statsd.event-flush-threshold={{ .Values.statsd.eventFlushThreshold }}
- --statsd.event-flush-interval={{ .Values.statsd.eventFlushInterval }}
{{- if .Values.statsd.mappingConfig }}
- --statsd.mapping-config=/etc/prometheus-statsd-exporter/statsd-mapping.conf
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
{{- if .Values.statsd.tcpPort }}
- name: statsd-tcp
containerPort: {{ .Values.statsd.tcpPort }}
protocol: TCP
{{- end }}
{{- if .Values.statsd.udpPort }}
- name: statsd-udp
containerPort: {{ .Values.statsd.udpPort }}
protocol: UDP
{{- end }}
livenessProbe:
httpGet:
path: /metrics
port: http
readinessProbe:
httpGet:
path: /metrics
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if or .Values.statsd.mappingConfigMapName .Values.statsd.mappingConfig }}
volumeMounts:
- name: statsd-mapping-config
mountPath: /etc/prometheus-statsd-exporter
{{- end }}
{{- if or .Values.statsd.mappingConfigMapName .Values.statsd.mappingConfig }}
volumes:
- name: statsd-mapping-config
configMap:
name: {{ template "prometheus-statsd-exporter.configMapName" . }}
items:
- key: statsd.mappingConf
path: statsd-mapping.conf
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/prometheus-statsd-exporter/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "prometheus-statsd-exporter.fullname" . }}
labels:
{{- include "prometheus-statsd-exporter.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "prometheus-statsd-exporter.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
Loading