Skip to content

Commit

Permalink
Merge pull request #1348 from christianhuth/dev-dns-exporter
Browse files Browse the repository at this point in the history
Initial Commit for DNS-Exporter
  • Loading branch information
christianhuth authored Feb 24, 2025
2 parents 7974602 + 29d941a commit ec5e40c
Show file tree
Hide file tree
Showing 19 changed files with 1,385 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ You can then run `helm search repo christianhuth` to see the current list of ava
| [argocd-metrics-server](./charts/argocd-metrics-server) | [argoprojlabs/argocd-extension-metrics](https://quay.io/argoprojlabs/argocd-extension-metrics) | [The ArgoCD Metrics Server connects to Prometheus and displays Metrics in the ArgoCD UI.](https://github.com/argoproj-labs/argocd-extension-metrics) |
| [baserow](./charts/baserow) | [baserow/backend](https://hub.docker.com/r/baserow/backend), [baserow/web-frontend](https://hub.docker.com/r/baserow/web-frontend) | [Baserow is an open source no-code database and Airtable alternative.](https://baserow.io) |
| [cluster-api-visualizer](./charts/cluster-api-visualizer) | [jont828/cluster-api-visualizer](https://ghcr.io/jont828/cluster-api-visualizer) | [Multicluster resource visualization tool for Cluster API.](https://github.com/Jont828/cluster-api-visualizer) |
| [dns-exporter](./charts/dns-exporter) | [tykling/dns_exporter](https://hub.docker.com/r/tykling/dns_exporter) | [A multi-target Prometheus exporter with an exclusive focus on DNS monitoring.](https://github.com/tykling/dns_exporter) |
| [etcd-defrag](./charts/etcd-defrag) | [bitnami/etcd](https://hub.docker.com/r/bitnami/etcd) | [Runs a defragmentation CronJob for ETCD](https://etcd.io/docs/latest/op-guide/maintenance/#defragmentation) |
| [github-exporter](./charts/github-exporter) | [githubexporter/github-exporter](https://hub.docker.com/r/githubexporter/github-exporter) | [Prometheus Exporter for generating GitHub Metrics](https://github.com/githubexporter/github-exporter) |
| [headwind-mdm](./charts/headwind-mdm) | [headwindmdm/hmdm](https://hub.docker.com/r/headwindmdm/hmdm) | [Headwind MDM is an open source mobile device management software for Android](https://h-mdm.com) |
Expand Down
29 changes: 29 additions & 0 deletions charts/dns-exporter/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 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/

# Chart-Testing Files
ci/

# Additional Helm Values for Development or Testing
values-*.yaml
7 changes: 7 additions & 0 deletions charts/dns-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# dns-exporter

## 1.0.0

### Added

- Changelog
23 changes: 23 additions & 0 deletions charts/dns-exporter/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
name: dns-exporter
description: A multi-target Prometheus exporter with an exclusive focus on DNS monitoring
type: application
version: 1.0.0
appVersion: "v1.1.0"
home: https://github.com/christianhuth/helm-charts
maintainers:
- name: christianhuth
email: [email protected]
sources:
- https://github.com/tykling/dns_exporter
annotations:
artifacthub.io/category: monitoring-logging
artifacthub.io/changes: |
- kind: added
description: Changelog
artifacthub.io/screenshots: |
- title: Display DNS exporter results using Grafana
url: https://grafana.com/api/dashboards/20617/images/15803/image
artifacthub.io/signKey: |
fingerprint: EE24F8BB6D099E78FD704F83B5ECDBCDDD485D0E
url: https://charts.christianhuth.de/public.key
158 changes: 158 additions & 0 deletions charts/dns-exporter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
# dns-exporter

A multi-target Prometheus exporter with an exclusive focus on DNS monitoring

## TL;DR;

```console
helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/dns-exporter
```

## Introduction

This chart bootstraps the [Prometheus DNS-Exporter](https://github.com/tykling/dns_exporter) using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.19+

## Installing the Chart

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

```console
helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/dns-exporter
```

These commands deploy the DNS-Exporter on the Kubernetes cluster in the default configuration. The [Values](#values) section lists the values that can be configured during installation.

> **Tip**: List all releases using `helm list`
### Defining Scrape Targets

This Helm Charts allows you to create two ServiceMonitors:

- One for the metrics of the DNS-Exporter itself
- One for the DNS metrics of the targets

The Scrape Targets can be configured using `.serviceMonitor.targetsMonitor.targets`.
For each Scrape Target we need to define at least the DNS server and ip family (`ipv4` or `ipv6`).
You also have to define the family if you are scraping DNS records unrelated to the ip address type like NS.

A basic example would look like this:

```yaml
serviceMonitor:
targetsMonitor:
targets:
- query_name:
- christianhuth.de
family:
- ipv4
server:
- dns.google
```
While this looks like you can define multiple values for the attributes, this is sadly not supported by the DNS-Exporter.
Defining multiple values will result in only the first value taking affect.
There are more attributes you can define for each target.
A complete list can be found [https://dns-exporter.readthedocs.io/latest/configuration.html#settings](in the official documentation).
Instead of defining all the attributes (like family, server, ...) for each target again, you can use pre-defined modules or define your own ones using .Values.serviceMonitor.modules.
```yaml
serviceMonitor:
targetsMonitor:
modules:
google_udp:
family: ipv4
protocol: udp
server: dns.google
query_type: NS
targets:
- query_name:
- christianhuth.de
module:
- google_udp
```
This will result in a query for the NS records of christianhuth.de using the DNS server dns.google with the UDP protocol.
In this example, the ip family is only defined, because DNS-Exporter won't work without defining one.
## Uninstalling the Chart
To uninstall the `my-release` deployment:

```console
helm uninstall my-release
```

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

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| affinity | object | `{}` | Affinity settings for pod assignment |
| autoscaling.enabled | bool | `false` | |
| autoscaling.maxReplicas | int | `100` | |
| autoscaling.minReplicas | int | `1` | |
| autoscaling.targetCPUUtilizationPercentage | int | `80` | |
| extraEnv | list | `[]` | Additional environment variables that will be added to the deployment |
| fullnameOverride | string | `""` | String to fully override `"netcupscp-exporter.fullname"` |
| image.pullPolicy | string | `"Always"` | image pull policy |
| image.registry | string | `"docker.io"` | image registry |
| image.repository | string | `"tykling/dns_exporter"` | image repository |
| image.tag | string | `"v1.1.0"` | Overrides the image tag |
| imagePullSecrets | list | `[]` | If defined, uses a Secret to pull an image from a private Docker registry or repository. |
| ingress.annotations | object | `{}` | |
| ingress.className | string | `""` | |
| ingress.enabled | bool | `false` | |
| ingress.hosts[0].host | string | `"chart-example.local"` | |
| ingress.hosts[0].paths[0].path | string | `"/"` | |
| ingress.hosts[0].paths[0].pathType | string | `"ImplementationSpecific"` | |
| ingress.tls | list | `[]` | |
| nameOverride | string | `""` | Provide a name in place of `netcupscp-exporter` |
| nodeSelector | object | `{}` | Node labels for pod assignment |
| podAnnotations | object | `{}` | Annotations to be added to pods |
| podSecurityContext | object | `{}` | pod-level security context |
| replicaCount | int | `1` | Number of replicas |
| resources | object | `{}` | Resource limits and requests for the headwind pods. |
| revisionHistoryLimit | int | `0` | The number of old ReplicaSets to retain |
| securityContext | object | `{}` | container-level security context |
| service.port | int | `80` | Kubernetes port where service is exposed |
| service.type | string | `"ClusterIP"` | Kubernetes service type |
| serviceAccount.annotations | object | `{}` | Annotations to add to the service account |
| serviceAccount.create | bool | `true` | Specifies whether a service account should be created |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| serviceMonitor.enabled | bool | `false` | Enable a prometheus ServiceMonitor |
| serviceMonitor.modules | object | `{}` | Define modules that can be used inside your targets |
| serviceMonitor.selfMonitor.additionalLabels | object | `{}` | Prometheus ServiceMonitor labels |
| serviceMonitor.selfMonitor.enabled | bool | `true` | Enable a prometheus ServiceMonitor to monitor the DNS Exporter |
| serviceMonitor.selfMonitor.interval | string | `"30s"` | Prometheus ServiceMonitor interval |
| serviceMonitor.selfMonitor.metricRelabelings | list | `[]` | Prometheus [MetricRelabelConfigs] to apply to samples before ingestion |
| serviceMonitor.selfMonitor.namespace | string | `""` | Prometheus ServiceMonitor namespace |
| serviceMonitor.selfMonitor.relabelings | list | `[]` | Prometheus [RelabelConfigs] to apply to samples before scraping |
| serviceMonitor.selfMonitor.selector | object | `{}` | Prometheus ServiceMonitor selector |
| serviceMonitor.targetsMonitor.additionalLabels | object | `{}` | Prometheus ServiceMonitor labels |
| serviceMonitor.targetsMonitor.enabled | bool | `true` | Enable a prometheus ServiceMonitor to monitor the Targets of the DNS Exporter |
| serviceMonitor.targetsMonitor.interval | string | `"30s"` | Prometheus ServiceMonitor interval |
| serviceMonitor.targetsMonitor.metricRelabelings | list | `[]` | Prometheus [MetricRelabelConfigs] to apply to samples before ingestion |
| serviceMonitor.targetsMonitor.namespace | string | `""` | Prometheus ServiceMonitor namespace |
| serviceMonitor.targetsMonitor.relabelings | list | `[]` | Prometheus [RelabelConfigs] to apply to samples before scraping |
| serviceMonitor.targetsMonitor.selector | object | `{}` | Prometheus ServiceMonitor selector |
| serviceMonitor.targetsMonitor.targets | list | `[]` | Targets that should be scraped by the DNS-Exporter |
| tolerations | list | `[]` | Toleration labels for pod assignment |

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

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

```console
helm install my-release -f values.yaml christianhuth/dns-exporter
```
104 changes: 104 additions & 0 deletions charts/dns-exporter/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{{ template "chart.header" . }}
{{ template "chart.description" . }}

## TL;DR;

```console
helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/dns-exporter
```

## Introduction

This chart bootstraps the [Prometheus DNS-Exporter](https://github.com/tykling/dns_exporter) using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.19+

## Installing the Chart

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

```console
helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/dns-exporter
```

These commands deploy the DNS-Exporter on the Kubernetes cluster in the default configuration. The [Values](#values) section lists the values that can be configured during installation.

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

### Defining Scrape Targets

This Helm Charts allows you to create two ServiceMonitors:

- One for the metrics of the DNS-Exporter itself
- One for the DNS metrics of the targets

The Scrape Targets can be configured using `.serviceMonitor.targetsMonitor.targets`.
For each Scrape Target we need to define at least the DNS server and ip family (`ipv4` or `ipv6`).
You also have to define the family if you are scraping DNS records unrelated to the ip address type like NS.

A basic example would look like this:

```yaml
serviceMonitor:
targetsMonitor:
targets:
- query_name:
- christianhuth.de
family:
- ipv4
server:
- dns.google
```

While this looks like you can define multiple values for the attributes, this is sadly not supported by the DNS-Exporter.
Defining multiple values will result in only the first value taking affect.

There are more attributes you can define for each target.
A complete list can be found [https://dns-exporter.readthedocs.io/latest/configuration.html#settings](in the official documentation).

Instead of defining all the attributes (like family, server, ...) for each target again, you can use pre-defined modules or define your own ones using .Values.serviceMonitor.modules.

```yaml
serviceMonitor:
targetsMonitor:
modules:
google_udp:
family: ipv4
protocol: udp
server: dns.google
query_type: NS
targets:
- query_name:
- christianhuth.de
module:
- google_udp
```

This will result in a query for the NS records of christianhuth.de using the DNS server dns.google with the UDP protocol.
In this example, the ip family is only defined, because DNS-Exporter won't work without defining one.

## Uninstalling the Chart

To uninstall the `my-release` deployment:

```console
helm uninstall my-release
```

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

{{ template "chart.valuesSection" . }}

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

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

```console
helm install my-release -f values.yaml christianhuth/dns-exporter
```
22 changes: 22 additions & 0 deletions charts/dns-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 }}{{ .path }}
{{- 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 "dns-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 "dns-exporter.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "dns-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 "dns-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 }}
Loading

0 comments on commit ec5e40c

Please sign in to comment.