Skip to content

Commit

Permalink
Improve ServiceMonitor customization
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Jogeleit committed Feb 28, 2021
1 parent a949b40 commit 5e4bacd
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 11 deletions.
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
# Changelog

## 0.9.0
## 0.11.0

* Helm Chart Value `metrics.serviceMonitor` changed to `metrics.serviceMonitor.enabled`
* New Helm Chart Value `metrics.serviceMonitor.labels` can be used to add additional `labels` to the `SeriveMonitor`. This helps to fullfil the `serviceMonitorSelector` of the `Prometheus` Resource in the MonitoringStack.

## 0.10.0

* Implement Discord as Target for PolicyReportResults

## 0.8.0
## 0.9.0

* Implement Slack as Target for PolicyReportResults

## 0.7.0
## 0.8.0

* Implement Elasticsearch as Target for PolicyReportResults
* Replace CLI flags with a single `config.yaml` to manage target-configurations as separate `ConfigMap`
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ elasticsearch:
helm install policy-reporter policy-reporter/policy-reporter --set slack.webhook=http://hook.slack -n policy-reporter --create-namespace
```

### Additional configurations for Slack
#### Additional configurations for Slack

* Configure `slack.minimumPriority` to send only results with the configured minimumPriority or above, empty means all results. (info < warning < error)
* Configure `slack.skipExistingOnStartup` to skip all results who already existed before the PolicyReporter started (default: `true`).
Expand Down Expand Up @@ -101,7 +101,7 @@ discord:
### Customization
You can combine multiple targets by setting the required `host` or `webhook` configuration for your targets of choice. For all possible configurations checkout the `./charts/policy-reporter/values.yaml` to change any configurations available.
You can combine multiple targets by setting the required `host` or `webhook` configuration for your targets of choice. For all possible configurations checkout the `./charts/policy-reporter/values.yaml` to change any available configuration.

### Configure Policy Priorities

Expand All @@ -117,7 +117,8 @@ kubectl create configmap policy-reporter-priorities --from-literal check-label-a

The Helm Chart includes optional Manifests for the [MonitoringStack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack). The provided Dashboard works without Loki

* Enable a ServiceMonitor by setting `metrics.serviceMonitor` to `true`.
* Enable a ServiceMonitor by setting `metrics.serviceMonitor.enabled` to `true`.
* With `metrics.serviceMonitor.labels` you can add additional labels to the `ServiceMonitor`. This helps to match the `serviceMonitorSelector` configuration of your Prometheus resource
* Enable a basic Dashboard as ConfigMap by setting `metrics.dashboard.enabled` to `true`.
* Change the namespace to your required monitoring namespace by changing `metrics.dashboard.namespace` (default: cattle-dashboards)

Expand Down
2 changes: 1 addition & 1 deletion charts/policy-reporter/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: policy-reporter
description: K8s PolicyReporter watches for wgpolicyk8s.io/v1alpha1.PolicyReport resources. It creates Prometheus Metrics and can send rule validation events to Loki

type: application
version: 0.10.0
version: 0.11.0
appVersion: 0.9.0
6 changes: 5 additions & 1 deletion charts/policy-reporter/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{{- if .Values.metrics.serviceMonitor }}
{{- if .Values.metrics.serviceMonitor.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
name: {{ include "policyreporter.fullname" . }}
{{- if .Values.metrics.serviceMonitor.labels }}
labels:
{{- toYaml .Values.metrics.serviceMonitor.labels | nindent 4 }}
{{- end }}
spec:
selector:
matchLabels:
Expand Down
6 changes: 5 additions & 1 deletion charts/policy-reporter/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ discord:
skipExistingOnStartup: true

metrics:
serviceMonitor: false
serviceMonitor:
enabled: false
# labels to match the serviceMonitorSelector of the Prometheus Resource
labels: {}

dashboard:
enabled: false
namespace: cattle-dashboards
Expand Down
2 changes: 1 addition & 1 deletion pkg/target/discord/discord_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_LokiTarget(t *testing.T) {
}

slack := discord.NewClient("http://hook.discord:80", "", false, testClient{callback, 200})
slack.Send(minimalResult)
slack.Send(completeResult)
})

t.Run("Send Minimal Result", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/target/slack/slack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func Test_LokiTarget(t *testing.T) {
}

slack := slack.NewClient("http://hook.slack:80", "", false, testClient{callback, 200})
slack.Send(minimalResult)
slack.Send(completeResult)
})

t.Run("Send Minimal Result", func(t *testing.T) {
Expand Down

0 comments on commit 5e4bacd

Please sign in to comment.