-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add OpenCost to the ClusterMetrics feature
Signed-off-by: Pete Wall <pete.wall@grafana.com>
- Loading branch information
Showing
52 changed files
with
1,772 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
--- | ||
name: Update dependency "opencost" for Helm chart "feature-cluster-metrics" | ||
sources: | ||
opencost: | ||
name: Get latest "opencost" Helm chart version | ||
kind: helmchart | ||
spec: | ||
name: opencost | ||
url: https://opencost.github.io/opencost-helm-chart | ||
versionfilter: | ||
kind: semver | ||
pattern: '*' | ||
conditions: | ||
opencost: | ||
name: Ensure Helm chart dependency "opencost" is specified | ||
kind: yaml | ||
spec: | ||
file: charts/feature-cluster-metrics/Chart.yaml | ||
key: $.dependencies[4].name | ||
value: opencost | ||
disablesourceinput: true | ||
targets: | ||
opencost: | ||
name: Bump Helm chart dependency "opencost" for Helm chart "feature-cluster-metrics" | ||
kind: helmchart | ||
spec: | ||
file: Chart.yaml | ||
key: $.dependencies[4].version | ||
name: charts/feature-cluster-metrics | ||
versionincrement: none | ||
sourceid: opencost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
charts/feature-cluster-metrics/templates/_opencost.alloy.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
{{ define "feature.clusterMetrics.opencost.allowList" }} | ||
{{ if .Values.opencost.metricsTuning.useDefaultAllowList }} | ||
{{ "default-allow-lists/opencost.yaml" | .Files.Get }} | ||
{{ end }} | ||
{{ if .Values.opencost.metricsTuning.includeMetrics }} | ||
{{ .Values.opencost.metricsTuning.includeMetrics | toYaml }} | ||
{{ end }} | ||
{{ end }} | ||
|
||
{{- define "feature.clusterMetrics.opencost.alloy" }} | ||
{{- if .Values.opencost.enabled }} | ||
{{- $metricAllowList := include "feature.clusterMetrics.opencost.allowList" . }} | ||
{{- $metricDenyList := .Values.opencost.metricsTuning.excludeMetrics }} | ||
{{- $labelSelectors := list }} | ||
{{- range $k, $v := .Values.opencost.labelMatchers }} | ||
{{- $labelSelectors = append $labelSelectors (printf "%s=%s" $k $v) }} | ||
{{- end }} | ||
|
||
discovery.kubernetes "opencost" { | ||
role = "pod" | ||
namespaces { | ||
own_namespace = true | ||
} | ||
selectors { | ||
role = "pod" | ||
label = {{ $labelSelectors | join "," | quote }} | ||
} | ||
} | ||
|
||
discovery.relabel "opencost" { | ||
targets = discovery.kubernetes.opencost.targets | ||
rule { | ||
source_labels = ["__meta_kubernetes_pod_node_name"] | ||
action = "replace" | ||
target_label = "instance" | ||
} | ||
{{- if .Values.opencost.extraDiscoveryRules }} | ||
{{ .Values.opencost.extraDiscoveryRules | indent 2 }} | ||
{{- end }} | ||
} | ||
|
||
prometheus.scrape "opencost" { | ||
targets = discovery.relabel.opencost.output | ||
job_name = "integrations/opencost" | ||
honor_labels = true | ||
scrape_interval = {{ .Values.opencost.scrapeInterval | default .Values.global.scrapeInterval | quote }} | ||
clustering { | ||
enabled = true | ||
} | ||
{{- if or $metricAllowList $metricDenyList .Values.opencost.extraMetricProcessingRules }} | ||
forward_to = [prometheus.relabel.opencost.receiver] | ||
} | ||
|
||
prometheus.relabel "opencost" { | ||
max_cache_size = {{ .Values.opencost.maxCacheSize | default .Values.global.maxCacheSize | int }} | ||
{{- if $metricAllowList }} | ||
rule { | ||
source_labels = ["__name__"] | ||
regex = "up|{{ $metricAllowList | fromYamlArray | join "|" }}" | ||
action = "keep" | ||
} | ||
{{- end }} | ||
{{- if $metricDenyList }} | ||
rule { | ||
source_labels = ["__name__"] | ||
regex = {{ $metricDenyList | join "|" | quote }} | ||
action = "drop" | ||
} | ||
{{- end }} | ||
{{- if .Values.opencost.extraMetricProcessingRules }} | ||
{{ .Values.opencost.extraMetricProcessingRules | indent 2 }} | ||
{{- end }} | ||
{{- end }} | ||
forward_to = argument.metrics_destinations.value | ||
} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.