Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #21 from integr8ly/namespace-selector
Browse files Browse the repository at this point in the history
add dashboard namespace selector
  • Loading branch information
pb82 authored Feb 5, 2019
2 parents be4b91c + 99260ae commit 44bd9ca
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ spec:
env:
- name: TEMPLATE_PATH
value: /usr/local/bin/templates
- name: MONITORING_KEY
value: middleware
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
Expand Down
11 changes: 9 additions & 2 deletions pkg/controller/applicationmonitoring/templateHelper.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type Parameters struct {
AlertManagerRouteName string
GrafanaServiceMonitorName string
PrometheusServiceMonitorName string
MonitoringKey string
}

type TemplateHelper struct {
Expand Down Expand Up @@ -80,13 +81,19 @@ func newTemplateHelper(cr *applicationmonitoring.ApplicationMonitoring) *Templat
AlertManagerRouteName: AlertManagerRouteName,
GrafanaServiceMonitorName: GrafanaServiceMonitorName,
PrometheusServiceMonitorName: PrometheusServiceMonitorName,
MonitoringKey: "middleware",
}

templatePath := os.Getenv("TEMPLATE_PATH")
if templatePath == "" {
templatePath, exists := os.LookupEnv("TEMPLATE_PATH")
if !exists {
templatePath = "./templates"
}

monitoringKey, exists := os.LookupEnv("MONITORING_KEY")
if exists {
param.MonitoringKey = monitoringKey
}

return &TemplateHelper{
Parameters: param,
TemplatePath: templatePath,
Expand Down
3 changes: 3 additions & 0 deletions templates/grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ metadata:
namespace: {{ .Namespace }}
spec:
prometheusUrl: "http://prometheus-service:9090"
dashboardNamespaceSelector:
matchLabels:
monitoring-key: {{ .MonitoringKey }}

0 comments on commit 44bd9ca

Please sign in to comment.