Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* text=auto
*.yml eol=lf
*.yaml eol=lf
*.sh eol=lf
*.tpl eol=lf
*.helmignore eol=lf
*.md eol=lf
*.txt eol=lf
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Azure Service Bus Prometheus exporter - Helm Chart

This is a fork from https://github.com/marcinbudny/servicebus_exporter, just for the Helm Chart.

See [the chart readme](https://github.com/giggio/servicebus_exporter/blob/helmchart/charts/servicebusexporter/README.md).

# Azure Service Bus Prometheus exporter
Azure Service Bus metrics Prometheus exporter. Does not use Azure Monitor, connects to the Service Bus directly and scrapes all queues, topics and subscriptions.

Expand Down
22 changes: 22 additions & 0 deletions charts/servicebusexporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
11 changes: 11 additions & 0 deletions charts/servicebusexporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
appVersion: "0.1.0"
description: Azure Service Bus exporter for Prometheus
name: servicebusexporter
version: 0.0.1
home: https://github.com/giggio/servicebus_exporter
sources:
- https://github.com/giggio/servicebus_exporter
maintainers:
- name: giggio
email: giggio@giggio.net
113 changes: 113 additions & 0 deletions charts/servicebusexporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Azure Service Bus Prometheus exporter

Azure Service Bus metrics Prometheus exporter. Does not use Azure Monitor,
connects to the Service Bus directly and scrapes all queues, topics and
subscriptions.

## TL;DR;

```console
$ helm repo add sbe https://giggio.github.io/servicebus_exporter/
$ helm repo update
$ helm install sbe/servicebusexporter
```

## Introduction

This chart bootstraps a [Azure Service Bus Prometheus exporter](https://github.com/marcinbudny/servicebus_exporter) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.12+
- Helm 2.11+ or Helm 3.0-beta3+

## Add the repo

Add the help repo:

```console
$ helm repo add sbe https://giggio.github.io/servicebus_exporter/
$ helm repo update
```

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm install --name my-release sbe/servicebusexporter
```

The command deploys Azure Service Bus Prometheus exporter on the Kubernetes cluster in the default configuration. The [Parameters](#parameters) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`

## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release --purge
```

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

## Parameters

The following table lists the configurable parameters of the Azure Service Bus Prometheus exporter chart and their default values.

| Parameter | Description | Default |
| ----------------------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------------ |
| `connectionString` | Connection string for Azure Service Bus. The exporter requires `Manage` SAS policy. | `nil` (required) |
| `timeout` | Timeout when scraping the Service Bus | `30s` |
| `verbose` | Enable verbose logging | `false` |
| `addPromAnnotations` | Adds Prometheus annotations so that scrapping is automatic. | `true` |
| `rewriteAppHTTPProbers` | Adds `sidecar.istio.io/rewriteAppHTTPProbers` annotation to pods so service health checks work with MTLS when using Istio. | `false` |
| `imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
| `image.repository` | Image name | `marcinbudny/servicebus_exporter` |
| `image.tag` | Image tag | `{TAG_NAME}` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `image.pullSecrets` | Specify docker-registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this different from imagePullSecrets?

| `nameOverride` | String to partially override servicebusprometheusexporter.fullname template with a string (will prepend the release name) | `nil` |
| `fullnameOverride` | String to fully override servicebusprometheusexporter.fullname template with a string | `nil` |
| `service.type` | Kubernetes Service type | `ClusterIP` |
| `service.port` | Service HTTP port where the metrics will listen on. | `9580` |
| `ingress.enabled` | Enable ingress controller resource | `false` |
| `ingress.annotations` | Ingress annotations | `[]` |
| `ingress.hosts[0].host` | Hostname to service installation | `nil` |
| `ingress.hosts[0].paths[0]` | Paths within the url structure | `[]` |
| `ingress.tls[0].hosts[0]` | TLS hosts | `nil` |
| `ingress.tls[0].secretName` | TLS Secret (certificates) | `nil` |
| `virtualservice.enabled` | Enable Istio Virtual Service | `false` |
| `virtualservice.gateways` | Istio gateways for the Virtual Service | `[]` |
| `virtualservice.hosts` | Istio hosts for the Virtual Service | `[]` |
| `virtualservice.matches` | Http matches for the Virtual Service | `[ { uri: { prefix: '/metrics' } } ]` |
| `resources` | Resource for the pods (limits, requests etc.) | `{}` |
| `podSecurityContext` | Pod security context | `{}` |
| `securityContext` | Security context | `{}` |
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `tolerations` | List of node taints to tolerate | `[]` |
| `affinity` | Map of node/pod affinities | `{}` |

The first three parameters and `service.port` map to the command line arguments for the binary.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are mapped to env variables


Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```console
$ helm install --name my-release \
--set 'connectionString=<your connection string>' \
sbe/servicebusexporter
```

The above command sets the connection string to `<your connection string>`.

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

```console
$ helm install --name my-release -f values.yaml sbe/serviceexporter
```

> **Tip**: You can use the default [values.yaml](values.yaml).

> **Tip**: Only set the connection string. You don't need to enable ingress or
> an Istio Virtual Service. The scrapper will be found because of the annotations.
2 changes: 2 additions & 0 deletions charts/servicebusexporter/ci/simple-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# fake value so the chart installs

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain purpose of this file?

connectionString: "Endpoint=sb://foobar123456.servicebus.windows.net/;SharedAccessKeyName=foobar123456-role;SharedAccessKey=anNkZmtqbGZsamtzZGZqa2xsa2pmc2FkbGtqZmpzYWxrZmpzYWxmZHNhamZsYXNmYXNmc2Rh"
28 changes: 28 additions & 0 deletions charts/servicebusexporter/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
1. Scrape endpoint will be available by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}/metrics
{{- end }}
{{- end }}
{{- else if and .Values.virtualservice.enabled .Values.virtualservice.hosts }}
{{- $root := . }}
{{- range $host := .Values.virtualservice.hosts }}
{{- range $match := $root.Values.virtualservice.matches }}
http://{{ $host }}:{{ $root.Values.service.port }}{{ $match.uri.prefix }}
{{- 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 "servicebusexporter.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT/metrics
{{- 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 "servicebusexporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "servicebusexporter.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}/metrics
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "servicebusexporter.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080/metrics to use your application"
kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME 8080:{{ .Values.service.port }}
{{- end }}
56 changes: 56 additions & 0 deletions charts/servicebusexporter/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "servicebusexporter.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 "servicebusexporter.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 "servicebusexporter.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "servicebusexporter.labels" -}}
app.kubernetes.io/name: {{ include "servicebusexporter.name" . }}
helm.sh/chart: {{ include "servicebusexporter.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "servicebusexporter.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "servicebusexporter.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
80 changes: 80 additions & 0 deletions charts/servicebusexporter/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "servicebusexporter.fullname" . }}
labels:
{{ include "servicebusexporter.labels" . | indent 4 }}
spec:
replicas: {{ .Values.replicaCount }}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes little sense to use more than one replica, since all of them will be scraped separately. That will result in multiple copies of the metrics and they will be difficult to separate.

selector:
matchLabels:
app.kubernetes.io/name: {{ include "servicebusexporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
template:
metadata:
labels:
app.kubernetes.io/name: {{ include "servicebusexporter.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.addPromAnnotations }}
annotations:
prometheus.io/scrape: "true"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowing any custom annotations may be reasonable. The prometheus.io/* annotations are the default for discovery, but it can also be based on other annotations depending on the config.

prometheus.io/path: "/metrics"
prometheus.io/port: {{ .Values.service.port | quote }}
{{- end }}
{{- if and .Values.rewriteAppHTTPProbers .Values.virtualservice.enabled }}
sidecar.istio.io/rewriteAppHTTPProbers: "true"
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "servicebusexporter.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
env:
- name: "CONNECTION_STRING"
valueFrom:
secretKeyRef:
name: {{ include "servicebusexporter.fullname" . }}
key: "connectionString"
{{- if .Values.service.port }}
- name: "PORT"
value: {{ .Values.service.port | quote }}
{{- end }}
{{- if .Values.timeout }}
- name: "TIMEOUT"
value: {{ .Values.timeout | quote }}
{{- end }}
{{- if .Values.verbose }}
- name: "VERBOSE"
value: {{ .Values.verbose | quote }}
{{- end }}
readinessProbe:
httpGet:
path: /
port: http
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
41 changes: 41 additions & 0 deletions charts/servicebusexporter/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "servicebusexporter.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{ include "servicebusexporter.labels" . | indent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/servicebusexporter/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ include "servicebusexporter.fullname" . }}
labels:
{{ include "servicebusexporter.labels" . | indent 4 }}
data:
connectionString: {{ .Values.connectionString | b64enc }}
Loading