mirror of
https://github.com/kyverno/policy-reporter.git
synced 2024-12-14 11:57:32 +00:00
Add Loki Path config to change deprecated API usage
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
This commit is contained in:
parent
011dfa830f
commit
7d9f35b294
12 changed files with 28 additions and 13 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
# 2.10.3
|
||||||
|
* Policy Reporter
|
||||||
|
* Add new config `target.loki.path` to overwrite the deprected prom push API
|
||||||
|
|
||||||
# 2.10.2
|
# 2.10.2
|
||||||
* Policy Reporter UI
|
* Policy Reporter UI
|
||||||
* New option `ui.clusters` makes it possible to configure additional external Policy Reporter APIs (<a href="https://kyverno.github.io/policy-reporter/guide/helm-chart-core#external-clusters" target="_blank">details</a>)
|
* New option `ui.clusters` makes it possible to configure additional external Policy Reporter APIs (<a href="https://kyverno.github.io/policy-reporter/guide/helm-chart-core#external-clusters" target="_blank">details</a>)
|
||||||
|
|
|
@ -5,8 +5,8 @@ description: |
|
||||||
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
|
It creates Prometheus Metrics and can send rule validation events to different targets like Loki, Elasticsearch, Slack or Discord
|
||||||
|
|
||||||
type: application
|
type: application
|
||||||
version: 2.10.2
|
version: 2.10.3
|
||||||
appVersion: 2.7.0
|
appVersion: 2.7.1
|
||||||
|
|
||||||
icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
|
icon: https://github.com/kyverno/kyverno/raw/main/img/logo.png
|
||||||
home: https://kyverno.github.io/policy-reporter
|
home: https://kyverno.github.io/policy-reporter
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
loki:
|
loki:
|
||||||
host: {{ .Values.target.loki.host | quote }}
|
host: {{ .Values.target.loki.host | quote }}
|
||||||
|
path: {{ .Values.target.loki.path | quote }}
|
||||||
minimumPriority: {{ .Values.target.loki.minimumPriority | quote }}
|
minimumPriority: {{ .Values.target.loki.minimumPriority | quote }}
|
||||||
skipExistingOnStartup: {{ .Values.target.loki.skipExistingOnStartup }}
|
skipExistingOnStartup: {{ .Values.target.loki.skipExistingOnStartup }}
|
||||||
{{- with .Values.target.loki.customLabels }}
|
{{- with .Values.target.loki.customLabels }}
|
||||||
|
|
|
@ -2,7 +2,7 @@ image:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
repository: kyverno/policy-reporter
|
repository: kyverno/policy-reporter
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
tag: 2.7.0
|
tag: 2.7.1
|
||||||
|
|
||||||
imagePullSecrets: []
|
imagePullSecrets: []
|
||||||
|
|
||||||
|
@ -232,6 +232,8 @@ target:
|
||||||
loki:
|
loki:
|
||||||
# loki host address
|
# loki host address
|
||||||
host: ""
|
host: ""
|
||||||
|
# loki api path, defaults to "/api/prom/push" (deprecated)
|
||||||
|
path: ""
|
||||||
# minimum priority "" < info < warning < critical < error
|
# minimum priority "" < info < warning < critical < error
|
||||||
minimumPriority: ""
|
minimumPriority: ""
|
||||||
# list of sources which should send to loki
|
# list of sources which should send to loki
|
||||||
|
|
|
@ -147,7 +147,7 @@ spec:
|
||||||
fsGroup: 1234
|
fsGroup: 1234
|
||||||
containers:
|
containers:
|
||||||
- name: policy-reporter
|
- name: policy-reporter
|
||||||
image: "ghcr.io/kyverno/policy-reporter:2.7.0"
|
image: "ghcr.io/kyverno/policy-reporter:2.7.1"
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
|
|
@ -259,7 +259,7 @@ spec:
|
||||||
fsGroup: 1234
|
fsGroup: 1234
|
||||||
containers:
|
containers:
|
||||||
- name: policy-reporter
|
- name: policy-reporter
|
||||||
image: "ghcr.io/kyverno/policy-reporter:2.7.0"
|
image: "ghcr.io/kyverno/policy-reporter:2.7.1"
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
|
|
@ -85,7 +85,7 @@ spec:
|
||||||
automountServiceAccountToken: true
|
automountServiceAccountToken: true
|
||||||
containers:
|
containers:
|
||||||
- name: policy-reporter
|
- name: policy-reporter
|
||||||
image: "ghcr.io/kyverno/policy-reporter:2.7.0"
|
image: "ghcr.io/kyverno/policy-reporter:2.7.1"
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
|
|
@ -26,7 +26,7 @@ spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
containers:
|
containers:
|
||||||
- name: policy-reporter
|
- name: policy-reporter
|
||||||
image: "ghcr.io/kyverno/policy-reporter:2.7.0"
|
image: "ghcr.io/kyverno/policy-reporter:2.7.1"
|
||||||
imagePullPolicy: IfNotPresent
|
imagePullPolicy: IfNotPresent
|
||||||
securityContext:
|
securityContext:
|
||||||
allowPrivilegeEscalation: false
|
allowPrivilegeEscalation: false
|
||||||
|
|
|
@ -29,6 +29,7 @@ type MetricsFilter struct {
|
||||||
type Loki struct {
|
type Loki struct {
|
||||||
Name string `mapstructure:"name"`
|
Name string `mapstructure:"name"`
|
||||||
Host string `mapstructure:"host"`
|
Host string `mapstructure:"host"`
|
||||||
|
Path string `mapstructure:"path"`
|
||||||
CustomLabels map[string]string `mapstructure:"customLabels"`
|
CustomLabels map[string]string `mapstructure:"customLabels"`
|
||||||
SkipExisting bool `mapstructure:"skipExistingOnStartup"`
|
SkipExisting bool `mapstructure:"skipExistingOnStartup"`
|
||||||
MinimumPriority string `mapstructure:"minimumPriority"`
|
MinimumPriority string `mapstructure:"minimumPriority"`
|
||||||
|
|
|
@ -143,6 +143,9 @@ func (r *Resolver) LokiClients() []target.Client {
|
||||||
if r.config.Loki.Name == "" {
|
if r.config.Loki.Name == "" {
|
||||||
r.config.Loki.Name = "Loki"
|
r.config.Loki.Name = "Loki"
|
||||||
}
|
}
|
||||||
|
if r.config.Loki.Path == "" {
|
||||||
|
r.config.Loki.Path = "/api/prom/push"
|
||||||
|
}
|
||||||
|
|
||||||
if loki := createLokiClient(r.config.Loki, Loki{}); loki != nil {
|
if loki := createLokiClient(r.config.Loki, Loki{}); loki != nil {
|
||||||
clients = append(clients, loki)
|
clients = append(clients, loki)
|
||||||
|
@ -534,11 +537,15 @@ func createLokiClient(config Loki, parent Loki) target.Client {
|
||||||
config.MinimumPriority = parent.MinimumPriority
|
config.MinimumPriority = parent.MinimumPriority
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.Path == "" {
|
||||||
|
config.Path = parent.Path
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("[INFO] %s configured", config.Name)
|
log.Printf("[INFO] %s configured", config.Name)
|
||||||
|
|
||||||
return loki.NewClient(
|
return loki.NewClient(
|
||||||
config.Name,
|
config.Name,
|
||||||
config.Host,
|
config.Host+config.Path,
|
||||||
config.SkipExisting,
|
config.SkipExisting,
|
||||||
createTargetFilter(config.Filter, config.MinimumPriority, config.Sources),
|
createTargetFilter(config.Filter, config.MinimumPriority, config.Sources),
|
||||||
config.CustomLabels,
|
config.CustomLabels,
|
||||||
|
|
|
@ -98,10 +98,10 @@ func (l *client) Send(result report.Result) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a new loki.client to send Results to Loki
|
// NewClient creates a new loki.client to send Results to Loki
|
||||||
func NewClient(name, host string, skipExistingOnStartup bool, filter *report.ResultFilter, customLabels map[string]string, httpClient http.Client) target.Client {
|
func NewClient(name, api string, skipExistingOnStartup bool, filter *report.ResultFilter, customLabels map[string]string, httpClient http.Client) target.Client {
|
||||||
return &client{
|
return &client{
|
||||||
target.NewBaseClient(name, skipExistingOnStartup, filter),
|
target.NewBaseClient(name, skipExistingOnStartup, filter),
|
||||||
host + "/api/prom/push",
|
api,
|
||||||
httpClient,
|
httpClient,
|
||||||
customLabels,
|
customLabels,
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,7 +117,7 @@ func Test_LokiTarget(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loki := loki.NewClient("Loki", "http://localhost:3100", false, &report.ResultFilter{}, map[string]string{"custom": "label"}, testClient{callback, 200})
|
loki := loki.NewClient("Loki", "http://localhost:3100/api/prom/push", false, &report.ResultFilter{}, map[string]string{"custom": "label"}, testClient{callback, 200})
|
||||||
loki.Send(completeResult)
|
loki.Send(completeResult)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -175,11 +175,11 @@ func Test_LokiTarget(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loki := loki.NewClient("Loki", "http://localhost:3100", false, &report.ResultFilter{}, make(map[string]string), testClient{callback, 200})
|
loki := loki.NewClient("Loki", "http://localhost:3100/api/prom/push", false, &report.ResultFilter{}, make(map[string]string), testClient{callback, 200})
|
||||||
loki.Send(minimalResult)
|
loki.Send(minimalResult)
|
||||||
})
|
})
|
||||||
t.Run("Name", func(t *testing.T) {
|
t.Run("Name", func(t *testing.T) {
|
||||||
client := loki.NewClient("Loki", "http://localhost:9200", true, &report.ResultFilter{}, make(map[string]string), testClient{})
|
client := loki.NewClient("Loki", "http://localhost:9200/api/prom/push", true, &report.ResultFilter{}, make(map[string]string), testClient{})
|
||||||
|
|
||||||
if client.Name() != "Loki" {
|
if client.Name() != "Loki" {
|
||||||
t.Errorf("Unexpected Name %s", client.Name())
|
t.Errorf("Unexpected Name %s", client.Name())
|
||||||
|
|
Loading…
Reference in a new issue